Ejemplo n.º 1
0
global $db;
require_once '../confy.php';
require_once '../functions.php';
require_once '../functions-2.php';
tep_db_connect();
use_class('PHPExcel/PHPExcel');
use_class('Product');
use_class('depot_orders');
use_class('products_minierp');
use_class('elements_suppliers');
$class_do = new depot_orders();
$class_pm = new products_minierp();
$order_date = $_GET['date'];
$order_date_ts = strtotime($order_date);
$supplier_id = $_GET['supplier_id'];
$supplier = new elements_suppliers($supplier_id);
$filename = date('Ymd', $order_date_ts) . '-OutsourcingPO-' . $supplier->getCleanName() . '-' . time() . '.xls';
$order_date_nice = date('d.m.Y', $order_date_ts);
$po_number_sample = date('ymd', $order_date_ts) . '/' . $supplier->id . '/001';
$date_filter_start = $order_date . ' 00:00:00';
$date_filter_end = $order_date . ' 23:59:59';
$jng_company_name = utf8_encode(JNG_ADDRESS_NAME . ' - ' . JNG_COMPANY_SUFFIX);
$jng_address = utf8_encode(JNG_ADDRESS_STREET);
$jng_shipto_recepient = utf8_encode('Ms. Julia Schüssel');
$orders_items = array();
if (isset($_GET['type']) && $_GET['type'] == 'non-refill') {
    $trans_type = depot_orders::TRANS_TYPE_NON_REFILL;
    $trans_id = depot_orders::NONREFILL_OUTSOURCED_ID;
} else {
    $trans_type = depot_orders::TRANS_TYPE_MANUAL_REFILL;
    $trans_id = depot_orders::MANUAL_REFILL_OUTSOURCED;
            $total['2'] = ' ';
            $total['tar 3'] = strval($total_ordered);
            $total['tar 4'] = strval($total_received);
            $total['tar 5'] = strval($total_open);
            $total['tar 6'] = ' ';
            $table_po[] = $total;
            $content .= tep_draw_table('', $table_po, false, true);
        }
        $title = "Open PO for Element {$eid}";
    }
} else {
    $option_refill = array('SHOWALL' => 'Show All', 'ON' => 'Show ON', 'OFF' => 'Show OFF');
    $option_stars = array('SHOWALL' => 'Show All', '0' => 'No Stars', '1' => '1 Star', '2' => '2 Stars', '3' => '3 Stars');
    $option_sourcing_type = array('SHOWALL' => 'Show All', 'S' => 'Scheduled', 'M' => 'Supermarkt');
    $option_suppliers = array('SHOWALL' => 'Show All');
    $suppliers_list = elements_suppliers::retrieveList('', 'suppliers_name');
    foreach ($suppliers_list as $supplier) {
        $option_suppliers[$supplier['elements_suppliers_id']] = $supplier['suppliers_name'];
    }
    if ($eid != '' && $hidemenuscript != '') {
        $filter_view = 'display:none;';
        $list_margin = '';
    } else {
        $filter_view = '';
        $list_margin = 'margin-left:260px;';
    }
    $content .= '<div id="search_form" class="ui-widget-content ui-corner-all" style="' . $filter_view . 'position:fixed;padding:10px;cursor:move;">';
    $content .= '<h2>Filter Window</h2>';
    $content .= '<table class="form" border="0" cellpadding="0" cellspacing="0">';
    $content .= '<tr><td colspan="2" class="bold">Elements</td></tr>';
    $content .= '<tr><td width="120">Show Maximum</td><td><input type="text" name="maxel" value="50" /></td></tr>';
Ejemplo n.º 3
0
         $q .= " AND e.attribute_category_id=" . $_SESSION[$session_page]['ef-category'];
     }
     if ($_SESSION[$session_page]['ef-supplier'] > 0) {
         $q .= " AND etes.elements_suppliers_id=" . $_SESSION[$session_page]['ef-supplier'];
     }
 }
 $q .= " GROUP BY elements_id";
 //$q .= " ORDER BY esup.suppliers_name, firstadd";
 $q .= " ORDER BY stars DESC, dioh_shadow_for_sorting_only ASC";
 $r = tep_db_query($q);
 $categories_combo = array();
 $categories = $class_ea->retrieveListData('cat');
 foreach ($categories as $cat) {
     $categories_combo[$cat['element_category_id']] = $cat['name'];
 }
 $suppliers = elements_suppliers::retrieveListCombo();
 $tabcontent = '';
 $tabcontent .= '<div style="margin-bottom:10px;">Filter by Category ';
 $tabcontent .= '<select name="ef-category" class="ef input"><option value="0">Show All</option>' . loadComboListFromArray($categories_combo, null, $_SESSION[$session_page]['ef-category']) . '</select>';
 $tabcontent .= ' &sdot; Default Supplier <select name="ef-supplier" class="ef input"><option value="0">Show All</option>' . loadComboListFromArray($suppliers, null, $_SESSION[$session_page]['ef-supplier']) . '</select>';
 $tabcontent .= '</div>';
 if (tep_db_num_rows($r) == 0) {
     $tabcontent .= '<h3 class="red">No Sourcing Data Found</h3>';
 } else {
     element::loadDIOHsettings();
     $epo_list = array();
     $epo_total = 0;
     while ($row = tep_db_fetch_array($r)) {
         $epo_total++;
         if ($status == 'M' || $row['stock'] <= $row['quantity']) {
             $epo_list[] = $row;
Ejemplo n.º 4
0
     } else {
         $es->removeElementConnection('*');
         $es->deleteDetail();
         $deleted = true;
     }
     $result = array();
     $result['esid'] = $esid;
     $result['deleted'] = $deleted ? '1' : '0';
     echo ajaxReturn($result);
     exit;
 } elseif ($_POST['me_action'] == 'CREATENEWSUPPLIER') {
     $s_name = tep_db_prepare_input(utf8_decode($_POST['sname']));
     $s_address = tep_db_prepare_input(utf8_decode($_POST['saddr']));
     $s_contact = tep_db_prepare_input(utf8_decode($_POST['scont']));
     $s_phone = tep_db_prepare_input(utf8_decode($_POST['sphon']));
     $es = new elements_suppliers(null);
     $es->create($s_name, $s_address, $s_contact, $s_phone);
     $result = '<tr>';
     $result .= '<td class="tac no green"></td>';
     $result .= '<td class="supname green">' . $s_name . '</td>';
     $result .= '<td class="supaddress green">' . $s_address . '</td>';
     $result .= '<td class="supcontact green">' . $s_contact . '</td>';
     $result .= '<td class="supphone green">' . $s_phone . '</td>';
     $result .= '<td class="tac supsdt green" title="Please refresh page to set safety delivery time for this new supplier">-</td>';
     $result .= '<td class="tac supoutsourced green" title="Please refresh page to set outsourced flag for this new supplier">-</td>';
     $result .= '<td class="tac supscheduled green" title="Please refresh page to set scheduled flag for this new supplier">-</td>';
     $result .= '<td class="tac action green bold">NEW</td>';
     $result .= '</tr>';
     echo utf8_encode($result);
     exit;
 }
$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;
                }
                if ($etes['elements_suppliers_id'] == $eo->suppliers_id && $etes['item_number'] == $eoi['item_number']) {
                    $e->updateSupplier($etesid, $etes['elements_suppliers_id'], $price, $etes['price_quantity_type'], $etes['item_number'], $currency, $etes['discount'], $etes['pieces_per_qty_type'], $etes['is_default'], $etes['resourcing_day'], $el_cur_info);
                }
            }
        }
        $result = array();
