public function init() { $transaction_types = new Model_TransactionTypes(); $result = $transaction_types->getAdjusmentTypes(); foreach ($result as $trans) { $this->_list["adjustment_type"][''] = 'Select'; $this->_list["adjustment_type"][$trans['pkId']] = $trans['transactionTypeName']; } //Generate Item Combo $item_pack_size = new Model_ItemPackSizes(); $result = $item_pack_size->getItemsAll(); $this->_childlist["item_id"][''] = "Select"; if ($result) { $item_id = $result[0]->getPkId(); foreach ($result as $row) { $this->_childlist["item_id"][$row->getPkId()] = $row->getItemName(); } } //Generate Purpose(activity_id) combo $stk_activities = new Model_StakeholderActivities(); $result4 = $stk_activities->getAllStakeholderActivitiesIssues(); if ($result4) { $stakeholder_id = $result4[0]['pkId']; foreach ($result4 as $stk_activity) { $this->_list["stakeholder_activity_id"][$stk_activity['pkId']] = $stk_activity['activity']; } } foreach ($this->_fields as $col => $name) { switch ($col) { case "adjustment_date": $this->addElement("text", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array(), "value" => date("d/m/Y"))); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); break; case "ref_no": case "transaction_reference": case "comments": $this->addElement("text", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array())); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); break; case "reference_number": case "description": $this->addElement("text", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array())); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); break; case "transaction_date": $this->addElement("text", $col, array("attribs" => array("class" => "form-control", 'readonly' => 'true'), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array())); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); break; default: break; } if (in_array($col, array_keys($this->_list))) { $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => true, "required" => false, "registerInArrayValidator" => false, "multiOptions" => $this->_list[$col], "validators" => array(array("validator" => "Float", "breakChainOnFailure" => false, "options" => array("messages" => array("notFloat" => $name . " must be a valid option")))))); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); } } }
public function init() { $transaction_types = new Model_TransactionTypes(); $result = $transaction_types->getAdjusmentTypes(); foreach ($result as $trans) { $this->_list["adjustment_type"][''] = 'Select'; $this->_list["adjustment_type"][$trans['pkId']] = $trans['transactionTypeName']; } $item_pack_sizes = new Model_ItemPackSizes(); $result1 = $item_pack_sizes->getAllManageItems(); $this->_list["product"][''] = 'Select'; if ($result1 && count($result1) > 0) { foreach ($result1 as $whs) { $this->_list["product"][$whs['pkId']] = $whs['itemName']; } } $this->_list["vvm_stage"][""] = "NA"; $this->_list["old_vvm"][""] = "NA"; foreach ($this->_hidden as $col => $name) { switch ($col) { case "item_unit_id": $this->addElement("hidden", $col); break; default: break; } } foreach ($this->_fields as $col => $name) { switch ($col) { case "adjustment_date": $this->addElement("text", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array(), "value" => date("d/m/Y"))); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); break; default: break; case "available": case "quantity": case "ref_no": case "transaction_reference": case "comments": $this->addElement("text", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array())); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); break; default: break; } if (in_array($col, array_keys($this->_list))) { $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => true, "required" => false, "registerInArrayValidator" => false, "multiOptions" => $this->_list[$col])); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); } } }
public function ajaxUpdatePhysicalCurrentQuantityAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(TRUE); $wh_id = $this->_identity->getWarehouseId(); $data = explode("|", substr($this->_request->data, 0, -1)); $count = count($data); $physical_quantity = 0; $current_quantity = 0; $em = Zend_Registry::get('doctrine'); $em->getConnection()->beginTransaction(); try { for ($i = 0; $i < $count; $i++) { $flag = 0; $placement_physical_summary = $this->_em->getRepository("PhysicalStockTakingDetail")->find($data[$i]); if ($placement_physical_summary->getStockBatch() != "") { //$physical_quantity = $placement_physical_summary->getQuantity(); $current_quantity = $placement_physical_summary->getStockBatch()->getQuantity(); $batch_id = $placement_physical_summary->getStockBatch()->getPkId(); $stk_master = new Model_StockMaster(); $physical_quantity = $stk_master->getPhysicalBatchQuantity($batch_id); /* $already_exists = $this->_em->getRepository("PhysicalStockTakingDetail")->findBy(array("stockBatch" => $batch_id, "warehouse" => $this->_identity->getWarehouseId())); if (count($already_exists) > 0) { foreach ($already_exists as $physical_stk) { if ($physical_stk->getPkId() != $placement_physical_summary->getPkId()) { $physical_quantity = $physical_quantity + $physical_stk->getQuantity(); } } } */ if ($current_quantity > $physical_quantity) { $quantity = $current_quantity - $physical_quantity; $type = 13; $placement_physical_summary->setCurrentQuantity($current_quantity); $this->_em->persist($placement_physical_summary); $this->_em->flush(); } else { if ($current_quantity < $physical_quantity) { $quantity = $physical_quantity - $current_quantity; $type = 12; $placement_physical_summary->setCurrentQuantity($current_quantity); $this->_em->persist($placement_physical_summary); $this->_em->flush(); } else { if ($current_quantity == $physical_quantity) { $flag = 1; $stock_detail = null; } } } } else { $stock_batch_model = new Model_StockBatch(); $batch_number = $placement_physical_summary->getBatchNumber(); $item_pack_size_id = $placement_physical_summary->getItemPackSize()->getPkId(); //$production_date = ($placement_physical_summary->getProductionDate() != null) ? $placement_physical_summary->getProductionDate()->format("d/m/Y") : ''; $expiry_date = $placement_physical_summary->getExpiryDate()->format("d/m/Y"); $vvm_type_id = 2; //$manufacturer_id = $this->_em->getRepository("StakeholderItemPackSizes")->findBy(array('itemPackSize' => $placement_physical_summary->getItemPackSize()->getPkId())); $array = array('number' => $batch_number, 'quantity' => $placement_physical_summary->getQuantity(), 'item_id' => $item_pack_size_id, 'production_date' => '', 'expiry_date' => $expiry_date, 'unit_price' => '0', 'vvm_type_id' => $vvm_type_id, 'manufacturer_id' => $placement_physical_summary->getStakeholderItemPackSize()); $batch_id = $stock_batch_model->createBatch($array); $type = 12; $quantity = 0; $multi_batches = $this->_em->getRepository("PhysicalStockTakingDetail")->findBy(array("batchNumber" => $batch_number, "warehouse" => $this->_identity->getWarehouseId(), "physicalStockTaking" => Model_PhysicalStockTakingDetail::STOCKID)); if (count($multi_batches) > 0) { foreach ($multi_batches as $add_batch_id) { $add_batch_id->setCurrentQuantity($current_quantity); $ba_id01 = $this->_em->getRepository('StockBatch')->find($batch_id); $add_batch_id->setStockBatch($ba_id01); $this->_em->persist($add_batch_id); $this->_em->flush(); $quantity += $add_batch_id->getQuantity(); } } } if ($flag == 0) { $tranaction_type = new Model_TransactionTypes(); $type_nature = $tranaction_type->findById($type); $stock_batch_vvm = new StockBatchVvm(); $stock_batch_vvm->setQuantity($type_nature['0']['nature'] . $quantity); $stock_batch_vvm->setVvmStage($placement_physical_summary->getVvmStage()); $ba_id1 = $this->_em->getRepository('StockBatch')->find($batch_id); $stock_batch_vvm->setStockBatch($ba_id1); $this->_em->persist($stock_batch_vvm); $this->_em->flush(); $stock_batch_vvm_id = $stock_batch_vvm->getPkId(); $stock_batch_vvm_history = new StockBatchVvmHistory(); $stock_batch_vvm_ID = $this->_em->getRepository('StockBatchVvm')->find($stock_batch_vvm_id); $stock_batch_vvm_history->setStockBatchVvm($stock_batch_vvm_ID); $stock_batch_vvm_history->setQuantity($type_nature['0']['nature'] . $quantity); $stock_batch_vvm_history->setVvmStage($placement_physical_summary->getVvmStage()); $ba_id2 = $this->_em->getRepository('StockBatch')->find($batch_id); $stock_batch_vvm_history->setStockBatch($ba_id2); $this->_em->persist($stock_batch_vvm_history); $this->_em->flush(); $stock_master = new StockMaster(); $stock_master->setTransactionDate(new \DateTime(date('Y-m-d'))); $tran_type = $this->_em->getRepository('TransactionTypes')->find($type); $stock_master->setTransactionType($tran_type); $warehouse_id = $this->_em->getRepository('Warehouses')->find($wh_id); $stock_master->setFromWarehouse($warehouse_id); $stock_master->setToWarehouse($warehouse_id); $created_by = $this->_em->getRepository('Users')->find($this->_userid); $stock_master->setCreatedBy($created_by); $stock_master->setCreatedDate(new \DateTime(date("Y-m-d"))); $adjustment_date = date('d/m/Y'); $sm = new Model_StockMaster(); $trans = $sm->getTransactionNumber($type, $adjustment_date); $stock_master->setTransactionNumber($trans['trans_no']); $stock_master->setDraft(0); $stock_master->setTransactionCounter($trans['id']); $stock_master->setParentId(0); $this->_em->persist($stock_master); $this->_em->flush(); $stock_detail = new StockDetail(); $stock_detail->setStockMaster($stock_master); $b_id = $this->_em->getRepository('StockBatch')->find($batch_id); $stock_detail->setStockBatch($b_id); $stock_detail->setQuantity($type_nature[0]['nature'] . $quantity); $stock_detail->setAdjustmentType($type); $stock_detail->setVvmStage($placement_physical_summary->getVvmStage()); $stock_detail->setTemporary(0); $stock_detail->setItemUnit($placement_physical_summary->getItemPackSize()->getItemUnit()); $this->_em->persist($stock_detail); $this->_em->flush(); $stock_ID = $stock_master->getPkId(); $stock_batch = new Model_StockBatch(); $warehouse_data = new Model_WarehousesData(); $stock_batch->adjustQuantityBywarehouse($batch_id); $warehouse_data->addReport($stock_ID, $type); $placement_physical_summary->setStockMaster($stock_master); $this->_em->persist($placement_physical_summary); $this->_em->flush(); } $already_exists = $this->_em->getRepository("PhysicalStockTakingDetail")->findBy(array("stockBatch" => $batch_id, "warehouse" => $this->_identity->getWarehouseId(), "physicalStockTaking" => Model_PhysicalStockTakingDetail::STOCKID)); if (count($already_exists) > 0) { foreach ($already_exists as $physical_stk) { if ($physical_stk->getPlacementLocation() != null && $physical_stk->getQuantity() > 0) { $placement = new Placements(); $placement->setQuantity($physical_stk->getQuantity()); $placement->setPlacementLocation($physical_stk->getPlacementLocation()); $placement->setStockBatch($physical_stk->getStockBatch()); if ($stock_detail != null) { $placement->setStockDetail($stock_detail); } $type_id = $this->_em->getRepository("ListDetail")->find(114); $placement->setPlacementTransactionType($type_id); $created_by = $this->_em->getRepository("Users")->find($this->_userid); $placement->setCreatedBy($created_by); $placement->setIsPlaced(1); $placement->setCreatedDate(new \DateTime(date("Y-m-d"))); $vvm = $physical_stk->getVvmStage(); $placement->setVvmStage($vvm); $this->_em->persist($placement); $this->_em->flush(); } } } } $em->getConnection()->commit(); echo 1; } catch (Exception $e) { $em->getConnection()->rollback(); $em->close(); echo 0; } }
public function init() { $transaction_types = new Model_TransactionTypes(); $result = $transaction_types->getAdjusmentTypes(); foreach ($result as $trans) { $this->_list["adjustment_type"][''] = 'Select'; $this->_list["adjustment_type"][$trans['pkId']] = $trans['transactionTypeName']; } $item_pack_sizes = new Model_ItemPackSizes(); $result1 = $item_pack_sizes->getAllManageItems(); $this->_list["product"][''] = 'Select'; if ($result1 && count($result1) > 0) { foreach ($result1 as $whs) { $this->_list["product"][$whs['pkId']] = $whs['itemName']; } } $quarter = array(1 => '1st Quarter', 2 => '2nd Quarter', 3 => '3rd Quarter', 4 => '4th Quarter'); $this->_list["issue_period"][""] = "Select Period"; for ($y = 2015; $y <= date("Y"); $y++) { for ($q = 1; $q <= 4; $q++) { switch ($q) { case 1: $key = "01/01/{$y}-01/03/{$y}"; break; case 2: $key = "01/04/{$y}-01/06/{$y}"; break; case 3: $key = "01/07/{$y}-01/09/{$y}"; break; case 4: $key = "01/10/{$y}-01/12/{$y}"; break; } $this->_list["issue_period"][$key] = $quarter[$q] . " - " . $y; } } $this->_list["issue_period"]["custom"] = "Custom"; //Generate Products(items) Combo //$item_pack_sizes = new Model_ItemPackSizes(); //$items = $item_pack_sizes->getAllWarehouseProducts(); $this->_list["item_id"][''] = "Select"; /* if ($items && count($items) > 0) { foreach ($items as $item) { $this->_list["item_id"][$item['pk_id']] = $item['item_name']; } } */ //Generate Purpose(activity_id) combo $stk_activities = new Model_StakeholderActivities(); $result1 = $stk_activities->getAllStakeholderActivities(); foreach ($result1 as $stk_activity) { $this->_list["activity_id"][''] = "Select"; $this->_list["activity_id"][$stk_activity['pkId']] = $stk_activity['activity']; } foreach ($this->_hidden as $col => $name) { switch ($col) { case "hdn_transaction_number": case "hdn_stock_id": case "hdn_province_id": case "hdn_district_id": case "hdn_warehouse_id": case "hdn_available_quantity": case "hdn_to_warehouse_id": case "hdn_master_id": case "hdn_activity_id": case "hdn_campaign_id": case "hdn_transaction_date": $this->addElement("hidden", $col); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); break; default: break; } } foreach ($this->_fields as $col => $name) { switch ($col) { case "transaction_reference": case "quantity": case "dispatch_by": case "issue_from": case "issue_to": $this->addElement("text", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array())); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); break; case "expiry_date": case "transaction_date": case "available_quantity": case "transaction_number": case "warehouse_name": $this->addElement("text", $col, array("attribs" => array("class" => "form-control", "readonly" => "true"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array())); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); break; case "comments": $this->addElement("textarea", $col, array("attribs" => array("class" => "form-control", "rows" => "2"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array())); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); break; default: break; } if (in_array($col, array_keys($this->_list))) { $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => true, "required" => false, "registerInArrayValidator" => false, "multiOptions" => $this->_list[$col], "validators" => array())); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); } } }
public function addStockWarehouseByIssue() { if (!empty($this->form_values['wh_id'])) { $wh_id = $this->form_values['wh_id']; } else { $wh_id = $this->_identity->getWarehouseId(); } $created_by = $this->_em->getRepository('Users')->find($this->_user_id); $tranaction_type = new Model_TransactionTypes(); $arr_types = $tranaction_type->getAll(); $array_types = array(); foreach ($arr_types as $arrtype) { $array_types[$arrtype['pkId']] = $arrtype['nature']; } if (isset($this->form_values['stock_id']) && !empty($this->form_values['stock_id'])) { $stock_id = $this->form_values['stock_id']; $stock_detail = new Model_StockDetail(); $stock_detail->pkId = $stock_id; $stock_detail_result = $stock_detail->findbyStockId(); $type_id = 1; if (isset($this->form_values['remarks']) && !empty($this->form_values['remarks'])) { $remarks = $this->form_values['remarks']; } if (isset($this->form_values['issue_no']) && !empty($this->form_values['issue_no'])) { $issue_no = $this->form_values['issue_no']; } if (isset($this->form_values['count']) && !empty($this->form_values['count'])) { $count_o = $this->form_values['count']; } if (isset($this->form_values['rec_date']) && !empty($this->form_values['rec_date'])) { $rec_date = $this->form_values['rec_date']; } if (isset($this->form_values['rec_ref']) && !empty($this->form_values['rec_ref'])) { $rec_ref = $this->form_values['rec_ref']; } if (isset($this->form_values['vvmstage']) && !empty($this->form_values['vvmstage'])) { $vvmstage = $this->form_values['vvmstage']; } if (isset($this->form_values['locations']) && !empty($this->form_values['locations'])) { $locations = $this->form_values['locations']; } if (count($stock_detail_result) > 0) { $stock_master = new StockMaster(); $time_arr = explode(' ', $rec_date); $time = date('H:i:s', strtotime($time_arr[1] . $time_arr[2])); $stock_master->setTransactionDate(new \DateTime(App_Controller_Functions::dateToDbFormat($time_arr[0]) . ' ' . $time)); $tran_type = $this->_em->getRepository('TransactionTypes')->find($type_id); $stock_master->setTransactionType($tran_type); $stock_master->setTransactionReference($rec_ref); $from_warehouse_id = $this->_em->getRepository('Warehouses')->find($stock_detail_result[0]['fromWarehouse']); $stock_master->setFromWarehouse($from_warehouse_id); $warehouse_id = $this->_em->getRepository('Warehouses')->find($wh_id); $stock_master->setToWarehouse($warehouse_id); $stock_master->setCreatedBy($created_by); $stock_master->setModifiedBy($created_by); $stock_master->setCreatedDate(App_Tools_Time::now()); $stock_master->setModifiedDate(App_Tools_Time::now()); $stock_master->setComments($remarks); $trans_no = $this->getTransactionNumber(1, $rec_date); $stock_master->setTransactionNumber($trans_no['trans_no']); if (!empty($stock_detail_result[0]['stakeholderActivity'])) { $stakeholder_activity = $this->_em->getRepository('StakeholderActivities')->find($stock_detail_result[0]['stakeholderActivity']); $stock_master->setStakeholderActivity($stakeholder_activity); } $stock_master->setDraft(0); $stock_master->setTransactionCounter($trans_no['id']); $stock_master->setParentId(0); $this->_em->persist($stock_master); $this->_em->flush(); $fk_stock_ID = $stock_master->getPkId(); } } if (isset($this->form_values['stockid']) && !empty($this->form_values['stockid'])) { $stock_ids = $this->form_values['stockid']; $count_stock_ids = count($stock_ids); foreach ($stock_ids as $index => $detail_id) { $stock_detail = new Model_StockDetail(); $stock_detail->stockReceived($detail_id); $stockBatch = $stock_detail->GetBatchDetail($detail_id); $stockDetail = $stock_detail->findByDetailId($detail_id); $array_missing = $this->form_values['missing']; $quantity = ABS($stockBatch['0']['quantity']); $obj_stock_batch = new Model_StockBatch(); $product_id = $stockBatch['0']['itemPackSize']; $array = array('number' => $stockBatch['0']['number'], 'item_id' => $product_id); $batch_id1 = $obj_stock_batch->checkBatch($array); if ($batch_id1 === 0) { $stock_batch = new StockBatch(); $stock_batch->setNumber(strtoupper($stockBatch['0']['number'])); $stock_batch->setExpiryDate(new \DateTime($stockBatch[0]['expiryDate'])); $stock_batch->setUnitPrice($stockBatch['0']['unitPrice']); $stock_batch->setProductionDate(new \DateTime($stockBatch[0]['productionDate'])); if (!empty($stockBatch['0']['stakeholderItemPackSize'])) { $pack_info_id = $this->_em->getRepository('PackInfo')->findOneBy(array("stakeholderItemPackSize" => $stockBatch['0']['stakeholderItemPackSize'])); $stock_batch->setPackInfo($pack_info_id); } if (!empty($stockBatch['0']['vvmType'])) { $vvm_id = $this->_em->getRepository('VvmTypes')->find($stockBatch['0']['vvmType']); $stock_batch->setVvmType($vvm_id); } $stock_batch->setModifiedBy($created_by); $stock_batch->setModifiedDate(App_Tools_Time::now()); $stock_batch->setCreatedBy($created_by); $stock_batch->setCreatedDate(App_Tools_Time::now()); $this->_em->persist($stock_batch); $this->_em->flush(); $batch_id2 = $stock_batch->getPkId(); $stock_batch_warehouses = new StockBatchWarehouses(); $stock_batch_warehouses->setQuantity($quantity); $stock_batch_warehouses->setStatus(Model_StockBatch::STACKED); $warehouse_id = $this->_em->getRepository('Warehouses')->find($wh_id); $stock_batch_warehouses->setWarehouse($warehouse_id); $stock_batch_id = $this->_em->getRepository('StockBatch')->find($batch_id2); $stock_batch_warehouses->setStockBatch($stock_batch_id); $stock_batch_warehouses->setModifiedBy($created_by); $stock_batch_warehouses->setModifiedDate(App_Tools_Time::now()); $stock_batch_warehouses->setCreatedBy($created_by); $stock_batch_warehouses->setCreatedDate(App_Tools_Time::now()); $this->_em->persist($stock_batch_warehouses); $this->_em->flush(); $batch_id1 = $stock_batch_warehouses->getPkId(); } $stock_detail = new StockDetail(); $sm_id = $this->_em->getRepository('StockMaster')->find($fk_stock_ID); $stock_detail->setStockMaster($sm_id); $sb_id = $this->_em->getRepository('StockBatchWarehouses')->find($batch_id1); $stock_detail->setStockBatchWarehouse($sb_id); $iu_id = $this->_em->getRepository('ItemUnits')->find($stockDetail['0']['itemUnit']); $stock_detail->setItemUnit($iu_id); $stock_detail->setQuantity($array_types[$type_id] . $quantity); $stock_detail->setTemporary(0); $vvms = $this->_em->getRepository("VvmStages")->find($vvmstage[$index]); $stock_detail->setVvmStage($vvms); $stock_detail->setIsReceived($detail_id); $stock_detail->setAdjustmentType($type_id); $stock_detail->setModifiedBy($created_by); $stock_detail->setModifiedDate(App_Tools_Time::now()); $stock_detail->setCreatedBy($created_by); $stock_detail->setCreatedDate(App_Tools_Time::now()); $this->_em->persist($stock_detail); $this->_em->flush(); $adj_stock_detail_id = $stock_detail->getPkId(); if (!empty($locations[$index])) { $placement = new Model_Placements(); $placement->form_values = array('vvmstage' => $vvmstage[$index], 'is_placed' => 1, 'quantity' => $array_types[$type_id] . $quantity, 'placement_loc_type_id' => 114, 'placement_loc_id' => $locations[$index], 'batch_id' => $batch_id1, 'detail_id' => $stock_detail->getPkId(), 'user_id' => $this->_user_id, 'created_date' => date("Y-m-d")); $placement->add(); } if (isset($array_missing[$index]) && !empty($array_missing[$index])) { $type = $this->form_values['types']; $stock_detail = new Model_StockDetail(); $stockDetail = $stock_detail->findByDetailId($detail_id); if (count($stockDetail) > 0) { $stock_master = new StockMaster(); $stock_master->setTransactionDate(new \DateTime(App_Controller_Functions::dateToDbFormat($rec_date))); $tran_type1 = $this->_em->getRepository('TransactionTypes')->find($type[$index]); $stock_master->setTransactionType($tran_type1); //$type_id; $stock_master->setTransactionReference($rec_ref); $warehouse_id = $this->_em->getRepository('Warehouses')->find($wh_id); $stock_master->setFromWarehouse($warehouse_id); $stock_master->setToWarehouse($warehouse_id); $stock_master->setCreatedBy($created_by); $stock_master->setModifiedBy($created_by); $stock_master->setCreatedDate(App_Tools_Time::now()); $stock_master->setModifiedDate(App_Tools_Time::now()); $stock_master->setComments($remarks); $trans_no = $this->getTransactionNumber($type[$index], $rec_date); $stock_master->setTransactionNumber($trans_no['trans_no']); $stock_master->setDraft(0); $stock_master->setTransactionCounter($trans_no['id']); $stock_master->setParentId($fk_stock_ID); $this->_em->persist($stock_master); $this->_em->flush(); $stock_id = $stock_master->getPkId(); } $stock_detail_a = new StockDetail(); $s_id = $this->_em->getRepository('StockMaster')->find($stock_id); $stock_detail_a->setStockMaster($s_id); $sb_id = $this->_em->getRepository('StockBatchWarehouses')->find($batch_id1); $stock_detail_a->setStockBatchWarehouse($sb_id); $iu_id = $this->_em->getRepository('ItemUnits')->find($stockDetail['0']['itemUnit']); $stock_detail_a->setItemUnit($iu_id); $stock_detail_a->setQuantity($array_types[$type[$index]] . $array_missing[$index]); $stock_detail_a->setAdjustmentType($type[$index]); $stock_detail_a->setTemporary(0); $stock_detail_a->setIsReceived($adj_stock_detail_id); $vvms = $this->_em->getRepository("VvmStages")->find($vvmstage[$index]); $stock_detail_a->setVvmStage($vvms); $stock_detail_a->setCreatedBy($created_by); $stock_detail_a->setModifiedBy($created_by); $stock_detail_a->setCreatedDate(App_Tools_Time::now()); $stock_detail_a->setModifiedDate(App_Tools_Time::now()); $this->_em->persist($stock_detail_a); $this->_em->flush(); if (!empty($locations[$index])) { $placement2 = new Model_Placements(); $placement2->form_values = array('vvmstage' => $vvmstage[$index], 'is_placed' => 0, 'quantity' => $array_types[$type[$index]] . $array_missing[$index], 'placement_loc_type_id' => 115, 'placement_loc_id' => $locations[$index], 'batch_id' => $batch_id1, 'detail_id' => $stock_detail_a->getPkId(), 'user_id' => $this->_user_id, 'created_date' => date("Y-m-d")); $placement2->add(); } } $obj_stock_batch->adjustQuantityByWarehouse($batch_id1); $obj_stock_batch->autoRunningLEFOBatch($product_id); } } $warehouse_data = new Model_HfDataMaster(); $warehouse_data->addReport($stock_id, 1, 'wh'); return true; }
public function transactionTypeAction() { $form = new Form_Iadmin_TransactionTypeSearch(); $form_add = new Form_Iadmin_TransactionTypeAdd(); $transaction_type = new Model_TransactionTypes(); if ($this->_request->isPost()) { if ($form->isValid($this->_request->getPost())) { //App_Controller_Functions::pr($this->_request->getPost()); $transaction_type_name = $form->getValue('transaction_type_name'); $nature = $form->getValue('nature'); if (!empty($transaction_type_name)) { $transaction_type->form_values['transactionTypeName'] = $transaction_type_name; } if (!empty($nature)) { $transaction_type->form_values['nature'] = $nature; } } $form->transaction_type_name->setValue($transaction_type_name); $form->nature->setValue($nature); } $sort = $this->_getParam("sort", "asc"); $order = $this->_getParam("order", "transaction_type_name"); $result = $transaction_type->getAllTransactionTypes($order, $sort); //Paginate the contest results $paginator = Zend_Paginator::factory($result); $page = $this->_getParam("page", 1); $counter = $this->_getParam("counter", 10); $paginator->setCurrentPageNumber((int) $page); $paginator->setItemCountPerPage((int) $counter); $this->view->form = $form; $this->view->form_add = $form_add; $this->view->paginator = $paginator; $this->view->sort = $sort; $this->view->order = $order; $this->view->counter = $counter; $base_url = Zend_Registry::get('baseurl'); $this->view->inlineScript()->appendFile($base_url . '/js/all_level_combos.js'); }
public function init() { $transaction_types = new Model_TransactionTypes(); $result = $transaction_types->getAdjusmentTypes(); foreach ($result as $trans) { $this->_list["adjustment_type"][''] = 'Select'; $this->_list["adjustment_type"][$trans['pkId']] = $trans['transactionTypeName']; } // This code gets all the products // $item_pack_sizes = new Model_ItemPackSizes(); // $result2 = $item_pack_sizes->getAllItems(); // Get adjusted products names $stock_master = new Model_StockMaster(); $result2 = $stock_master->getAdjustedProducts(); $this->_list["product"][''] = "All"; foreach ($result2 as $item) { $this->_list["product"][$item['pkId']] = $item['itemName']; } $date_from = date('01/m/Y'); $date_to = date('d/m/Y'); foreach ($this->_fields as $col => $name) { switch ($col) { case "adjustment_no": $this->addElement("text", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array())); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); break; case "adjustment_date": case "expiry_date": $this->addElement("text", $col, array("attribs" => array("class" => "form-control", "style" => "position: relative; z-index: 100000;"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array())); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); break; default: break; case "date_from": $this->addElement("text", $col, array("attribs" => array("class" => "form-control", "readonly" => "true", "style" => "position: relative; z-index: 100000;"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array(), "value" => $date_from)); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); break; case "date_to": $this->addElement("text", $col, array("attribs" => array("class" => "form-control", "readonly" => "true", "style" => "position: relative; z-index: 100000;"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array(), "value" => $date_to)); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); break; case "ref_no": case "transaction_reference": case "comments": $this->addElement("text", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array())); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); break; default: break; } if (in_array($col, array_keys($this->_list))) { $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => true, "required" => false, "registerInArrayValidator" => false, "multiOptions" => $this->_list[$col])); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); } } foreach ($this->_hidden as $col => $name) { switch ($col) { case "hdn_batch_no": $this->addElement("hidden", $col); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); break; default: break; } } }