/** * Contains the testing sample data for the ReceiptController. * * @return void */ public function setVariables() { // Initial sample storage data $this->input = array('commodity' => Commodity::find(1)->id, 'supplier' => Supplier::find(1)->id, 'quantity' => '200', 'batch_no' => '4535', 'expiry_date' => '2015-07-17'); // Edition sample data $this->inputUpdate = array('commodity' => Commodity::find(1)->id, 'supplier' => Supplier::find(1)->id, 'quantity' => '200', 'batch_no' => '4535', 'expiry_date' => '2015-07-17'); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $del = Supplier::find($id)->delete(); if ($del) { echo "Your Item Deleted"; } else { echo "Not Found or Already Deleted"; } }
public function postLoadSupplierProducts() { if (Request::ajax()) { $post = Input::all(); $supplier = Supplier::find($post['suppliersId']); if (!is_null($supplier)) { $products = $supplier->products()->orderBy('name')->get(); return View::make('products.select')->with('products', $products)->render(); } else { return Form::select('product', array('' => ' - Seleccione - '), null, array('class' => 'form-control', 'id' => 'product')); } } }
public function SupplierAndItemInfo() { App::uses("Supplier", "Inventory.Model"); App::import("Model", "Inventory.Item"); $supplierModel = new Supplier(); $itemModel = new Item(); $supplierModel->recursive = 0; $suppliers = $supplierModel->find("all"); $tmp_suplliers = array(); foreach ($suppliers as $key => $supplier) { $tmp_suplliers[$supplier['Supplier']['id']]['name'] = $supplier['Supplier']['name']; $tmp_suplliers[$supplier['Supplier']['id']]['email'] = $supplier['Supplier']['email']; $tmp_suplliers[$supplier['Supplier']['id']]['gst'] = $supplier['Supplier']['gst_rate']; $tmp_suplliers[$supplier['Supplier']['id']]['pst'] = $supplier['Supplier']['pst_rate']; $tmp_suplliers[$supplier['Supplier']['id']]['item'] = $itemModel->find("list", array("fields" => array("id_plus_item"), 'conditions' => array('supplier_id' => $supplier['Supplier']['id']))); $tmp_suplliers[$supplier['Supplier']['id']]['address'] = $this->address_format($supplier['Supplier']['address'], $supplier['Supplier']['city'], $supplier['Supplier']['province'], $supplier['Supplier']['country'], $supplier['Supplier']['postal_code']); $tmp_suplliers[$supplier['Supplier']['id']]['phone'] = $this->phone_format($supplier['Supplier']['phone'], $supplier['Supplier']['phone_ext'], $supplier['Supplier']['cell'], $supplier['Supplier']['fax_number']); } return $tmp_suplliers; }
private function setSupplierData() { if (isset($this->phkRequestData['supplier_id']) && !isset($this->phkRequestData['supplier_text'])) { App::import("Model", "Supplier"); $supplier = new Supplier(); $result = $supplier->find("first", array('conditions' => array('Supplier.id' => $this->phkRequestData['supplier_id']))); if (count($result)) { $this->phkRequestData['supplier_id'] = $result['Supplier']['id']; $this->phkRequestData['supplier_text'] = $result['Supplier']['name']; } } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function delete($id) { //Soft delete the item $supplier = Supplier::find($id); if (count($supplier->stocks) > 0) { return Redirect::route('supplier.index')->with('message', trans('messages.failure-delete-record')); } else { $supplier->delete(); // redirect return Redirect::route('supplier.index')->with('message', trans('messages.record-successfully-deleted')); } }
/** * Remove the specified resource from storage. * DELETE /supplier/{id} * * @param int $id * @return Response */ public function destroy($id) { $barang = Supplier::find($id); $barang->delete(); // redirect Session::flash('message', 'Successfully deleted supplier!'); return Redirect::to('supplier'); // }
public function quote_approved($id = null) { $this->autoRender = FALSE; App::import('Model', 'QuoteManager.QuoteStatus'); $QuoteStatus = new QuoteStatus(); App::import('Model', 'QuoteManager.Quote'); $Quote = new Quote(); $Q_model = new Quote(); $quote['Quote']['id'] = $id; $quote['Quote']['status'] = 'Approve'; $Q_data = $Q_model->find("first", array("conditions" => array("Quote.id" => $id))); if (empty($Q_data['Quote']['est_shipping'])) { if ($Q_data['Quote']['delivery'] == '4 - 8 Weeks Delivery') { $add_days = 56; $today = $Q_data['Quote']['quote_created_date']; $esd_date = date('d/m/Y', strtotime($today) + 24 * 3600 * $add_days); } if ($Q_data['Quote']['delivery'] == '5 - 10 Weeks Delivery') { $add_days = 70; $today = $Q_data['Quote']['quote_created_date']; $esd_date = date('d/m/Y', strtotime($today) + 24 * 3600 * $add_days); } $quote['Quote']['est_shipping'] = $esd_date; } $Quote->save($quote); $quote_status['QuoteStatus']['status'] = 'Approve'; $quote_status['QuoteStatus']['quote_id'] = $id; $quote_info = $Quote->find("first", array("conditions" => array("Quote.id" => $id))); $workorder['WorkOrder']['quote_id'] = $quote_info['Quote']['id']; $workorder['WorkOrder']['project_id'] = $quote_info['Quote']['project_id']; $workorder['WorkOrder']['customer_id'] = $quote_info['Quote']['customer_id']; $workorder['WorkOrder']['status'] = 'New'; $quote_number_explode = explode("-", $quote_info['Quote']['quote_number']); $workorder['WorkOrder']['work_order_number'] = $quote_number_explode[0]; $workorder['WorkOrder']['skid_number'] = $quote_info['Quote']['skid_number']; $workorder['WorkOrder']['skid_weight'] = $quote_info['Quote']['skid_weight']; App::import("Model", "WorkOrderManager.WorkOrder"); $wo = new WorkOrder(); $wo->save($workorder); App::import("Model", "PurchaseOrderManager.PurchaseOrder"); App::import("Model", "PurchaseOrderManager.PurchaseOrderItem"); App::import("Model", "Inventory.Supplier"); App::import('Model', 'PurchaseOrderManager.GeneralSetting'); $supplier = array(); foreach ($quote_info['CabinetOrderItem'] as $quote_item) { $item_info = $this->findQuoteItem($quote_item['item_id']); $supplier_required = $this->findQuoteItemDept($item_info['Item']['item_department_id']); if ($supplier_required['ItemDepartment']['supplier_required'] == 1) { $supplier[$item_info['Item']['supplier_id']][] = $item_info; } } $total_amount = 0; foreach ($supplier as $key => $value) { if (empty($Q_data['Quote']['est_shipping'])) { $est_date_quote = $quote['Quote']['est_shipping']; } else { $est_date_quote = $quote_info['Quote']['est_shipping']; } $purchaseorder = new PurchaseOrder(); $sp_model = new Supplier(); $sp_data = $sp_model->find("first", array("conditions" => array("Supplier.id" => $id))); $general_model = new GeneralSetting(); $location_data = $general_model->find("first", array("conditions" => array("GeneralSetting.name" => 'Default'))); $po['supplier_id'] = $key; $po['work_order_id'] = $wo->id; $po_number = explode("-", $quote_info['Quote']['quote_number']); $po['purchase_order_num'] = $po_number[0]; $po['quote_id'] = $quote_info['Quote']['id']; $po['shipment_date'] = $est_date_quote; $po['payment_type'] = 'On Account'; $po['issued_on'] = date('d/m/Y'); $po['issued_by'] = $this->loginUser['id']; $po['term'] = $sp_data['Supplier']['terms']; $po['location_name'] = $location_data['GeneralSetting']['name']; $po['name_ship_to'] = $location_data['GeneralSetting']['name_address']; $po['address'] = $location_data['GeneralSetting']['address']; $po['city'] = $location_data['GeneralSetting']['city']; $po['province'] = $location_data['GeneralSetting']['province']; $po['postal_code'] = $location_data['GeneralSetting']['postal_code']; $po['country'] = $location_data['GeneralSetting']['country']; foreach ($value as $v) { foreach ($quote_info['CabinetOrderItem'] as $req_info) { if ($req_info['item_id'] == $v['Item']['id']) { $quantity = $req_info['quantity']; $total_amount = $total_amount + $quantity * $v['Item']['price']; } } } App::import("Model", "PurchaseOrderManager.GeneralSetting"); $g_setting = new GeneralSetting(); $gst_rate = $g_setting->find("first", array("conditions" => array("GeneralSetting.type" => 'gst'))); $pst_rate = $g_setting->find("first", array("conditions" => array("GeneralSetting.type" => 'pst'))); $gst_amount = $gst_rate['GeneralSetting']['value'] / 100 * $total_amount; $pst_amount = $pst_rate['GeneralSetting']['value'] / 100 * $total_amount; $total_amount = $total_amount + $gst_amount + $pst_amount; $po['total_amount'] = $total_amount; $purchaseorder->save($po); $index = 0; $purchaseorderitem = new PurchaseOrderItem(); foreach ($value as $v) { foreach ($quote_info['CabinetOrderItem'] as $req_info) { if ($req_info['item_id'] == $v['Item']['id']) { $po_item[$index]['quantity'] = $req_info['quantity']; $po_item[$index]['code'] = $req_info['code']; $po_item[$index]['cabinet_id'] = $req_info['cabinet_id']; $po_item[$index]['door_id'] = $req_info['door_id']; } } $po_item[$index]['item_id'] = $v['Item']['id']; $po_item[$index]['purchase_order_id'] = $purchaseorder->id; $index++; } $purchaseorderitem->saveAll($po_item); } // foreach($quote_info['CabinetOrderItem'] as $quote_item){ // $purchaseorder = new PurchaseOrder(); // $item_info = $this->findQuoteItem($quote_item['item_id']); // $supplier_required = $this->findQuoteItemDept($item_info['Item']['item_department_id']); // if(!empty($supplier_required['ItemDepartment']['supplier_required'])){ // $supplier[$item_info['Item']['supplier_id']][] = $item_info; // $po['supplier_id'] = $item_info['Item']['supplier_id']; // $po['work_order_id'] = $wo->id; // $po['purchase_order_num'] = $quote_info['Quote']['quote_number']; // $po['quote_id'] = $quote_info['Quote']['id']; // $po['shipment_date'] = date("Y-m-d"); // $po['expiry_date'] = date("Y-m-d"); // $po['cc_num'] = 'Test CC Number'; // $po['name_cc'] = 'Test CC Name'; // $po['payment_type'] = 'On Account'; // //$purchaseorder->save($po); // // $index = 0; // foreach($quote_info['CabinetOrderItem'] as $qitem){ // $purchaseorderitem = new PurchaseOrderItem(); // $item_info = $this->findQuoteItem($qitem['item_id']); // $supplier_required = $this->findQuoteItemDept($item_info['Item']['item_department_id']); // if(!empty($supplier_required['ItemDepartment']['supplier_required'])){ // $po_item[$index]['item_id'] = $item_info['Item']['id']; // $po_item[$index]['code'] = $item_info['Item']['id']."|item"; // $po_item[$index]['purchase_order_id'] = $purchaseorder->id; // $index++; // } // } // //$purchaseorderitem->saveAll($po_item); // } // }exit; //exit; if ($QuoteStatus->save($quote_status)) { $this->redirect("http://{$_SERVER['SERVER_NAME']}{$this->webroot}work_order_manager/work_orders/detail/{$wo->id}"); } }
function SupplierForView($id = null) { App::uses("Supplier", "Inventory.Model"); $supplier = new Supplier(); return $supplier->find("first", array("fields" => array("id", "name"), "conditions" => array("Supplier.id" => $id))); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function delete($id) { //Soft delete the item $supplier = Supplier::find($id); $supplier->delete(); // redirect return Redirect::route('supplier.index')->with('message', trans('messages.supplier-succesfully-deleted')); }
public function delete_supp() { $getID = Input::get('deleteID'); $supp = Supplier::find($getID); $supp->actStatus = '0'; $supp->save(); return Redirect::to('/suppliers'); }
public function postDeletesupplier() { $s = Supplier::find(Input::get('id')); if ($s) { $s->delete(); return Redirect::to('admin/uploadsuppliers')->with('message', 'Supplier Deleted'); } return Redirect::to('admin/uploadsuppliers')->with('message', 'Could not Delete'); }
public function getSupplierData($id = null) { $this->autoRender = false; App::import('Model', 'Inventory.Supplier'); $supplier_model = new Supplier(); $supplier_data = $supplier_model->find("first", array("conditions" => array("Supplier.id" => $id))); echo json_encode($supplier_data); }
/** * postPackageCheckedin (拆包检验入库) */ public function postPackageCheckedin() { $id = Input::get('id'); $position = Input::get('readyposition'); $itemReceivedPackageDetail = ItemReceivedPackageDetail::find($id); $itemReceivedPackageDetail->status = 2; $itemReceivedPackageDetail->readyposition = $position; $itemReceivedPackageDetail->save(); //历史入库记录 $historyWareHouse = new HistoryWarehouse(); $historyWareHouse->identity = $itemReceivedPackageDetail->identity; $historyWareHouse->item = $itemReceivedPackageDetail->item; $historyWareHouse->batch = $itemReceivedPackageDetail->batch; $historyWareHouse->quantity = $itemReceivedPackageDetail->quantity; $historyWareHouse->position = $position; $historyWareHouse->operator = 5; $historyWareHouse->save(); //库存汇总 $wareHouse = Warehouse::where('item', $itemReceivedPackageDetail->item)->where('position', $position)->first(); if ($wareHouse) { $wareHouse->quantity = $wareHouse->quantity + $itemReceivedPackageDetail->quantity; $wareHouse->save(); } else { $wareHouse = new Warehouse(); $wareHouse->item = $itemReceivedPackageDetail->item; $wareHouse->position = $position; $wareHouse->quantity = $itemReceivedPackageDetail->quantity; $wareHouse->save(); } //更新item总库存 $items = Item::where('code', $itemReceivedPackageDetail->item)->first(); $items->stock += $itemReceivedPackageDetail->quantity; $items->readystock -= $itemReceivedPackageDetail->quantity; $items->save(); //到包日期|包号 $itemReceivedPackage = ItemReceivedPackage::find($itemReceivedPackageDetail->package_id); $package_checked_date = $itemReceivedPackage->package_checked_date; $package_no = $itemReceivedPackage->package_no; //供应商 $supplier = Supplier::find($itemReceivedPackageDetail->supplier_id); //details $itemReceivedPackageDetails = ItemReceivedPackageDetail::where('package_id', $itemReceivedPackageDetail->package_id)->orderBy('status')->get(); return View::make('admin.itemreceive.packagedetail')->with('itemReceivedPackageDetails', $itemReceivedPackageDetails)->with('supplier', $supplier)->with('package_checked_date', $package_checked_date)->with('package_no', $package_no); }
/** * Show the form for editing the specified supplier. * * @param int $id * @return Response */ public function edit($id) { $supplier = Supplier::find($id); return View::make('admin.suppliers.edit', compact('supplier')); }
function getItem() { set_time_limit(0); $this->autoRender = false; $sql = "SELECT * FROM `inventory`\n\t\tWHERE\n\t\t\t`Description` NOT LIKE '%:V'\n\t\t\tAND `Description` NOT LIKE '%:M'\n\t\t\tAND `Description` NOT LIKE '%:P'\n\t\t\tAND `Description` NOT LIKE '%-V'\n\t\t\tAND `Description` NOT LIKE '%-M'\n\t\t\tAND `Description` NOT LIKE '%-P'\n\t\t\tAND `Department` NOT IN ( 'Stain', 'Sheet Stk', 'Sheet Goods' );"; $datas = $this->Cabinet->query($sql); App::uses("Item", "Inventory.Model"); App::uses("Supplier", "Inventory.Model"); $supplier_model = new Supplier(); App::uses("Material", "Inventory.Model"); $Material_model = new Material(); App::uses("ItemDepartment", "Inventory.Model"); $ItemDepartment_model = new ItemDepartment(); foreach ($datas as $data) { $Item = new Item(); $item_data = array(); $item_data['Item']['item_title'] = $data['inventory']['Description']; $item_data['Item']['number'] = $data['inventory']['Number']; $item_data['Item']['old_number'] = $data['inventory']['Number']; $item_data['Item']['description'] = $data['inventory']['Reference']; $item_data['Item']['width'] = !empty($data['inventory']['Width']) ? $data['inventory']['Width'] : 0; $item_data['Item']['length'] = !empty($data['inventory']['Length']) ? $data['inventory']['Length'] : 0; $item_data['Item']['minimum'] = $data['inventory']['Minimum']; $item_data['Item']['maximum'] = $data['inventory']['Maximum']; $item_data['Item']['location'] = $data['inventory']['Location']; $supplier_id = $supplier_model->find('first', array('fields' => array('id'), 'conditions' => array('Supplier.name' => $data['inventory']['Supplier']), 'recursive' => -1)); $item_data['Item']['supplier_id'] = $supplier_id['Supplier']['id']; $item_data['Item']['created'] = $data['inventory']['Created']; $item_data['Item']['modified'] = $data['inventory']['Modified']; $item_data['Item']['item_cost'] = $data['inventory']['Cost']; $item_data['Item']['PGM_Biesse'] = $data['inventory']['PGM_Biesse']; $item_data['Item']['PGM_Morbi'] = $data['inventory']['PGM_Morbi']; $item_data['Item']['PGM_Edgeband'] = $data['inventory']['PGM_Edgeband']; $item_data['Item']['material'] = "Standard"; $item_data['Item']['item_material'] = 2; $item_data['Item']['item_material_group'] = 3; $item_data['Item']['variable_cost'] = $data['inventory']['Variablecost']; $item_data['Item']['main_item'] = $data['inventory']['Mainitem']; $item_data['Item']['base_item'] = 0; $item_data['Item']['Department'] = $data['inventory']['Department']; $department_id = $ItemDepartment_model->find('first', array('fields' => array('id', "name"), 'conditions' => array('ItemDepartment.name' => $data['inventory']['Department']), 'recursive' => -1)); $item_data['Item']['item_department_id'] = $department_id['ItemDepartment']['id']; $item_data['Item']['price'] = $data['inventory']['Price']; $item_data['Item']['factor'] = $data['inventory']['Factor']; $item_data['Item']['image'] = $data['inventory']['Image']; $item_data['Item']['current_stock'] = !empty($data['inventory']['Onhand']) ? $data['inventory']['Onhand'] : 0; $item_data['Item']['item_group'] = 1; if (!$Item->save($item_data)) { pr($Item->validationErrors); } //------------VENEER------------------------ $Item_Veneer = new Item(); $veneer = array(); $veneer['Item']['base_item'] = $Item->id; $veneer['Item']['material'] = "Maple"; $veneer['Item']['item_material'] = 1; $veneer['Item']['item_material_group'] = 1; $veneer['Item']['description'] = $data['inventory']['Reference']; $veneer['Item']['width'] = !empty($data['inventory']['Width']) ? $data['inventory']['Width'] : 0; $veneer['Item']['length'] = !empty($data['inventory']['Length']) ? $data['inventory']['Length'] : 0; $veneer['Item']['Department'] = $data['inventory']['Department']; $veneer['Item']['item_department_id'] = $department_id['ItemDepartment']['id']; $veneer['Item']['item_group'] = 1; $veneer['Item']['item_title'] = $data['inventory']['Description']; $veneer['Item']['item_cost'] = $data['inventory']['Cost']; $veneer['Item']['price'] = $data['inventory']['Price']; $veneer['Item']['factor'] = $data['inventory']['Factor']; $veneer['Item']['supplier_id'] = $supplier_id['Supplier']['id']; if (!$Item_Veneer->save($veneer)) { pr($Item_Veneer->validationErrors); } //------------MDF------------------------ $Item_MDF = new Item(); $mdf = array(); $mdf['Item']['base_item'] = $Item->id; $mdf['Item']['material'] = $data['inventory']['Reference']; $mdf['Item']['item_material'] = 145; $mdf['Item']['item_material_group'] = 2; $mdf['Item']['description'] = 'ADJS'; $mdf['Item']['width'] = !empty($data['inventory']['Width']) ? $data['inventory']['Width'] : 0; $mdf['Item']['length'] = !empty($data['inventory']['Length']) ? $data['inventory']['Length'] : 0; $mdf['Item']['Department'] = $data['inventory']['Department']; $mdf['Item']['item_department_id'] = $department_id['ItemDepartment']['id']; $mdf['Item']['item_group'] = 1; $mdf['Item']['item_title'] = $data['inventory']['Description']; $mdf['Item']['item_cost'] = $data['inventory']['Cost']; $mdf['Item']['price'] = $data['inventory']['Price']; $mdf['Item']['factor'] = $data['inventory']['Factor']; $mdf['Item']['supplier_id'] = $supplier_id['Supplier']['id']; if (!$Item_MDF->save($mdf)) { pr($Item_MDF->validationErrors); } //------------Plywood------------------------ $Item_plywood = new Item(); $plywood = array(); $plywood['Item']['base_item'] = $Item->id; $plywood['Item']['material'] = $data['inventory']['Reference']; $plywood['Item']['item_material'] = 3; $plywood['Item']['item_material_group'] = 4; $plywood['Item']['description'] = 'ADJS'; $plywood['Item']['width'] = !empty($data['inventory']['Width']) ? $data['inventory']['Width'] : 0; $plywood['Item']['length'] = !empty($data['inventory']['Length']) ? $data['inventory']['Length'] : 0; $plywood['Item']['Department'] = $data['inventory']['Department']; $plywood['Item']['item_department_id'] = $department_id['ItemDepartment']['id']; $plywood['Item']['item_group'] = 1; $plywood['Item']['item_title'] = $data['inventory']['Description']; $plywood['Item']['item_cost'] = $data['inventory']['Cost']; $plywood['Item']['price'] = $data['inventory']['Price']; $plywood['Item']['factor'] = $data['inventory']['Factor']; $plywood['Item']['supplier_id'] = $supplier_id['Supplier']['id']; if (!$Item_plywood->save($plywood)) { pr($Item_plywood->validationErrors); } //------------Acrylic-19mm------------------------ $Item_Acr19 = new Item(); $Acr19 = array(); $Acr19['Item']['base_item'] = $Item->id; $Acr19['Item']['material'] = $data['inventory']['Reference']; $Acr19['Item']['item_material'] = 4; $Acr19['Item']['item_material_group'] = 5; $Acr19['Item']['description'] = 'ADJS'; $Acr19['Item']['width'] = !empty($data['inventory']['Width']) ? $data['inventory']['Width'] : 0; $Acr19['Item']['length'] = !empty($data['inventory']['Length']) ? $data['inventory']['Length'] : 0; $Acr19['Item']['Department'] = $data['inventory']['Department']; $Acr19['Item']['item_department_id'] = $department_id['ItemDepartment']['id']; $Acr19['Item']['item_group'] = 1; $Acr19['Item']['item_title'] = $data['inventory']['Description']; $Acr19['Item']['item_cost'] = $data['inventory']['Cost']; $Acr19['Item']['price'] = $data['inventory']['Price']; $Acr19['Item']['factor'] = $data['inventory']['Factor']; $Acr19['Item']['supplier_id'] = $supplier_id['Supplier']['id']; if (!$Item_Acr19->save($Acr19)) { pr($Item_Acr19->validationErrors); } //------------Acrylic-38mm------------------------ $Item_Acr38 = new Item(); $Acr38 = array(); $Acr38['Item']['base_item'] = $Item->id; $Acr38['Item']['material'] = $data['inventory']['Reference']; $Acr38['Item']['item_material'] = 148; $Acr38['Item']['item_material_group'] = 6; $Acr38['Item']['description'] = 'ADJS'; $Acr38['Item']['width'] = !empty($data['inventory']['Width']) ? $data['inventory']['Width'] : 0; $Acr38['Item']['length'] = !empty($data['inventory']['Length']) ? $data['inventory']['Length'] : 0; $Acr38['Item']['Department'] = $data['inventory']['Department']; $Acr38['Item']['item_department_id'] = $department_id['ItemDepartment']['id']; $Acr38['Item']['item_group'] = 1; $Acr38['Item']['item_title'] = $data['inventory']['Description']; $Acr38['Item']['item_cost'] = $data['inventory']['Cost']; $Acr38['Item']['price'] = $data['inventory']['Price']; $Acr38['Item']['factor'] = $data['inventory']['Factor']; $Acr38['Item']['supplier_id'] = $supplier_id['Supplier']['id']; if (!$Item_Acr38->save($Acr38)) { pr($Item_Acr38->validationErrors); } //------------HPL-19mm------------------------ $Item_HPL19 = new Item(); $HPL19 = array(); $HPL19['Item']['base_item'] = $Item->id; $HPL19['Item']['material'] = $data['inventory']['Reference']; $HPL19['Item']['item_material'] = 146; $HPL19['Item']['item_material_group'] = 7; $HPL19['Item']['description'] = 'ADJS'; $HPL19['Item']['width'] = !empty($data['inventory']['Width']) ? $data['inventory']['Width'] : 0; $HPL19['Item']['length'] = !empty($data['inventory']['Length']) ? $data['inventory']['Length'] : 0; $HPL19['Item']['Department'] = $data['inventory']['Department']; $HPL19['Item']['item_department_id'] = $department_id['ItemDepartment']['id']; $HPL19['Item']['item_group'] = 1; $HPL19['Item']['item_title'] = $data['inventory']['Description']; $HPL19['Item']['item_cost'] = $data['inventory']['Cost']; $HPL19['Item']['price'] = $data['inventory']['Price']; $HPL19['Item']['factor'] = $data['inventory']['Factor']; $HPL19['Item']['supplier_id'] = $supplier_id['Supplier']['id']; if (!$Item_HPL19->save($HPL19)) { pr($Item_HPL19->validationErrors); } //------------HPL-38mm------------------------ $Item_HPL38 = new Item(); $HPL38 = array(); $HPL38['Item']['base_item'] = $Item->id; $HPL38['Item']['material'] = $data['inventory']['Reference']; $HPL38['Item']['item_material'] = 147; $HPL38['Item']['item_material_group'] = 8; $HPL38['Item']['description'] = 'ADJS'; $HPL38['Item']['width'] = !empty($data['inventory']['Width']) ? $data['inventory']['Width'] : 0; $HPL38['Item']['length'] = !empty($data['inventory']['Length']) ? $data['inventory']['Length'] : 0; $HPL38['Item']['Department'] = $data['inventory']['Department']; $HPL38['Item']['item_department_id'] = $department_id['ItemDepartment']['id']; $HPL38['Item']['item_group'] = 1; $HPL38['Item']['item_title'] = $data['inventory']['Description']; $HPL38['Item']['item_cost'] = $data['inventory']['Cost']; $HPL38['Item']['price'] = $data['inventory']['Price']; $HPL38['Item']['factor'] = $data['inventory']['Factor']; $HPL38['Item']['supplier_id'] = $supplier_id['Supplier']['id']; if (!$Item_HPL38->save($HPL38)) { pr($Item_HPL38->validationErrors); } } }
function Supplier() { App::uses("Supplier", "Model"); $supplier = new Supplier(); return $supplier->find("list", array("fields" => array("id", "name"))); }