public function save() { $ship = Shipments::get_shipment(); $ship = new Shipments(); $ship -> vaccine_id = $this -> input -> post("combo2"); $ship -> task_id = $this -> input -> post("combo1"); $test_initiate_date=strtotime($this -> input -> post("start_date")); $ship -> Initiate_date = date('Y-m-d',$test_initiate_date); $test_start_date=strtotime($this -> input -> post("receive_date")); $ship -> receive_date = date('Y-m-d',$test_start_date); $test_end_date=strtotime($this -> input -> post("end_date")); $ship -> end_date = date('Y-m-d',$test_end_date); $ship -> Initiator_name = $this -> input -> post("name"); $ship -> save(); $this->index() ; }
public function addProcurements() { $data = $this->form_values; // App_Controller_Functions::pr($data); $shipments = new Shipments(); $shipmentHistory = new ShipmentHistory(); $shipments->setReferenceNumber($data['transaction_reference']); $item_id = $this->_em->getRepository('ItemPackSizes')->find($data['item_id']); $shipments->setItemPackSize($item_id); $shipments->setShipmentDate(new \DateTime(App_Controller_Functions::dateToDbFormat($data['shipment_date']))); $shipments->setShipmentQuantity($data['quantity']); $funding_source_id = $this->_em->getRepository('Warehouses')->find($data['from_warehouse_id']); $shipments->setFundingSource($funding_source_id); $activity_id = $this->_em->getRepository('StakeholderActivities')->find($data['activity_id']); $shipments->setStakeholderActivity($activity_id); $warhouse_id = $this->_em->getRepository('Warehouses')->find($this->_identity->getWarehouseId()); $shipments->setWarehouse($warhouse_id); $shipments->setCreatedDate(new \DateTime(date("Y-m-d"))); $created_by = $this->_em->getRepository('Users')->find($this->_user_id); $shipments->setCreatedBy($created_by); $shipments->setModifiedBy($created_by); $shipments->setModifiedDate(App_Tools_Time::now()); $this->_em->persist($shipments); $this->_em->flush(); $id = $shipments->getPkId(); $shipment_id = $this->_em->getRepository('Shipments')->find($id); $shipmentHistory->setShipment($shipment_id); $shipmentHistory->setStatus($data['status']); $shipmentHistory->setReferenceNumber($data['transaction_reference']); $shipmentHistory->setCreatedDate(new \DateTime(date("Y-m-d"))); //$created_by = $this->_em->getRepository('Users')->find($this->_user_id); $shipmentHistory->setCreatedBy($created_by); $shipmentHistory->setModifiedBy($created_by); $shipmentHistory->setModifiedDate(App_Tools_Time::now()); $this->_em->persist($shipmentHistory); $this->_em->flush(); $shipment_history_id = $shipmentHistory->getPkId(); return $shipment_history_id; }
/** * Model definition. */ function define() { // Fields. $this->fields = array('id', 'order_id', 'name', 'phone', 'address', 'city', 'state', 'zip', 'country', 'method', 'tracking', 'items', 'date_created', 'date_updated', 'items' => function ($shipment) { return get("/products", array(':with' => $shipment['items'])); }, 'order' => function ($shipment) { return get("/orders/{$shipment['order_id']}"); }, 'carrier' => function ($shipment) { return Shipments::get_carrier($shipment); }); $this->search_fields = array('name', 'address'); // Validate. $this->validate = array('required' => array('order_id', 'name', 'address', 'city', 'state', 'method', 'tracking'), ':items' => array('required' => array('id', 'quantity'))); // Event binds. $this->binds = array('GET' => function ($event, $model) { $params =& $event['data']; // Get shipping methods? if ($event['id'] == "methods") { $methods = array(); // Trigger special context event. $methods = trigger('shipments', 'methods', $methods, $params, $model); // Process default shipping methods? if (empty($methods)) { $methods = Shipments::process_default_methods($methods, $params); } // No methods exist? if (!empty($methods)) { // Order methods by price. if ($params) { $methods = orderby($methods, 'price'); } // Direct result. return array('result' => $methods); } return false; } }, 'POST' => function ($event) { $data =& $event['data']; if ($data['order_id'] && ($order = get("/orders/{$data['order_id']}"))) { // Default data from order. $data = array_merge((array) $order['shipping'], $data); $data['name'] = $data['name'] ?: $order['name']; $data['phone'] = $data['phone'] ?: $order['phone']; // Filter shipment items. $shipment_items = array(); foreach ($order['items'] as $order_item_id => $item) { // Specific items? Otherwise defaults to all order items. if (is_array($data['items'])) { $add_this_item = false; foreach ($data['items'] as $data_item) { if (is_array($data_item) && $data_item['order_item_id'] == $order_item_id) { $add_this_item = true; } } if ($add_this_item === false) { continue; } } // Bundle? if ($item['items']) { foreach ($item['items'] as $i) { $shipment_items[++$ship_item_id] = array('id' => $i['id'], 'quantity' => $i['quantity'] * $item['quantity'], 'order_item_id' => $order_item_id); } } else { $shipment_items[++$ship_item_id] = array('id' => $item['id'], 'quantity' => $item['quantity'], 'order_item_id' => $order_item_id); } } // Filtered. $data['items'] = $shipment_items; } }, 'PUT, POST' => function ($event, $model) { $data =& $event['data']; if ($data['items']) { // Clean items data if ID missing. foreach ((array) $data['items'] as $id => $item) { if (!$item['id'] || !$item['quantity']) { unset($data['items'][$id]); } } // Shipment requires at least 1 item. if (count($data['items']) == 0) { $model->error('Must contain at least one item', 'items'); } } }, 'after:POST, after:PUT' => function ($result, $event) { $data =& $event['data']; if ($result) { // Send shipment e-mail? if ($data[':email']) { $settings = get("/settings/emails/shipment"); if ($settings !== false) { $settings['shipment'] = $result; $settings['to'] = $result['order']['account']['email']; // Default subject? if ($settings['subject']) { $settings['subject'] .= ' #' . $result['order']['id']; } // Override default email? if (is_array($data[':email'])) { $settings = array_merge($settings, $data[':email']); } post("/emails/shipment", $settings); } } if ($result['order_id']) { // Set date_shipped on order? if (!$result['order']['date_shipped']) { put("/orders/{$result['order_id']}", array('date_shipped' => $result['date_created'])); } else { if ($result['is_cancelled']) { if (count($result['order']['shipments']) == 1) { put("/orders/{$result['order_id']}", array('date_shipped' => null)); } } } } } }, 'after:DELETE' => function ($result, $event) { if ($result) { // Last shipment of an order? Unset date shipped. if ($result['order']['shipments']['count'] == 0) { put("/orders/{$result['order_id']}", array('date_shipped' => null)); } } }); }
public function edit_task($id) { $tasks = Shipments::get_all($id); $data['tasks'] = $tasks; $data['title'] = "Task Management::Edit Task"; $data['module_view'] = "add_user_view"; $data['groups'] = User_Groups::getAllGroups(); $data['districts'] = Districts::getAllDistricts(); $data['regions'] = Regions::getAllRegions(); $this->base_params($data); echo $id; }
public function allowedShipmentStatuses() { $shipment_id = Input::json('id'); $usergroup = User::find(Auth::id())->usergroup()->first(); $job_id = Shipments::find($shipment_id)->Job_Id; $job = Jobs::find($job_id); $channel_id = $job->Channel_Id; $job_status_id = $job->Job_Status_Id; //select form usergroup channel rights where the channel_id and usergroup_id and ch_right $status_list = DB::select(DB::raw("SELECT jts.* FROM jobtypestatus jts\n\t\t\t\tWHERE jts.JobTypeStatus_Id = " . $job_status_id . "\n\t\t\t\t\tor jts.JobTypeStatus_Id in\n\t\t\t\t\t\t(Select jtst.To_JobTypeStatus_Id\n\t\t\t\t\t\t\tFrom jobtypestatustransitions jtst\n\t\t\t\t\t\t\twhere jtst.From_JobTypeStatus_Id= '" . $job_status_id . "')")); return Response::json(array('response' => $status_list)); }
$string.= "<text label='$initial'/>"; } $string.= "</dataColumn>"; $string.= "</dataTable>"; $range = Shipments::get_range(); foreach ($range as $ranges) { $minmonth = $ranges['date1']; $max = $ranges['date3']; } $task_id = Shipments::get_them_dates(); //$count = 0; $string.="<tasks>"; ///for ($i = $minmonth; $i <= $max; $i++) foreach ($task_id as $task_id) { //@$id = $task_id[$count]['id']; @$id = $task_id['id']; @$initialx = $task_id['Initiate_date']; @$initial2=date('d/m/Y', strtotime($initialx));; @$startx = $task_id['receive_date']; @$start=date('d/m/Y', strtotime($startx));; @$endx = $task_id['end_date']; @$end=date('d/m/Y', strtotime($endx));; $string.= "<task label='Planned' processId='$id' start='$initial2' end='$end' id='$id-1' color='4567aa' height='32%' topPadding='12%'/>"; $string.= "<task label='Actual' processId='$id' start='$start' end='$end' id='$id' color='EEEEEE' alpha='100' topPadding='56%' height='32%' />";