$result['fImage'] = '<img src="images/icon-' . $paid_image . '.png" title="' . $paid_image_title . '" />'; $result['fDate'] = $paydat == 'null' ? $paydat : date('d.m.Y', strtotime($paydat)); } ajaxReturn($result); exit; } elseif ($_POST['me_action'] == 'SETPOUNPAID') { $oid = tep_db_prepare_input($_POST['oid']); $eo = new elements_order($oid); $eo->updateStatus('3', $session_userinfo['username']); $result = array(); $result['oid'] = $oid; ajaxReturn($result); exit; } elseif ($_POST['me_action'] == 'CLOSEPO') { $oid = tep_db_prepare_input($_POST['oid']); $eo = new elements_order($oid); $eo->updateStatus('2', $session_userinfo['username']); $result = array(); $result['oid'] = $oid; ajaxReturn($result); exit; } elseif ($_POST['me_action'] == 'ADDMANLOADEID') { $eid = tep_db_prepare_input($_POST['eid']); $qtytoadd = ''; $element = new element($eid); if (is_null($element->id)) { $found = '0'; $preview = '<h3 class="red">Element Not Found</h3>'; } else { //$img = webImage($element->image, '80', '80', $eid); $img = webImageWithDetailLinkStars($element->image, '80', '80', $eid, '', '', '500', '500', $element->stars);
function runElementQuery($outsourced_flag) { global $class_ea, $ecats, $all_period; if (isset($_GET['shipwin_month'])) { $month = str_pad(tep_db_prepare_input($_GET['shipwin_month']), 2, '0', STR_PAD_LEFT); $year = date('Y'); $shipwin_start = $year . "-{$month}-01"; $eom_date = date('t', strtotime($shipwin_start)); $shipwin_end = date('Y') . "-{$month}-{$eom_date}"; $shipwin_filter = "AND joi.shipping_window_open BETWEEN '{$shipwin_start}' AND '{$shipwin_end}'"; } else { $shipwin_filter = ""; } $whid = WAREHOUSE_ID_ELEMENTS; $element_list = array(); $order_date_start = '2013-08-13'; $order_date_end = '2013-08-14'; $q = "SELECT\n e.elements_image\n , e.attribute_category_id AS ecatid\n , MONTH(joi.shipping_window_open) AS period\n , IF(IFNULL(paue.elements_id, 0)>0, paue.elements_id, pue.elements_id) AS elements_id\n , SUM(joi.order_quantity * IF(IFNULL(paue.quantity,0)>0, paue.quantity, pue.quantity)) AS elements_needed\n , etes.price_quantity_type AS unit, etes.pieces_per_qty_type AS unit_multiplier\n , es.stock\n FROM jng_sp_orders jo\n LEFT JOIN jng_sp_orders_items joi ON joi.jng_sp_orders_id=jo.jng_sp_orders_id\n LEFT JOIN products p ON p.products_id=joi.products_id\n LEFT JOIN products_use_elements pue ON pue.products_id=joi.products_id\n LEFT JOIN products_articles_use_elements paue ON paue.products_use_elements_id=pue.products_use_elements_id AND paue.products_articles_id=joi.products_articles_id\n LEFT JOIN element e ON e.elements_id=IF(IFNULL(paue.elements_id, 0)>0, paue.elements_id, pue.elements_id)\n LEFT JOIN elements_to_elements_suppliers etes ON etes.elements_id=e.elements_id AND is_default='1'\n LEFT JOIN elements_stock es ON es.jng_warehouses_id={$whid} AND es.elements_id=e.elements_id\n WHERE jo.jng_sp_id=5\n AND jo.order_date BETWEEN '{$order_date_start}' AND '{$order_date_end}'\n {$shipwin_filter}\n AND p.is_outsourced='{$outsourced_flag}'\n GROUP BY elements_id, period\n ORDER BY ecatid, elements_id, period"; $r = tep_db_query($q); $elements_total = array(); $elements_unit = array(); $elements_unit_multiplier = array(); while ($row = tep_db_fetch_array($r)) { $cid = $row['ecatid']; $eid = $row['elements_id']; $p = $row['period']; if (!isset($ecats[$cid])) { $c = $class_ea->retrieveDetail('cat', $cid); $ecats[$cid] = $c[0]['name']; } if (!in_array($p, $all_period)) { $all_period[] = $p; } if (!isset($element_list[$cid])) { $element_list[$cid] = array(); } if (!isset($element_list[$cid][$eid])) { $element_list[$cid][$eid] = array(); } if (!isset($element_list[$cid][$eid]['id'])) { $element_list[$cid][$eid]['id'] = '<div>' . $eid . '</div>'; } if (!isset($element_list[$cid][$eid]['image'])) { $element_list[$cid][$eid]['image'] = '<div>' . webImage($row['elements_image'], IMAGE_SIZE_THUMBNAIL_1, IMAGE_SIZE_THUMBNAIL_1, "Element {$eid}") . '</div>'; } if (!isset($element_list[$cid][$eid]['stock'])) { $element_list[$cid][$eid]['stock'] = '<div>' . $row['stock'] . '</div>'; } if (!isset($element_list[$cid][$eid]['order'])) { $element_list[$cid][$eid]['order'] = '<div>' . elements_order::openOrdersQuantity($eid) . '</div>'; } $element_list[$cid][$eid][$p] = '<div>' . $row['elements_needed'] . '</div>'; if (!isset($elements_total[$eid])) { $elements_total[$eid] = 0; } $elements_total[$eid] += $row['elements_needed']; if (!isset($elements_unit[$eid])) { $elements_unit[$eid] = $row['unit']; } if (!isset($elements_unit_multiplier[$eid])) { $elements_unit_multiplier[$eid] = $row['unit_multiplier']; } } foreach ($element_list as $cid => $elist) { foreach ($elist as $eid => $el) { foreach ($all_period as $p) { if (!isset($el[$p])) { $element_list[$cid][$eid][$p] = '<div>0</div>'; } } $element_list[$cid][$eid]['total'] = '<div>' . $elements_total[$eid] . '</div>'; $element_list[$cid][$eid]['unitm'] = '<div>' . $elements_unit_multiplier[$eid] . '</div>'; $element_list[$cid][$eid]['totalunit'] = '<div>' . ceil($elements_total[$eid] / $elements_unit_multiplier[$eid]) . '</div>'; $element_list[$cid][$eid]['unit'] = '<div>' . $elements_unit[$eid] . '</div>'; } } return $element_list; }
function createOrder($etesid, $qty_unit, $qty_default, $username) { //Move preorder as ORDER $result = false; if (isset($this->suppliers[$etesid]) && $this->total_orders_qty == $qty_default) { $etes = $this->suppliers[$etesid]; $qty = $qty_unit * $etes['pieces_per_qty_type']; $ids_created = array(); $ids_ignored = array(); $ids_crtless = array(); if ($qty == $qty_default) { $ids_created = array_keys($this->orders); } else { $total_updated = 0; foreach ($this->orders as $oid => $o) { if ($total_updated + $o['quantity'] <= $qty) { $total_updated += $o['quantity']; $ids_created[] = $oid; } else { $ids_ignored[] = $oid; } } foreach ($ids_ignored as $key => $oid) { if ($total_updated >= $qty) { break; } else { $total_updated += $this->orders[$oid]['quantity']; $ids_crtless[] = $oid; unset($ids_ignored[$key]); } } } use_class('elements_order'); $eo = new elements_order(null, $this->suppliers[$etesid]['elements_suppliers_id']); $eo->addItem($this->elements_id, $etes['item_number'], $qty_unit, $etes['price_quantity_type'], $etes['pieces_per_qty_type'], $etes['elements_price'], $etes['price_currency'], $username); $this->updateStatus($ids_created, '2', $username); $this->updateStatus($ids_crtless, 'L', $username); $this->updateStatus($ids_ignored, 'I', $username); $result = true; $this->load(); } return $result; }
$merge_use_elements[$eid] = $qty; } else { if ($qty > $merge_use_elements[$eid]) { $merge_use_elements[$eid] = $qty; } } } //echo "<h3>After Merged</h3>"; //echo "<pre>";var_dump($merge_use_elements);echo "</pre>"; //echo '<br /><br /><br />'; $new_use_element = array(); echo "<table border='1'>"; echo "<tr><th>Element ID</th><th>Current Stock</th><th>Pre-Ordered</th><th>Ordered</th><th>Total Available</th><th>Min Amount Needed</th></tr>"; foreach ($merge_use_elements as $eid => $qty) { $elstock = $class_es->retrieveOne(WAREHOUSE_ID_ELEMENTS, $eid); $tot_qty_el_preorder = elements_preorder::openOrdersQuantity($eid); $tot_qty_el_order = elements_order::openOrdersQuantity($eid); $total = $elstock['stock'] + $tot_qty_el_preorder + $tot_qty_el_order; echo "<tr><td>{$eid}</td><td>{$elstock['stock']}</td><td>{$tot_qty_el_preorder}</td><td>{$tot_qty_el_order}</td><td>{$total}</td><td>{$qty}</td></tr>"; if ($total < $qty) { $stock = $qty - $total; $new_use_element[] = array('elements_id' => $eid, 'quantity' => $stock); } } echo "</table>"; echo '<br /><br /><br />'; echo "<h3>New Pre Order to be created</h3>"; echo "<pre>"; var_dump($new_use_element); echo "</pre>"; echo '<br /><br /><br />';
function updateStatus($old_status, $new_status, $username) { $design_current_status = $this->sub_status != '' ? "{$this->status}-{$this->sub_status}" : $this->status; if ($design_current_status == $old_status) { $sda = array(); $temp_new_status = explode('-', $new_status); $temp_old_status = explode('-', $old_status); $new_main_status = $temp_new_status[0]; $old_main_status = $temp_old_status[0]; $new_sub_status = isset($temp_new_status[1]) ? $temp_new_status[1] : 'null'; $old_sub_status = isset($temp_old_status[1]) ? $temp_old_status[1] : 'null'; $sda['status'] = $new_main_status; $sda['sub_status'] = $new_sub_status; //will automatically reset sub_status when its moved to status that have no sub status tep_db_perform('designs', $sda, 'update', "designs_id={$this->id}"); $this->status = $new_main_status; $this->sub_status = $new_sub_status == 'null' ? null : $new_sub_status; $timestamp = $this->addStatusHistory($new_status, $username); $long_timestamp = date('Y-m-d H:i:s'); if ($old_status == '2' && $new_status == '11') { //REQUEST TO PULLEDRACK $this->setTargetDateStart($timestamp); } elseif ($old_status == '11' && $new_status == '2') { //PULLEDRACK BACK TO REQUEST $this->setTargetDateStart('CLEAR'); // } elseif ($old_status=='3' && $new_status=='5') { //DRAFTS TO SAMPLINGS } elseif ($old_status == '3' && $new_main_status == '5') { //DRAFTS TO SAMPLINGS // $drafts = $this->retrieveDrafts("approve_status='A'"); $drafts = $this->retrieveDrafts("approve_status!='R'"); if (count($drafts) == 0) { use_class('design_draft'); $draft = new design_draft(); $draft->create($this->id, $this->name, $this->colors_request, $this->followers->list_raw); $draft->uploadImage('1', DIR_WS_IMAGES . $this->image_1, basename($this->image_1)); //$draft->setApproveStatus('A', 'auto-set'); } } elseif ($old_status == '8' && $new_status == '9') { //FINALIZE TO DONE $this->setTargetDateEnd($timestamp); $drafts = $this->retrieveDrafts("approve_status!='R'"); $drafts_ids = array(); foreach ($drafts as $d) { $drafts_ids[] = $d['drafts_id']; } $products = $this->retrieveProducts(); //ADD TO WATCHLSIT $products_ids = array(); //to be used by ADD ATTRIBUTES $products_ids_nosample = array(); $products_ids_sample = array(); use_class('minierp_users'); use_class('elements_preorder'); use_class('elements_order'); use_class('products_articles'); use_class('products_minierp'); use_class('elements_stock'); $class_mu = new minierp_users(); $class_pm = new products_minierp(); $class_pa = new products_articles(); $class_es = new elements_stock(); $use_elements = array(); $eao = 2; //element adjust order foreach ($products as $p) { if (in_array($p['drafts_id'], $drafts_ids) && $p['finalized_time'] != '' && $p['finalized_by'] != '') { $products_ids[] = $p['products_id']; if ($p['create_sample'] == '1') { $products_ids_sample[] = $p['products_id']; } else { $products_ids_nosample[] = $p['products_id']; } foreach ($this->watched_by as $wl_user_id) { if ($wl_user_id > 0) { $class_mu->addToWatchlist($wl_user_id, $p['products_id']); } } // #BEGIN CALCULATE NEW ELEMENT SOURCE // first check category $tpdbq_products_use_elements = $class_pm->retrieveElementsUsage($p['products_id']); foreach ($tpdbq_products_use_elements as $row_pue) { $use_elements[] = array('elements_id' => $row_pue['elements_id'], 'quantity' => (int) $row_pue['quantity'] * $eao); } $tpdbq_products_articles = $class_pa->retrieveList($p['products_id'], "active_status='1'"); foreach ($tpdbq_products_articles as $row_pa) { $tpdbq_products_articles_use_elements = $class_pm->retrieveElementsUsage($p['products_id'], $row_pa['products_articles_id']); foreach ($tpdbq_products_articles_use_elements as $row_pue) { $use_elements[] = array('elements_id' => $row_pue['elements_id'], 'quantity' => (int) $row_pue['quantity'] * $eao); } } // #END CALCULATE NEW ELEMENT SOURCE } } // merge same element id $merge_use_elements = array(); foreach ($use_elements as $use_element) { $eid = $use_element['elements_id']; $qty = $use_element['quantity']; if (!isset($merge_use_elements[$eid])) { $merge_use_elements[$eid] = $qty; } else { if ($qty > $merge_use_elements[$eid]) { $merge_use_elements[$eid] = $qty; } } } // check to stock and // insert to element preorder //echo "</pre>merge<pre>";var_dump($merge_use_elements); // dari sini gk dibaca foreach ($merge_use_elements as $eid => $qty) { $epreorder = new elements_preorder($eid); $elstock = $class_es->retrieveOne(WAREHOUSE_ID_ELEMENTS, $eid); $tot_qty_el_preorder = elements_preorder::openOrdersQuantity($eid); $tot_qty_el_order = elements_order::openOrdersQuantity($eid); $total = $elstock['stock'] + $tot_qty_el_preorder + $tot_qty_el_order; if ($total < $qty) { $stock = $qty - $total; $epreorder->addOrder($stock, null, "New Design " . $this->id); } } //ADD ATTRIBUTES if (count($products_ids) > 0 && ($this->styles_id_F > 0 || $this->styles_id_L > 0)) { use_class('styles'); $class_s = new styles(); if ($this->styles_id_F > 0) { $class_s->addProduct($this->styles_id_F, $products_ids, $username); } if ($this->styles_id_L > 0) { $class_s->addProduct($this->styles_id_L, $products_ids, $username); } } //FINALLY, ACTIVATE THE PRODUCTS if (count($products_ids_nosample) > 0) { $class_pm->activateProducts($products_ids_nosample, true); } if (count($products_ids_sample) > 0) { $class_pm->activateProducts($products_ids_sample, true, true); } } elseif ($old_status == '11' && $new_status == '10-0') { //PULLRACK TO SOURCING $this->updateField('is_sourcing', 1); $n_drafts = $this->retrieveDrafts("approve_status!='R'"); if (count($n_drafts) == 0) { use_class('design_draft'); $draft = new design_draft(); $draft->create($this->id, $this->name); $draft->uploadImage('1', DIR_WS_IMAGES . $this->image_1, basename($this->image_1)); //$element = $draft->createElement('', $this->name, 0, '', 0, date('Y-m-d H:i:s'), 'auto', '0'); //we not auto create this, since we already used sub_status on design level } } elseif ($old_status == '10-0' && $new_status == '11') { //SOURCING BACK TO PULLRACK $this->updateField('is_sourcing', 'null'); } //INCREMENT FOR GRAPH DATASOURCE // if($old_status==3 && ($new_status==4||$new_status==5)) { if ($old_status == 3 && ($new_status == 4 || $new_main_status == 5)) { //COUNT NUMBER OF DESIGN MOVED OUT $this->addDataToField($long_timestamp, 'design_drafts', 1); } // if($new_status>5){ if ($new_main_status > 5) { //COUNT NUMBER OF PRODUCTS MOVED OUT $q = "SELECT COUNT(dp.designs_id) total_products FROM designs_products dp"; $q .= " INNER JOIN designs_drafts dd ON dd.drafts_id = dp.drafts_id AND dd.approve_status != 'R'"; $q .= " WHERE dp.designs_id = " . $this->id; $q .= " GROUP BY dp.designs_id"; $dbq = tep_db_query($q); $res = tep_db_fetch_array($dbq); $total_products = $res['total_products'] > 0 ? $res['total_products'] : 0; // if($old_status==5 && $new_status==6) $this->addDataToField($long_timestamp, 'design_samplings', $total_products); if ($old_main_status == 5 && $new_main_status == 14) { $this->addDataToField($long_timestamp, 'design_samplings', $total_products); } // if($old_status==6 && $new_status==12) $this->addDataToField($long_timestamp, 'design_graphics', $total_products); if ($old_main_status == 14 && $new_status == 12) { $this->addDataToField($long_timestamp, 'design_graphics', $total_products); } if ($old_status == 12 && $new_status == 7) { $this->addDataToField($long_timestamp, 'design_product_qc', $total_products); } if ($old_status == 7 && $new_status == 8) { $this->addDataToField($long_timestamp, 'design_details', $total_products); } if ($old_status == 8 && $new_status == 9) { $this->addDataToField($long_timestamp, 'design_finalize', $total_products); } } /*NO NEED ANYMORE, SINCE WE ALREADY SAVED sub_status ON DESIGN LEVEL if($new_status==10) { if($old_status=='1' && $this->isSourcingNewElements()) $this->addStatusHistory("10-0", $username); elseif($old_status=='6' && $this->isSourcingNewElements()) $this->addStatusHistory("10-0", $username); elseif($old_status=='4') $this->addStatusHistory("10-1", $username); elseif($old_status=='5') $this->addStatusHistory("10-7", $username); } */ } }
$sum[$item['id1']] += $item['tar q']; } //echo "<pre>";var_dump($sum); $report = array(); $r = array(); $r['id1'] = 'ID'; $r['tac na'] = 'Name'; $r['tar q'] = 'Qty Missing'; $r['tac n'] = 'No PO'; $r['tac d'] = 'Date of PO'; $r['tar qt'] = 'Qty on PO'; $report[] = $r; //$test = array(); foreach ($sum as $eid => $qty_missing) { $e = new element($eid); $polist = elements_order::openOrdersQuantityDetail($eid); //$test[$eid] = $polist; if (count($polist) == 0) { $content .= '<h3 class=red">No open PO found</h3>'; } else { foreach ($polist as $po_number => $po_data) { $r['id1'] = '<a class="view_webpage" href="?open=element&id=' . $e->id . '&hidemenu=true" title="Manage Element Detail">' . $eid . '</a>'; $r['tac na'] = substr($e->detail['name'], 0, $element_name_max_chars) . (strlen($e->detail['name']) > $element_name_max_chars ? '...' : ''); $r['tar q'] = $qty_missing; $r['tac n'] = $po_number; $r['tac d'] = date("d.m.Y", strtotime($po_data['date_submitted'])); $r['tar qt'] = $po_data['quantity_open']; $report[] = $r; break; } }
<?php use_class('elements_order'); use_class('element'); $oid = tep_db_prepare_input($_GET['id']); $eo = new elements_order($oid); $po_number = $eo->detail['po_number'] == '' ? $oid : $eo->detail['po_number']; if (isset($_POST['me_action'])) { if ($_POST['me_action'] == 'ADDRECEIVE') { $eoi_id = tep_db_prepare_input($_POST['eoi_id']); $qtyok = tep_db_prepare_input($_POST['qtyok']); $qtybad = tep_db_prepare_input($_POST['qtybad']); $qtyvoid = tep_db_prepare_input($_POST['qtyvoid']); $eo->addItemReceive($eoi_id, $qtyok, $qtybad, $qtyvoid, $session_userinfo['username']); $eoi = $eo->items[$eoi_id]; $ordr_qty = $eoi['quantity']; $recv_qty = 0; $void_qty = 0; if (isset($eo->items_received[$eoi_id])) { foreach ($eo->items_received[$eoi_id] as $ir) { $recv_qty += $ir['quantity_ok']; $void_qty += $ir['quantity_void']; } } $open_qty = elements_order::calculateOpenQuantity($ordr_qty, $recv_qty, $void_qty); $recv_qty_weight = $recv_qty * $eoi['unit_multiplier'] * $eoi['elements_weight']; $void_qty_weight = $void_qty * $eoi['unit_multiplier'] * $eoi['elements_weight']; if ($open_qty <= 0) { $open_qty_text = '<span class="notice">-</span>'; $status = 'CLOSED'; } else {
$ajaxResult['elements'] = 0; if (isset($_POST['suppliers']) && is_array($_POST['suppliers']) && count($_POST['suppliers']) > 0) { $po_list = array(); $el_list = array(); foreach ($_POST['suppliers'] as $suppliers) { list($supid, $elements_raw) = explode('|||', $suppliers); $elements = array(); $eltemp = explode('|', $elements_raw); foreach ($eltemp as $et) { list($eid, $eqty) = explode('-', $et); if ($eid > 0 && $eqty > 0) { $elements[$eid] = $eqty; } } if (count($elements) > 0) { $po = new elements_order('0'); foreach ($elements as $eid => $eqty) { $e = new element($eid); $e->getSuppliers(); $etes = null; foreach ($e->suppliers as $etes_id => $etes_temp) { if ($etes_temp['elements_suppliers_id'] == $supid) { $etes = $etes_temp; break; } } if (!is_null($etes)) { if ($po->orders_id == '0') { $po->suppliers_id = $supid; $po->createNew($etes['price_currency'], $session_userinfo['username']); $po_list[] = $po->orders_id;
<?php $currencies = array('IDR' => 'IDR', 'USD' => 'USD', 'EUR' => 'EUR'); use_class('elements_order'); use_class('element'); $oid = tep_db_prepare_input($_GET['id']); $eo = new elements_order($oid); $po_number = $eo->detail['po_number'] == '' ? $oid : $eo->detail['po_number']; if (isset($_POST['me_action'])) { if ($_POST['me_action'] == 'CONFIRMWAX') { $eoi_id = tep_db_prepare_input($_POST['eoi_id']); $status = tep_db_prepare_input($_POST['status']); $eo->confirmWax($eoi_id, $status); $wax_status = $status == 1 ? 'Wax is <span class="green bold">OK</span>' : 'Wax is <span class="red bold">BAD</span>'; $eoi = $eo->items[$eoi_id]; $result = array(); $result['oid'] = $oid; $result['eoi_id'] = $eoi_id; $result['order_er'] = elementsSourcingOpenPOlinks($oid, $eo->suppliers_id, count($eo->items), $eo->total_ordered, $eo->total_received, $eo->total_void, $eo->total_price_confirmed, $eo->total_wax_confirmed); $result['status'] = '1'; $result['wax_status'] = $wax_status; $result['item_number'] = $eoi['item_number']; ajaxReturn($result); exit; } } $content .= '<div style="clear:both;">'; $content .= ' <div style="float:left;"><table class="form" border="0" cellpadding="0" cellspacing="0">'; $content .= ' <tr><td class="label">Supplier Name</td><td>' . $eo->detail['suppliers_name'] . '</td></tr>'; $content .= ' <tr><td>Supplier PO #</td><td>' . $eo->detail['supplier_order_id'] . '</td></tr>'; $content .= ' <tr><td>Post Date</td><td>' . date('d.m.Y', strtotime($eo->detail['date_submitted'])) . '</td></tr>';
global $db; require_once '../confy.php'; require_once '../functions.php'; require_once '../functions-2.php'; require_once DIR_WS_FUNCTIONS . 'html_output.php'; tep_db_connect(); define('FPDF_IMGPATH', DIR_WS_IMAGES . 'pdf/'); define('FPDF_FONTPATH', FPDF_IMGPATH . 'fonts/'); require_once DIR_WS_CLASSES . 'fpdf.php'; use_class('element'); use_class('elements_order'); use_class('elements_suppliers'); $oid = tep_db_prepare_input($_GET['id']); $mode = tep_db_prepare_input($_GET['mode']); $eo = new elements_order($oid); $es = new elements_suppliers($eo->suppliers_id); $po_number = $eo->detail['po_number'] == '' ? $oid : $eo->detail['po_number']; $currency = $eo->detail['currency']; //$order_date = ($eo->detail['date_submitted']=='') ? time() : strtotime($eo->detail['date_submitted']); $order_date = $eo->detail['date_created'] == '' ? time() : 'Date: ' . date('j F Y', strtotime($eo->detail['date_created'])); //$pocode = 'PO '.$eo->detail['suppliers_name'].' '.date('d.m.Y', $order_date); $is_topup = isset($_GET['print-topup']) && $_GET['print-topup'] == '1' ? true : false; if ($is_topup) { $print_topup = true; $items2print = array(); $receivedBad = $eo->getLastReceivedBad(); foreach ($receivedBad as $eoi_id => $rb) { $item = $eo->items[$eoi_id]; $item['quantity'] = $rb['quantity_bad']; $items2print[] = $item;
<?php $currencies = array('IDR' => 'IDR', 'USD' => 'USD', 'EUR' => 'EUR'); use_class('elements_order'); use_class('elements_suppliers'); use_class('element'); $oid = tep_db_prepare_input($_GET['id']); $eo = new elements_order($oid); $po_number = $eo->detail['po_number'] == '' ? $oid : $eo->detail['po_number']; if (isset($_POST['me_action'])) { if ($_POST['me_action'] == 'CONFIRMPRICE') { $is_saved_to_elsup = tep_db_prepare_input($_POST['is_saved_to_elsup']) == 'true'; $eoi_id = tep_db_prepare_input($_POST['eoi_id']); $price = tep_db_prepare_input($_POST['price']); $currency = tep_db_prepare_input($_POST['currency']); $eo->confirmPrice($eoi_id, $price, $currency); $eoi = $eo->items[$eoi_id]; if ($is_saved_to_elsup) { $e = new element($eoi['elements_id']); $e->getSuppliers(); foreach ($e->suppliers as $etesid => $etes) { $el_cur_info = elements_suppliers::formatPreviousInfo($etes['elements_price'], $etes['price_currency'], $etes['price_quantity_type'], $etes['pieces_per_qty_type'], $etes['resourcing_day'], $session_userinfo['username']); if ($el_cur_info != '') { $prev_infos = explode('||', $el_cur_info); $prev_price = $prev_infos[1]; $new_el_price = $currency == 'IDR' ? number_format($price, 0, '.', '') : number_format($price, 2, '.', ''); $price_changed = "{$currency}|{$new_el_price}" != $prev_price; } if (!$price_changed) { $el_cur_info = null; }
elements_preorder::clearAllExistingOpenedSuggestion(); $logger->write('Existing Opened Suggestion is cleared!'); elements_preorder::clearPreordersTemp(); $logger->write('Existing Preorders temporary data is cleared!'); //Grab all existing elements, let's grab the data per element as an object $r = tep_db_query("SELECT e.elements_id FROM element e " . "WHERE e.is_finalized='1' ORDER BY elements_id"); $elements = array(); while ($row = tep_db_fetch_array($r)) { $elements[] = $row['elements_id']; } $total_elements = count($elements); $logger->write("Found {$total_elements} element(s) to process"); //COLLECTIVE QUERY //Grab all data that can be retrieved collectively for the whole elements $elements_stock = $class_es->retrieveAll(WAREHOUSE_ID_ELEMENTS); $elements_open_po = elements_order::openOrdersQuantityAllElements(); $elements_need_in_sourcing_tab = elements_preorder::totalNeededForSourcingTabAllElements(); //Clean all existing opened suggested //Loop through each element $elements_with_missing_qty = array(); foreach ($elements as $eid) { $e = new element($eid); //Grab all needed data $target_stock = $e->getDIOHstockTarget(); $need_in_sourcing_tab = $elements_need_in_sourcing_tab[$eid]; $current_stock = intval($elements_stock[$eid]); $already_ordered = intval($elements_open_po[$eid]); //ANY EXISTING SUGGESTIONS/PREORDERS IS DELETED IN PREVIOUS SCRIPT $already_preordered = 0; //Check if new preorder is needed (calc missing quantity) $missing_quantity = $target_stock + $need_in_sourcing_tab - ($current_stock + $already_ordered + $already_preordered);
public function retrieveOrdersQuantity() { use_class('elements_preorder'); use_class('elements_order'); $qty_preorder = elements_preorder::openOrdersQuantity($this->id); $qty_order = elements_order::openOrdersQuantity($this->id); return $qty_preorder + $qty_order; }