本文整理汇总了PHP中Cabinet::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Cabinet::find方法的具体用法?PHP Cabinet::find怎么用?PHP Cabinet::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cabinet
的用法示例。
在下文中一共展示了Cabinet::find方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterSave
public function afterSave($created)
{
parent::afterSave($created);
if (isset($this->data['CabinetOrder']['resource_type']) && $this->data['CabinetOrder']['resource_type'] == 'cabinet') {
App::import('Model', 'Inventory.Cabinet');
$cabinet_model = new Cabinet();
$cabinet_model->recursive = 1;
$cabinet_detail = $cabinet_model->find('first', array('conditions' => array('Cabinet.id' => $this->data['CabinetOrder']['resource_id'])));
if (!empty($cabinet_detail['CabinetsItem']) && is_array($cabinet_detail['CabinetsItem'])) {
foreach ($cabinet_detail['CabinetsItem'] as $key => $cabinet_item) {
$this->data['CabinetOrderItem'][$key] = array('cabinet_order_id' => $this->data['CabinetOrder']['id'], 'quote_id' => $this->data['CabinetOrder']['quote_id'], 'cabinet_id' => $this->data['CabinetOrder']['resource_id'], 'quantity' => $this->data['CabinetOrder']['quantity'] * $cabinet_item['item_quantity'], 'item_id' => $cabinet_item['item_id'], 'code' => "{$cabinet_item['item_id']}|item", 'type' => 'Cabinet Order');
}
}
}
if (isset($this->data['CabinetOrderItem'])) {
// delete CabinetOrderItem
$this->CabinetOrderItem->deleteAll(array('cabinet_order_id' => $this->id));
if (is_array($this->data['CabinetOrderItem'])) {
// save CabinetOrderItem
// $cabinetOrderItems = array();
// $index = 0;
// foreach ($this->data['CabinetOrderItem'] as $cabinetOrderItem) {
// if (trim($cabinetOrderItem['quantity']) == '' || trim($cabinetOrderItem['code']) == '') {
// continue; // skip if no data
// }
// $cabinetOrderItems[$index]['cabinet_order_id'] = $this->id;
// $cabinetOrderItems[$index]['item_id'] = trim($cabinetOrderItem['item_id']);
// $cabinetOrderItems[$index]['cabinet_id'] = trim($cabinetOrderItem['cabinet_id']);
//// $cabinetOrderItems[$index]['door_id'] = trim($cabinetOrderItem['door_id']);
//// $cabinetOrderItems[$index]['door_information'] = trim($cabinetOrderItem['door_information']);
//// $cabinetOrderItems[$index]['open_frame_door'] = trim($cabinetOrderItem['open_frame_door']);
//// $cabinetOrderItems[$index]['do_not_drill_door'] = trim($cabinetOrderItem['do_not_drill_door']);
//// $cabinetOrderItems[$index]['no_doors'] = trim($cabinetOrderItem['no_doors']);
// $cabinetOrderItems[$index]['quantity'] = trim($cabinetOrderItem['quantity']);
// $cabinetOrderItems[$index]['code'] = trim($cabinetOrderItem['code']);
// $cabinetOrderItems[$index]['type'] = "Cabinet Order";
//
// $index++;
// }
$this->CabinetOrderItem->saveAll($this->data['CabinetOrderItem']);
}
}
}
示例2: getCabinetItems
function getCabinetItems()
{
set_time_limit(0);
$this->autoRender = false;
$sql = "SELECT * FROM cabinetparts;";
$datas = $this->Cabinet->query($sql);
App::uses("CabinetsItem", "Inventory.Model");
App::uses("Cabinet", "Inventory.Model");
$Cabinet_model = new Cabinet();
App::uses("Item", "Inventory.Model");
$Item_model = new Item();
foreach ($datas as $data) {
$CabinetsItem_model = new CabinetsItem();
$cabinet_data['CabinetsItem']['lineid'] = $data['cabinetparts']['lineid'];
$cabinet_data = $Cabinet_model->find('first', array('fields' => array('id', 'name'), 'conditions' => array('Cabinet.name' => $data['cabinetparts']['cabinet']), 'recursive' => -1));
$cabinet_data['CabinetsItem']['cabinet_id'] = !empty($cabinet_data['Cabinet']['id']) ? $cabinet_data['Cabinet']['id'] : "0";
$Item_data = $Item_model->find('first', array('fields' => array('id', 'number'), 'conditions' => array('Item.number' => $data['cabinetparts']['number']), 'recursive' => -1));
$cabinet_data['CabinetsItem']['item_id'] = !empty($Item_data['Item']['id']) ? $Item_data['Item']['id'] : "0";
if (!empty($Item_data)) {
$item['Item']['id'] = $Item_data['Item']['id'];
$item['Item']['item_department_id'] = 3;
$item['Item']['Department'] = 'Accessories';
if (!$Item_model->save($item)) {
pr($Item_model->validationErrors);
}
}
$cabinet_data['CabinetsItem']['item_quantity'] = !empty($data['cabinetparts']['quantity']) ? $data['cabinetparts']['quantity'] : "1";
$cabinet_data['CabinetsItem']['component'] = $data['cabinetparts']['component'];
$cabinet_data['CabinetsItem']['category'] = $data['cabinetparts']['category'];
$cabinet_data['CabinetsItem']['number'] = $data['cabinetparts']['number'];
$cabinet_data['CabinetsItem']['accessories'] = 1;
if (!$CabinetsItem_model->save($cabinet_data)) {
pr($CabinetsItem_model->validationErrors);
}
}
}
示例3: findTotalAmountQuote
function findTotalAmountQuote($id = null)
{
$quote = $this->Quote->read(null, $id);
$total_quote_price = 0;
$total_quote_price_cabinet = 0;
$total_quote_price_installation = 0;
$total_quote_price_discount = 0;
$cabinets = array();
if ($quote['CabinetOrder'] && is_array($quote['CabinetOrder'])) {
App::import("Model", "Inventory.Cabinet");
App::import("Model", "Inventory.Item");
foreach ($quote['CabinetOrder'] as $cabinet_order) {
$cabinet = new Cabinet();
$item_model = new Item();
$resource_detail = array('Resource' => array('name' => '', 'description' => ''));
switch ($cabinet_order['resource_type']) {
case 'cabinet':
$resource_detail = $cabinet->find('first', array('conditions' => array('id' => $cabinet_order['resource_id'])));
$resource_detail['Resource']['name'] = $resource_detail['Cabinet']['name'];
$resource_detail['Resource']['description'] = $resource_detail['Cabinet']['description'];
$cabinets[] = $resource_detail;
break;
case 'item':
$resource_detail = $item_model->find('first', array('conditions' => array('Item.id' => $cabinet_order['resource_id'])));
$resource_detail['Resource']['name'] = $resource_detail['Cabinet'][0]['name'];
$resource_detail['Resource']['description'] = $resource_detail['Cabinet'][0]['description'];
$cabinets[] = $resource_detail;
break;
default:
break;
}
$sub_total = $cabinet_order['total_cost'];
$total_quote_price_cabinet += $sub_total;
}
}
if ($quote['Quote']['installation'] == 'We Installed' && !empty($cabinets) && is_array($cabinets)) {
$installation_summery_list = array();
foreach ($cabinets as $cabinet) {
if (!empty($cabinet['CabinetInstallation']) && is_array($cabinet['CabinetInstallation'])) {
foreach ($cabinet['CabinetInstallation'] as $installation) {
if (isset($installation_summery_list[$installation['name']]['quantity'])) {
$installation_summery_list[$installation['name']]['quantity']++;
} else {
$installation_summery_list[$installation['name']]['name'] = $installation['name'];
$installation_summery_list[$installation['name']]['price_unit'] = $installation['price_unit'];
$installation_summery_list[$installation['name']]['price'] = $installation['price'];
$installation_summery_list[$installation['name']]['quantity'] = 1;
}
}
}
}
if (!empty($installation_summery_list)) {
foreach ($installation_summery_list as $installation) {
$sub_total = $installation['price'] * $installation['quantity'];
$total_quote_price_installation += $sub_total;
}
}
}
$total_quote_price = $total_quote_price_cabinet + $total_quote_price_installation;
if ($quote['Quote']['delivery'] == '5 – 10 Weeks Delivery') {
$total_quote_price_discount = $total_quote_price * 0.25;
// 25% discount for late delivery
}
$total_quote_price -= $total_quote_price_discount;
return $total_quote_price;
}
示例4: Cabinet
function CabinetName2ID($name = null, $reverse = false)
{
// App::uses("Cabinet", "Inventory.Model");
App::import('Model', 'Inventory.Cabinet');
$cabinet = new Cabinet();
$cabinet->recursive = 0;
if (!$reverse) {
$cabinet_info = $cabinet->find("first", array("fields" => array("id", "name"), 'conditions' => array('Cabinet.name' => $name)));
} else {
$cabinet_info = $cabinet->find("first", array("fields" => array("id", "name"), 'conditions' => array('Cabinet.id' => $name)));
}
if (isset($cabinet_info['Cabinet']['id'])) {
if (!$reverse) {
return $cabinet_info['Cabinet']['id'];
} else {
return $cabinet_info['Cabinet']['name'];
}
} else {
return null;
}
}
示例5: Cabinet
function cabinet_json()
{
$id = $this->request->query['term'];
App::uses("Cabinet", "Inventory.Model");
$cabinet = new Cabinet();
$cabinet_list = array();
$cabinet_list = $cabinet->find("all", array('conditions' => array('Cabinet.id' => $id), 'order' => array('Cabinet.name' => 'asc'), 'limit' => 1));
$return_data = array();
foreach ($cabinet_list as $id => $cabinet_detail) {
if ($cabinet_detail) {
$return_data['id'] = $cabinet_detail['Cabinet']['id'];
$return_data['text'] = $cabinet_detail['Cabinet']['name'];
$return_data['item_type'] = 'cabinet';
$return_data['detail'] = $cabinet_detail['Cabinet'];
$return_data['door_count'] = (int) $cabinet_detail['Cabinet']['top_door_count'] + (int) $cabinet_detail['Cabinet']['bottom_door_count'] + (int) $cabinet_detail['Cabinet']['top_drawer_front_count'] + (int) $cabinet_detail['Cabinet']['middle_drawer_front_count'] + (int) $cabinet_detail['Cabinet']['bottom_drawer_front_count'] + (int) $cabinet_detail['Cabinet']['dummy_drawer_front_count'];
$return_data['quote_color_required'] = (int) $cabinet_detail['Cabinet']['quote_color_required'];
$return_data['quote_material_required'] = (int) $cabinet_detail['Cabinet']['quote_material_required'];
break;
}
}
print json_encode($return_data);
exit;
}
示例6: calculateCabinetPriceForBuilder
public function calculateCabinetPriceForBuilder($cabinet_id, $cabinet_color, $material_id, $door_id, $door_color, $drawer_id, $drawer_slide_id, $quantity = 1, $delivery_option = '', $delivery_charge = 0)
{
App::import("Model", "Inventory.Cabinet");
App::uses("Material", "Inventory.Model");
App::uses("Door", "Inventory.Model");
App::uses("Color", "Inventory.Model");
App::import("Model", "Inventory.Item");
App::import("Model", "Inventory.CabinetsItem");
App::import("Model", "Inventory.InventoryLookup");
$cabinet_id = Sanitize::escape($cabinet_id);
$material_id = Sanitize::escape($material_id);
$door_id = Sanitize::escape($door_id);
$door_color = Sanitize::escape($door_color);
$cabinet_color = Sanitize::escape($cabinet_color);
$drawer_id = Sanitize::escape($drawer_id);
$drawer_slide_id = Sanitize::escape($drawer_slide_id);
$debug_calculation = '';
$cabinets_items_model = new CabinetsItem();
$cabinets_items_model->recursive = 1;
$cabinets_items = $cabinets_items_model->find('all', array('conditions' => array('cabinet_id' => $cabinet_id, 'accessories' => '0')));
$cabinets_accessories = $cabinets_items_model->find('all', array('conditions' => array('cabinet_id' => $cabinet_id, 'accessories' => '1')));
if (!empty($cabinet_id)) {
$cabinet = new Cabinet();
$cabinet_detail = $cabinet->find('first', array('conditions' => array('id' => $cabinet_id)));
}
// predefined values
$debug_calculation .= "Blum Up Charge = {$this->bulm_up_charge} <br />";
$debug_calculation .= "Default Markup Factor = {$this->default_markup} <br />";
$debug_calculation .= "<br />";
// calculate cabinet sqft
$item_model = new Item();
$cabinet_sqft = $this->calculateCabinetSQFTForBuilder($cabinets_items, $item_model, $material_id);
$debug_calculation .= "Cabinet SQFT = {$cabinet_sqft} <br />";
$debug_calculation .= "<br />";
// calculate cabinet sqft
$panel_sqft = $this->calculatePanelSQFTForBuilder($cabinets_items);
$debug_calculation .= "Panel SQFT = {$panel_sqft} <br />";
$debug_calculation .= "<br />";
// calculate cabinet sqft
$box_total = $this->calculateBoxTotalForBuilder($cabinets_items, $door_id, $drawer_id, $drawer_slide_id);
$debug_calculation .= "<b>Box Total Price = {$box_total} </b><br />";
$debug_calculation .= "<br />";
// get door color price
$door_color_price = 0;
$door_color_detail = array();
if (!empty($door_color)) {
$color = new Color();
$door_color_detail = $color->find('first', array('conditions' => array('id' => $door_color)));
if (isset($door_color_detail['ColorSection']) && !empty($door_color_detail['ColorSection']) && is_array($door_color_detail['ColorSection'])) {
foreach ($door_color_detail['ColorSection'] as $color_section) {
if ($color_section['type'] == 'door_material') {
$door_color_price = $color_section['price'];
break;
}
}
}
unset($door_color_detail);
// clean up
unset($color);
// clean up
}
// get cabinet color price
$cabinet_color_price = 0;
$cabinet_price_color = 0;
$panel_price_color = 0;
$cabinet_color_detail = array();
if (!empty($cabinet_color)) {
$color = new Color();
$cabinet_color_detail = $color->find('first', array('conditions' => array('id' => $cabinet_color)));
if (isset($cabinet_color_detail['ColorSection']) && !empty($cabinet_color_detail['ColorSection']) && is_array($cabinet_color_detail['ColorSection'])) {
foreach ($cabinet_color_detail['ColorSection'] as $color_section) {
// if ($color_section['type'] == 'cabinet_material') {
if ($color_section['type'] == 'cabinate_material') {
$cabinet_color_price = $color_section['price'];
$cabinet_price_color = $cabinet_color_price * $cabinet_sqft;
$debug_calculation .= "Cabinet Color Price = {$cabinet_color_price} <br />";
$debug_calculation .= "<b>Cabinet Price (Color) = {$cabinet_price_color} </b><br />";
$panel_price_color = $cabinet_color_price * $panel_sqft;
$debug_calculation .= "<b>Panel Price (Color) = {$panel_price_color} </b><br />";
$debug_calculation .= "<br />";
break;
}
}
}
unset($cabinet_color_detail);
// clean up
unset($color);
// clean up
}
$doors_drawers_price = 0;
if (!empty($door_id)) {
$door = new Door();
$door_detail = $door->find('first', array('conditions' => array('Door.id' => $door_id)));
$door_cost_markup = $door_detail['Door']['cost_markup_factor'];
$door_drawers = array();
$debug_calculation .= "Door/Drawer Cost Markup = {$door_cost_markup} <br />";
$debug_calculation .= "<br />";
$door_drawers['top_door'] = array('sqft' => 0, 'price' => 0);
if (!empty($cabinet_detail['Cabinet']['top_door_count'])) {
$height = (double) $cabinet_detail['Cabinet']['top_door_height'];
//.........这里部分代码省略.........