Ejemplo n.º 6
0
 /**
  * Get all outsourcing suppliers
  * @return Array
  */
 function getOutsourceSuppliers()
 {
     use_class('elements_suppliers');
     return elements_suppliers::retrieveListCombo("suppliers_outsourced='1'");
 }
Ejemplo n.º 7
0
            }
            $row .= '</tr>';
        }
        echo utf8_encode($row);
        exit;
    } elseif ($_POST['me_action'] == 'ELEMENTCONNECTIONDELETE') {
        $esid = tep_db_prepare_input($_POST['esid']);
        $eid = tep_db_prepare_input($_POST['eid']);
        $es = new elements_suppliers($esid);
        $es->removeElementConnection($eid);
        echo utf8_encode('id-' . $eid);
        exit;
    }
}
$esid = tep_db_prepare_input($_GET['id']);
$es = new elements_suppliers($esid);
$list = $es->retrieveElementsConnection();
$listofids = array();
$listofcodes = array();
$listofprices = array();
foreach ($list as $l) {
    $eid = $l['elements_id'];
    if (!in_array($eid, $listofids)) {
        $listofids[] = $eid;
    }
    if (!isset($listofcodes[$eid])) {
        $listofcodes[$eid] = array();
    }
    $listofcodes[$eid][] = $l['item_number'];
    if (!isset($listofprices[$eid])) {
        $listofprices[$eid] = array();
Ejemplo n.º 8
0
function getElementSuppliers($elements_id)
{
    global $s_suppliers, $s_elements, $accessed, $designs_id, $session_userinfo;
    $element = new element($elements_id);
    if (is_null($element->id)) {
        $result = '<span class="red">Can not find Element ' . $msg_filter_type . ' <strong>' . $elements_id . '</strong>';
    } else {
        $suppliers = $s_suppliers->retrieveListCombo(SERVICECLIENTCODE);
        $el_suppliers = $element->getSuppliers();
        $sup_exist = array();
        if (count($el_suppliers) == 0) {
            $suppliers_table = '<span class="red">There is no suppliers info for this element yet</span>';
            $suppliers_button = '';
        } else {
            $unit_types = array('', 'strand', 'bottle', 'box', 'meter', 'gram', 'pieces', 'set', 'dozen', 'sheet', 'pack', 'roll', 'pair');
            $currencies = array('', 'IDR', 'USD', 'EUR');
            $sup_table = array();
            /*
                        $st_header_is_default = 'Default';
                        $st_header_suppplier_name = 'Supplier Name';
                        $st_header_element_code = 'Supplier Code';
                        $st_header_net_price = 'Net Price';
                        $st_header_discount = 'Discount';
                        $st_header_unit = 'Buying<br />Unit';
                        $st_header_qty_per_unit = 'Qty per<br />Buying Unit';
                        $st_header_safety_del_time = '<abbr title="Safety Delivery Time">SDT</abbr><br />in days';
                        $st_header_remove = 'Remove';
            */
            $st_header = elements_suppliers::getListTableHeader();
            $st_header_is_default = $st_header[0];
            $st_header_suppplier_name = $st_header[1];
            $st_header_element_code = $st_header[2];
            $st_header_net_price = $st_header[3];
            $st_header_discount = $st_header[4];
            $st_header_unit = $st_header[5];
            $st_header_qty_per_unit = $st_header[6];
            $st_header_safety_del_time = $st_header[7];
            $st_header_remove = $st_header[8];
            $st_header = array();
            $st_header['a w080 tac'] = $st_header_is_default;
            $st_header['b w200 tac'] = $st_header_suppplier_name;
            $st_header['c w300 tac'] = $st_header_element_code;
            $st_header['d w150 tac'] = $st_header_net_price;
            $st_header['e w080 tac'] = $st_header_discount;
            $st_header['f w080 tac'] = $st_header_unit;
            $st_header['g w080 tac'] = $st_header_qty_per_unit;
            $st_header['h w080 tac'] = $st_header_safety_del_time;
            $st_header['i w080 tac'] = $st_header_remove;
            $sup_table[] = $st_header;
            foreach ($el_suppliers as $supplier) {
                $st = array();
                $obj_elsup = new elements_suppliers($supplier['elements_suppliers_id']);
                //$supid = $supplier['elements_suppliers_id'];
                $supid = $supplier['etes_id'];
                $sup_exist[] = $supid;
                foreach ($st_header as $sth_k => $sth_v) {
                    switch ($sth_v) {
                        case $st_header_is_default:
                            $def_checked = $supplier['is_default'] == '1' ? 'checked="checked"' : '';
                            $radio_def = '<input type="radio" name="is_default" value="' . $supid . '" ' . $def_checked . ' />';
                            $value = $radio_def;
                            break;
                        case $st_header_suppplier_name:
                            $value = $supplier['suppliers_name'] . '<input type="hidden" name="elsups[' . $supid . '][elements_suppliers_id]" value="' . $supplier['elements_suppliers_id'] . '" />';
                            break;
                        case $st_header_element_code:
                            $sup_code = $obj_elsup->autoGenerateSupplierCode($supplier['elements_id']);
                            $value = $sup_code != '' ? '<input type="text" class="w300" name="elsups[' . $supid . '][item_number]" value="' . $sup_code . '" readonly="readonly" />' : '<input type="text" class="w300" name="elsups[' . $supid . '][item_number]" value="' . $supplier['item_number'] . '" />';
                            break;
                        case $st_header_net_price:
                            $curr_combo = '<select class="mandatory" name="elsups[' . $supid . '][price_currency]" style="width:50px;">';
                            foreach ($currencies as $cur) {
                                $curr_sel = $cur == $supplier['price_currency'] ? 'selected="selected"' : '';
                                $curr_combo .= '<option ' . $curr_sel . '>' . $cur . '</option>';
                            }
                            $curr_combo .= '</select>';
                            //$price  = '<input type="text" name="elsups['.$supid.'][price_currency]" value="'.$supplier['price_currency'].'" style="width:50px;" />';
                            $price_value = $supplier['price_currency'] == 'IDR' ? number_format($supplier['elements_price'], 0, '.', '') : number_format($supplier['elements_price'], 2, '.', '');
                            //This below current info will saved when there data changes
                            $el_cur_info = elements_suppliers::formatPreviousInfo($supplier['elements_price'], $supplier['price_currency'], $supplier['price_quantity_type'], $supplier['pieces_per_qty_type'], $supplier['resourcing_day'], $session_userinfo['username']);
                            //GET PREVIOUS INFO OF ELEMENT
                            $title_prev_info = elements_suppliers::tooltipDataPreviousInfo($supplier['elements_previous_info']);
                            $value = $curr_combo;
                            $value .= '<input type="text" name="elsups[' . $supid . '][price]" value="' . $price_value . '" style="width:70px;" title="' . $title_prev_info . '" class="mandatory help"/>';
                            $value .= '<input type="hidden" name="elsups[' . $supid . '][cur_price]" value="' . $price_value . '"/>';
                            $value .= '<input type="hidden" name="elsups[' . $supid . '][cur_currency]" value="' . $supplier['price_currency'] . '"/>';
                            $value .= '<input type="hidden" name="elsups[' . $supid . '][cur_info]" value="' . $el_cur_info . '"/>';
                            break;
                        case $st_header_discount:
                            $value = '<input type="text" name="elsups[' . $supid . '][discount]" value="' . number_format($supplier['discount'], 2, '.', '') . '" style="width:50px;" />';
                            break;
                        case $st_header_unit:
                            $value = '<select class="es-pqt mandatory" name="elsups[' . $supid . '][price_qty_type]" style="width:70px;">';
                            foreach ($unit_types as $ut) {
                                $unit_sel = $ut == $supplier['price_quantity_type'] ? 'selected="selected"' : '';
                                $value .= '<option ' . $unit_sel . '>' . $ut . '</option>';
                            }
                            $value .= '</select>';
                            break;
                        case $st_header_qty_per_unit:
                            $value = '<input type="text" class="es-ppqt mandatory" name="elsups[' . $supid . '][pieces_per_qty_type]" value="' . $supplier['pieces_per_qty_type'] . '" style="width:50px;text-align:center;" />';
                            break;
                        case $st_header_safety_del_time:
                            $value = '<input type="text" name="elsups[' . $supid . '][resourcing_day]" value="' . $supplier['resourcing_day'] . '" readonly="readonly" style="width:30px;text-align:center;" title="Please change safety delivery time in supplier level" />';
                            break;
                        case $st_header_remove:
                            $value = '<input type="checkbox" name="remove[]" value="' . $supid . '" class="cbrem" />';
                            break;
                    }
                    $st[$sth_k] = $value;
                }
                $sup_table[] = $st;
            }
            $suppliers_table = tep_draw_table('', $sup_table);
            $suppliers_button = '<div style="margin-top:10px;"><input type="submit" name="submit" class="button" value="Save Changes" /></div>';
        }
        $suppliers_combo = '<select name="new_supplier" class="iwbutton input">';
        $suppliers_combo .= '<option value="">Select a Supplier...</option>';
        foreach ($suppliers as $sup) {
            //if(!in_array($sup['cb_value'], $sup_exist)) //open option for multiple supplier per element
            $suppliers_combo .= '<option value="' . $sup['cb_value'] . '">' . $sup['cb_option'] . '</option>';
        }
        $suppliers_combo .= '</select>';
        $result = '';
        $result .= '<div style="float:left;margin-right:10px;">' . webImage($element->image, '130', '130', $element->id, 'img-border') . '</div>';
        $result .= '<h3>Element ' . $elements_id . '</h3>';
        //$result .= '<h2>'.$element->detail['name'].'</h2>';
        $result .= '<h2>' . $element->detail['description'] . '</h2>';
        $result .= '<div>Weight ' . $element->detail['weight'] . ' gram/qty</div>';
        $result .= '<form name="new-el-sup" action="?open=elements-suppliers" method="post">';
        $result .= '<input type="hidden" name="me_action" value="ADDELEMENTSSUPPLIERS" />';
        $result .= '<input type="hidden" name="elements_id" value="' . $element->id . '" />';
        $result .= '<div style="margin-top:55px;">' . $suppliers_combo . '<input type="submit" name="submit" value="Add New Supplier" /></div>';
        $result .= '</form>';
        $result .= '<div style="clear:both;">&nbsp;</div>';
        $result .= '<div class="red" style="margin-bottom:2px;"><strong>Safety Delivery Time (SDT)</strong> is now set in Supplier level</div>';
        $add_param = $accessed == CONST_ACCESS_DESIGNS_MANAGEMENT ? '&accessed=' . CONST_ACCESS_DESIGNS_MANAGEMENT . '&designs_id=' . $designs_id : '';
        $result .= '<form id="upd-el-sup" action="?open=elements-suppliers' . $add_param . '" method="post">';
        $result .= '<input type="hidden" name="me_action" value="UPDATEELEMENTSSUPPLIERS" />';
        $result .= '<input type="hidden" name="elements_id" value="' . $element->id . '" />';
        $result .= $suppliers_table;
        $result .= $suppliers_button;
        $result .= '</form>';
    }
    return $result;
}