Ejemplo n.º 1
0
function search_finduser()
{
    $design = new design('Finduser', '', 0);
    $design->header();
    $tpl = new tpl('search_finduser');
    $tpl->out(0);
    if (isset($_POST['sub']) and !empty($_POST['name'])) {
        $name = str_replace('*', "%", $_POST['name']);
        $name = escape($name, 'string');
        $q = "SELECT `name`,`name` FROM `prefix_user` WHERE `name` LIKE '" . $name . "'";
        $tpl->set('username', dbliste('', $tpl, 'username', $q));
        $tpl->out(1);
    }
    $tpl->out(2);
    $design->footer();
}
Ejemplo n.º 2
0
function check_forum_failure($ar)
{
    if (array_key_exists(0, $ar)) {
        $hmenu = '<a class="smalfont" href="?forum">Forum</a><b> &raquo; </b> Fehler aufgetreten';
        $title = 'Forum : Fehler aufgetreten';
        $design = new design($title, $hmenu);
        $design->header();
        echo '<b>Es ist/sind folgende(r) Fehler aufgetreten</b><br />';
        foreach ($ar as $v) {
            echo $v . '<br />';
        }
        echo '<br /><a href="javascript:history.back(-1)">zur&uuml;ck</a>';
        $design->footer();
        exit;
    }
    return true;
}
Ejemplo n.º 3
0
                 design::table_cell($TrCategoryShow, "");
             }
         }
         //AMOUNT
         $TrAmountShow = number_format($resultarray[$i]["Amount"], 2, ",", "");
         design::table_cell($TrAmountShow, "text_align_right td_size_5");
         //NOTES
         $TrNotesShow = $resultarray[$i]["Notes"];
         $NotesHTMLCode = "";
         if ($TrNotesShow != "" && $TrNotesShow != "None") {
             $NotesHTMLCode .= "<span class='glyphicon glyphicon-info-sign' data-toggle='tooltip' title='{$TrNotesShow}' id='tooltip_notes_{$lineid}'></span> ";
         }
         if (attachments::get_number_of_attachments($lineid) > 0) {
             $NotesHTMLCode .= "<span class='glyphicon glyphicon-paperclip'></span>";
         }
         design::table_cell($NotesHTMLCode, "text_align_center");
         //DELETE
         echo "<td class ='text_align_center'>";
         echo "<input type='checkbox' name='TrDelete[]' value='{$lineid}' />";
         echo "</td>";
         //EDIT
         echo "<td class ='text_align_center'>";
         echo "<input type='radio' name='TrEdit[]' value='{$lineid}' />";
         echo "</td>";
         echo "</tr>";
     }
 }
 echo "</tbody>";
 echo "</table>";
 echo "</div>\n";
 echo "<br />";
<?php

use_class('design');
$imgsize = '150';
$rowListReload = false;
if (isset($_GET['id']) && !isset($design)) {
    $id = tep_db_prepare_input($_GET['id']);
    $design = new design($id);
    $drafts = $design->retrieveDrafts("approve_status != 'R'");
}
if (is_null($design->id)) {
    $content .= '<h3 class="red">Can not found requested Design in database</h2>';
    $content .= '<a href="?open=designs-new">&raquo; Click here to Create New Design</a>';
} else {
    $img1 = webImage($design->image_1, $imgsize, $imgsize, 'Main Image', 'img-border', '');
    $img2 = webImage($design->image_2, $imgsize, $imgsize, 'Additional Image', 'img-border', '');
    $content .= '<form name="copydesign" method="post" action="?open=designs-detail">';
    $content .= '<input type="hidden" name="me_action" value="CREATENEWDESIGN" />';
    $content .= '<div style="float:left;margin-left:15px;">';
    //LEFT Part open
    $margin_left = 15;
    if (strpos($img1, 'color-pattern') === false) {
        $cbid = 'cb-img-1';
        $content .= '<div id="image_1" style="float:left;width:' . $imgsize . 'px;height:210px;text-align:center;">';
        $content .= '<label for="' . $cbid . '"><strong>Main Image</strong><br />';
        $content .= $img1 . '</label>';
        $content .= '<br /><input type="checkbox" id="' . $cbid . '" name="image_1" value="' . $design->image_1 . '" checked="checked" style="margin-top:2px;" /> <label for="' . $cbid . '">Copy Image</label>';
        $content .= '</div>';
        $margin_left += $imgsize;
    }
    if (strpos($img2, 'color-pattern') === false) {
Ejemplo n.º 5
0
// Text der gesendet wird, wenn ein Eintrag bearbeitet wird
$message2 = $lang['awaycalchangedenquiry'];
// Text fuer den User wenn der Stutus geandert wurde
$message3 = $lang['awaycalstatuschanged'];
// function
function away_sendpmtoleaders($m, $uid, $a)
{
    $q = "SELECT\r\n    DISTINCT `prefix_user`.`id` as `uid`\r\n  FROM `prefix_user`\r\n    LEFT JOIN `prefix_groupusers` ON `prefix_groupusers`.`uid` = " . $uid . "\r\n    LEFT JOIN `prefix_groups` ON `prefix_groups`.`id` = `prefix_groupusers`.`gid`\r\n  WHERE `recht` <= -7\r\n     OR (`mod1` = `prefix_user`.`id` AND `uid` = " . $uid . ")\r\n     OR (`mod2` = `prefix_user`.`id` AND `uid` = " . $uid . ")\r\n     OR (`mod3` = `prefix_user`.`id` AND `uid` = " . $uid . ")\r\n     OR (`mod4` = `prefix_user`.`id` AND `uid` = " . $uid . ")";
    $erg = db_query($q);
    while ($r = db_fetch_assoc($erg)) {
        sendpm($_SESSION['authid'], $r['uid'], 'Away-Anfrage', $m, -1);
    }
}
$title = $allgAr['title'] . ' :: Awaycalender';
$hmenu = 'Awaycalender';
$design = new design($title, $hmenu);
$header = array('jquery/jquery.validate.js', 'forms/awaycal.js');
$design->header($header);
$tpl = new tpl('awaycal.htm');
if ($_SESSION['authright'] > -3) {
    // Pruefen ob der User ein TrialMember oder mehr ist
    echo $lang['nopermission'];
    $design->footer(1);
}
// status aendern
if ($menu->getA(1) == 'c' and is_numeric($menu->getE(1)) and is_numeric($menu->get(2)) and is_siteadmin('awaycal')) {
    $uid = db_result(db_query("SELECT `uid` FROM `prefix_awaycal` WHERE `id` = " . $menu->getE(1)), 0);
    db_query("UPDATE `prefix_awaycal` SET `pruef` = " . $menu->get(2) . " WHERE `id` = " . $menu->getE(1));
    sendpm($_SESSION['authid'], $uid, 'Away-Anfrage', $message3);
}
if ($menu->getA(1) == 'd' and is_numeric($menu->getE(1)) and is_siteadmin('awaycal')) {
Ejemplo n.º 6
0
/**
 * Construct KPI Leadtime Table
 * @param string $status
 * @param string $kpi_closing_date_start
 * @param string $kpi_closing_date_end
 * @return string
 */
function kpiLeadtimeLoad($kpi_status, $kpi_closing_date_start = '', $kpi_closing_date_end = '')
{
    use_class('jng_sp');
    use_class('design');
    $class_sp = new jng_sp();
    $sp_b2b = array_keys($class_sp->retrieveList('active_status = 1 AND use_amvd_logistic = 1'));
    $target_leadtime = load_config('kpi-leadtime');
    $design_categories = design::getDesignCategory();
    $initial = array('sourcing' => 0, 'depot-refill-orders' => 0, 'internal-levelling-orders' => 0, 'cust-order-mto-mmo' => 0, 'external-levelling-order' => 0, 'full-dso' => 0, 'mto' => 0);
    foreach ($design_categories as $des_cat_id => $des_cat_name) {
        $initial["design-{$des_cat_id}"] = 0;
    }
    $below_target = $initial;
    $on_target = $initial;
    $above_target_1to3d = $initial;
    $above_target_gt3d = $initial;
    $total = $initial;
    $kpi_leadtime_data_o = array();
    //open
    $kpi_leadtime_data_c = array();
    //closed
    //PREPARE KPI LEADTIME DATA
    if ($kpi_status == 'o') {
        //OPEN ORDERS
        //Sourcing
        $q = " SELECT sp_type, item_id, quantity, MIN(status_date) AS date_start FROM";
        $q .= " (";
        $q .= " SELECT 'sp' AS sp_type, joi.jng_sp_orders_items_id AS item_id" . ", joish.status_date, joi.order_quantity AS quantity";
        $q .= " FROM jng_sp_orders_items joi" . " INNER JOIN jng_sp_orders_items_status_history joish ON joish.jng_sp_orders_items_id = joi.jng_sp_orders_items_id" . " AND joish.status = 2";
        $q .= " WHERE joi.status = 2";
        $q .= " UNION";
        $q .= " SELECT 'jg' AS sp_type, op.orders_products_id AS item_id" . ", opsh.status_date, op.products_quantity AS quantity";
        $q .= " FROM orders_products op" . " INNER JOIN orders_products_status_history opsh ON opsh.orders_products_id = op.orders_products_id" . " AND opsh.status = 2";
        $q .= " WHERE op.status = 2";
        $q .= " UNION";
        $q .= " SELECT 'dp' AS sp_type, do.depot_orders_id AS item_id" . ", dosh.update_time AS status_date, do.quantity";
        $q .= " FROM depot_orders do" . " INNER JOIN depot_orders_status_history dosh ON dosh.depot_orders_id = do.depot_orders_id" . " AND dosh.status = 2";
        $q .= " WHERE do.status = 2";
        $q .= ") dt";
        $q .= " GROUP BY sp_type, item_id";
        $dbq = tep_db_query($q);
        while ($r = tep_db_fetch_array($dbq)) {
            //Sourcing Order Type
            $kpi_leadtime_data_o['sourcing'][] = $r;
        }
        //Production
        $q = " SELECT sp_type, item_id, quantity, MIN(status_date) AS date_start, mode, order_type, order_type_id, order_type_name";
        $q .= " FROM (";
        $q .= " SELECT 'sp' AS sp_type, joi.jng_sp_orders_items_id AS item_id" . ", joish.status_date, joi.order_quantity AS quantity, joi.mode" . ", '' AS order_type, '' AS order_type_id, '' AS order_type_name";
        $q .= " FROM jng_sp_orders_items joi" . " INNER JOIN jng_sp_orders_items_status_history joish ON joish.jng_sp_orders_items_id = joi.jng_sp_orders_items_id" . " AND joish.status = 4";
        $q .= " WHERE joi.status = 4";
        $q .= " UNION";
        $q .= " SELECT 'jg' AS sp_type, op.orders_products_id AS item_id" . ", opsh.status_date, op.products_quantity AS quantity, op.mode" . ", '' AS order_type, '' AS order_type_id, '' AS order_type_name";
        $q .= " FROM orders_products op" . " INNER JOIN orders_products_status_history opsh ON opsh.orders_products_id = op.orders_products_id" . " AND opsh.status = 4";
        $q .= " WHERE op.status = 4";
        $q .= " UNION";
        $q .= " SELECT 'dp' AS sp_type, do.depot_orders_id AS item_id" . ", dosh.update_time AS status_date, do.quantity, '' AS mode" . ", trans_type AS order_type, trans_id AS order_type_id, group_name AS order_type_name";
        $q .= " FROM depot_orders do" . " INNER JOIN depot_orders_status_history dosh ON dosh.depot_orders_id = do.depot_orders_id" . " AND dosh.status = 4";
        $q .= " WHERE do.status = 4";
        $q .= ") dt";
        $q .= " GROUP BY sp_type, item_id";
        $dbq = tep_db_query($q);
        while ($r = tep_db_fetch_array($dbq)) {
            if ($r['order_type'] == 'AR' || $r['order_type'] == '' && $r['order_type_id'] == depot_orders::MANUAL_REFILL_ID) {
                //Depot Refill Order Type
                $kpi_leadtime_data_o['depot-refill-orders'][] = $r;
            } elseif ($r['order_type_name'] == depot_orders::GROUP_NAME_LTF_INTERNAL) {
                //Internal Levelling Order Type
                $kpi_leadtime_data_o['internal-levelling-orders'][] = $r;
            } elseif ($r['mode'] == 2 || $r['mode'] == 4) {
                //Customer Orders (MTO/MMO) Order Type
                $kpi_leadtime_data_o['cust-order-mto-mmo'][] = $r;
            }
        }
        //Outsourcing
        $q = " SELECT do.depot_orders_id AS item_id, MIN(dosh.update_time) AS status_date, do.quantity";
        $q .= " FROM depot_orders do" . " INNER JOIN depot_orders_status_history dosh ON dosh.depot_orders_id = do.depot_orders_id" . " AND dosh.status = 22";
        $q .= " WHERE do.status = 22";
        $q .= " AND do.trans_type = '' && do.trans_id = " . depot_orders::MANUAL_REFILL_OUTSOURCED;
        $q .= " GROUP BY item_id";
        $dbq = tep_db_query($q);
        while ($r = tep_db_fetch_array($dbq)) {
            //External Levelling Order Type
            $kpi_leadtime_data_o['external-levelling-order'][] = $r;
        }
        //Customer Order
        $q = " SELECT sp_type, item_id, quantity, MIN(status_date) AS date_start, mode";
        $q .= " FROM (";
        $q .= " SELECT 'sp' AS sp_type, joi.jng_sp_orders_items_id AS item_id" . ", joish.status_date, joi.order_quantity AS quantity, joi.mode";
        $q .= " FROM jng_sp_orders jo " . " INNER JOIN jng_sp_orders_items joi ON joi.jng_sp_orders_id = jo.jng_sp_orders_id" . " INNER JOIN jng_sp_orders_items_status_history joish ON joish.jng_sp_orders_items_id = joi.jng_sp_orders_items_id" . " AND joish.status = 1";
        $q .= " WHERE joi.status < 9 AND jo.jng_sp_id NOT IN (" . implode(',', $sp_b2b) . ")";
        $q .= " UNION";
        $q .= " SELECT 'jg' AS sp_type, op.orders_products_id AS item_id" . ", opsh.status_date, op.products_quantity AS quantity, op.mode";
        $q .= " FROM orders_products op" . " INNER JOIN orders_products_status_history opsh ON opsh.orders_products_id = op.orders_products_id" . " AND opsh.status = 1";
        $q .= " WHERE op.status < 9";
        $q .= ") dt";
        $q .= " GROUP BY sp_type, item_id";
        $dbq = tep_db_query($q);
        while ($r = tep_db_fetch_array($dbq)) {
            if ($r['mode'] == 1) {
                //Full DSO Order Type
                $kpi_leadtime_data_o['full-dso'][] = $r;
            } elseif ($r['mode'] == 2 || $r['mode'] == 3 || $r['mode'] == 4) {
                $kpi_leadtime_data_o['mto'][] = $r;
            }
        }
        //Design
        $q = " SELECT d.designs_category, 1 AS quantity, d.designs_id AS item_id" . ", FROM_UNIXTIME(MIN(dsh.status_time)) AS date_start";
        $q .= " FROM designs d " . " INNER JOIN designs_status_history dsh ON dsh.designs_id = d.designs_id AND dsh.status = 2";
        $q .= " WHERE d.status NOT IN (1, 9)";
        $q .= " GROUP BY d.designs_id";
        $dbq = tep_db_query($q);
        while ($r = tep_db_fetch_array($dbq)) {
            $kpi_leadtime_data_o["design-{$r['designs_category']}"][] = $r;
        }
    } elseif ($kpi_status == 'c') {
        $kpi_filter_closing_date_start = date('Y-m-d', strtotime($kpi_closing_date_start));
        $kpi_filter_closing_date_end = date('Y-m-d', strtotime($kpi_closing_date_end));
        //Sourcing
        $q = " SELECT * FROM";
        $q .= " (";
        $q .= " SELECT 'sp' AS sp_type, joi.jng_sp_orders_items_id AS item_id, joi.order_quantity AS quantity" . ", MIN(joish_2.status_date) AS date_start, MAX(joish_3.status_date) AS date_end";
        $q .= " FROM jng_sp_orders_items_status_history joish_3" . " LEFT JOIN jng_sp_orders_items joi ON joi.jng_sp_orders_items_id = joish_3.jng_sp_orders_items_id" . " LEFT JOIN jng_sp_orders_items_status_history joish_2 ON joish_2.jng_sp_orders_items_id = joi.jng_sp_orders_items_id" . " AND joish_2.status = 2";
        $q .= " WHERE joish_3.status_date >= '{$kpi_filter_closing_date_start} 00:00:00'" . " AND joish_3.status_date <= '{$kpi_filter_closing_date_end} 23:59:59'" . " AND joish_3.status = 3 AND joi.status NOT IN (1, 2)";
        $q .= " GROUP BY sp_type, item_id";
        $q .= " UNION";
        $q .= " SELECT 'jg' AS sp_type, op.orders_products_id AS item_id, op.products_quantity AS quantity" . ", MIN(opsh_2.status_date) AS date_start, MAX(opsh_3.status_date) AS date_end";
        $q .= " FROM orders_products_status_history opsh_3" . " LEFT JOIN orders_products op ON op.orders_products_id = opsh_3.orders_products_id" . " LEFT JOIN orders_products_status_history opsh_2 ON opsh_2.orders_products_id = op.orders_products_id" . " AND opsh_2.status = 2";
        $q .= " WHERE opsh_3.status_date >= '{$kpi_filter_closing_date_start} 00:00:00'" . " AND opsh_3.status_date <= '{$kpi_filter_closing_date_end} 23:59:59'" . " AND opsh_3.status = 3 AND op.status NOT IN (1, 2)";
        $q .= " GROUP BY sp_type, item_id";
        $q .= " UNION";
        $q .= " SELECT 'dp' AS sp_type, do.depot_orders_id AS item_id, do.quantity" . ", MIN(dosh_2.update_time) AS date_start, MAX(dosh_3.update_time) AS date_end";
        $q .= " FROM depot_orders_status_history dosh_3" . " LEFT JOIN depot_orders do ON do.depot_orders_id = dosh_3.depot_orders_id" . " LEFT JOIN depot_orders_status_history dosh_2 ON dosh_2.depot_orders_id = do.depot_orders_id" . " AND dosh_2.status = 2";
        $q .= " WHERE dosh_3.update_time >= '{$kpi_filter_closing_date_start} 00:00:00'" . " AND dosh_3.update_time <= '{$kpi_filter_closing_date_end} 23:59:59'" . " AND dosh_3.status = 3 AND do.status NOT IN (1, 2)";
        $q .= " GROUP BY sp_type, item_id";
        $q .= ") dt";
        $q .= " WHERE date_start IS NOT NULL AND date_end IS NOT NULL";
        $dbq = tep_db_query($q);
        while ($r = tep_db_fetch_array($dbq)) {
            //Sourcing Order Type
            $kpi_leadtime_data_c['sourcing'][] = $r;
        }
        //Production
        $q = " SELECT * FROM";
        $q .= " (";
        $q .= " SELECT 'sp' AS sp_type, joi.jng_sp_orders_items_id AS item_id, joi.order_quantity AS quantity" . ", MIN(joish_4.status_date) AS date_start, MAX(joish_5.status_date) AS date_end, joi.mode" . ", '' AS order_type, '' AS order_type_id, '' AS order_type_name";
        $q .= " FROM jng_sp_orders_items_status_history joish_5" . " LEFT JOIN jng_sp_orders_items joi ON joi.jng_sp_orders_items_id = joish_5.jng_sp_orders_items_id" . " LEFT JOIN jng_sp_orders_items_status_history joish_4 ON joish_4.jng_sp_orders_items_id = joi.jng_sp_orders_items_id" . " AND joish_4.status = 4";
        $q .= " WHERE joish_5.status_date >= '{$kpi_filter_closing_date_start} 00:00:00'" . " AND joish_5.status_date <= '{$kpi_filter_closing_date_end} 23:59:59'" . " AND joish_5.status = 5 AND joi.status NOT IN (1, 2, 3, 4)";
        $q .= " GROUP BY sp_type, item_id";
        $q .= " UNION";
        $q .= " SELECT 'jg' AS sp_type, op.orders_products_id AS item_id, op.products_quantity AS quantity" . ", MIN(opsh_4.status_date) AS date_start, MAX(opsh_5.status_date) AS date_end, op.mode" . ", '' AS order_type, '' AS order_type_id, '' AS order_type_name";
        $q .= " FROM orders_products_status_history opsh_5" . " LEFT JOIN orders_products op ON op.orders_products_id = opsh_5.orders_products_id" . " LEFT JOIN orders_products_status_history opsh_4 ON opsh_4.orders_products_id = op.orders_products_id" . " AND opsh_4.status = 4";
        $q .= " WHERE opsh_5.status_date >= '{$kpi_filter_closing_date_start} 00:00:00'" . " AND opsh_5.status_date <= '{$kpi_filter_closing_date_end} 23:59:59'" . " AND opsh_5.status = 5 AND op.status NOT IN (1, 2, 3, 4)";
        $q .= " GROUP BY sp_type, item_id";
        $q .= " UNION";
        $q .= " SELECT 'dp' AS sp_type, do.depot_orders_id AS item_id, do.quantity" . ", MIN(dosh_4.update_time) AS date_start, MAX(dosh_5.update_time) AS date_end, '' AS mode" . ", trans_type AS order_type, trans_id AS order_type_id, group_name AS order_type_name";
        $q .= " FROM depot_orders_status_history dosh_5" . " LEFT JOIN depot_orders do ON do.depot_orders_id = dosh_5.depot_orders_id" . " LEFT JOIN depot_orders_status_history dosh_4 ON dosh_4.depot_orders_id = do.depot_orders_id" . " AND dosh_4.status = 4";
        $q .= " WHERE dosh_5.update_time >= '{$kpi_filter_closing_date_start} 00:00:00'" . " AND dosh_5.update_time <= '{$kpi_filter_closing_date_end} 23:59:59'" . " AND dosh_5.status = 5 AND do.status NOT IN (1, 2, 3, 4)";
        $q .= " GROUP BY sp_type, item_id";
        $q .= ") dt";
        $q .= " WHERE date_start IS NOT NULL AND date_end IS NOT NULL";
        $dbq = tep_db_query($q);
        while ($r = tep_db_fetch_array($dbq)) {
            if ($r['order_type'] == 'AR' || $r['order_type'] == '' && $r['order_type_id'] == depot_orders::MANUAL_REFILL_ID) {
                //Depot Refill Order Type
                $kpi_leadtime_data_c['depot-refill-orders'][] = $r;
            } elseif ($r['order_type_name'] == depot_orders::GROUP_NAME_LTF_INTERNAL) {
                //Internal Levelling Order Type
                $kpi_leadtime_data_c['internal-levelling-orders'][] = $r;
            } elseif ($r['mode'] == 2 || $r['mode'] == 4) {
                //Customer Orders (MTO/MMO) Order Type
                $kpi_leadtime_data_c['cust-order-mto-mmo'][] = $r;
            }
        }
        //Outsourcing
        $q = " SELECT * FROM";
        $q .= " (";
        $q .= " SELECT do.depot_orders_id AS item_id, do.quantity" . ", MIN(dosh_8.update_time) AS date_start, MAX(dosh_22.update_time) AS date_end";
        $q .= " FROM depot_orders_status_history dosh_22" . " LEFT JOIN depot_orders do ON do.depot_orders_id = dosh_22.depot_orders_id" . " LEFT JOIN depot_orders_status_history dosh_8 ON dosh_8.depot_orders_id = do.depot_orders_id" . " AND dosh_8.status = 8";
        $q .= " WHERE dosh_22.update_time >= '{$kpi_filter_closing_date_start} 00:00:00'" . " AND dosh_22.update_time <= '{$kpi_filter_closing_date_end} 23:59:59'" . " AND do.trans_type = '' AND do.trans_id = " . depot_orders::MANUAL_REFILL_OUTSOURCED . " AND dosh_22.status = 22 AND do.status NOT IN (1, 2, 3, 4, 5, 6, 7, 8, 9)";
        $q .= " GROUP BY item_id";
        $q .= ") dt";
        $q .= " WHERE date_start IS NOT NULL AND date_end IS NOT NULL";
        $dbq = tep_db_query($q);
        while ($r = tep_db_fetch_array($dbq)) {
            //External Levelling Order Type
            $kpi_leadtime_data_c['external-levelling-order'][] = $r;
        }
        //Customer Order (only B2C Sales Partner)
        $q = " SELECT * FROM";
        $q .= " (";
        $q .= " SELECT 'sp' AS sp_type, joi.jng_sp_orders_items_id AS item_id, joi.order_quantity AS quantity" . ", MIN(joish_1.status_date) AS date_start, MAX(joish_9.status_date) AS date_end, joi.mode";
        $q .= " FROM jng_sp_orders_items_status_history joish_9" . " LEFT JOIN jng_sp_orders_items joi ON joi.jng_sp_orders_items_id = joish_9.jng_sp_orders_items_id" . " INNER JOIN jng_sp_orders jo ON jo.jng_sp_orders_id = joi.jng_sp_orders_id" . " LEFT JOIN jng_sp_orders_items_status_history joish_1 ON joish_1.jng_sp_orders_items_id = joi.jng_sp_orders_items_id" . " AND joish_1.status = 1";
        $q .= " WHERE joish_9.status_date >= '{$kpi_filter_closing_date_start} 00:00:00'" . " AND joish_9.status_date <= '{$kpi_filter_closing_date_end} 23:59:59'" . " AND joish_9.status = 9 AND joi.status NOT IN (1, 2, 3, 4, 5, 6, 7, 8)" . " AND jo.jng_sp_id NOT IN (" . implode(',', $sp_b2b) . ")";
        $q .= " GROUP BY sp_type, item_id";
        $q .= " UNION";
        $q .= " SELECT 'jg' AS sp_type, op.orders_products_id AS item_id, op.products_quantity AS quantity" . ", MIN(opsh_1.status_date) AS date_start, MAX(opsh_9.status_date) AS date_end, op.mode";
        $q .= " FROM orders_products_status_history opsh_9" . " LEFT JOIN orders_products op ON op.orders_products_id = opsh_9.orders_products_id" . " LEFT JOIN orders_products_status_history opsh_1 ON opsh_1.orders_products_id = op.orders_products_id" . " AND opsh_1.status = 1";
        $q .= " WHERE opsh_9.status_date >= '{$kpi_filter_closing_date_start} 00:00:00'" . " AND opsh_9.status_date <= '{$kpi_filter_closing_date_end} 23:59:59'" . " AND opsh_9.status = 9 AND op.status NOT IN (1, 2, 3, 4, 5, 6, 7, 8)";
        $q .= " GROUP BY sp_type, item_id";
        $q .= " UNION";
        $q .= " SELECT 'dp' AS sp_type, do.depot_orders_id AS item_id, do.quantity" . ", MIN(dosh_1.update_time) AS date_start, MAX(dosh_9.update_time) AS date_end, '' AS mode";
        $q .= " FROM depot_orders_status_history dosh_9" . " LEFT JOIN depot_orders do ON do.depot_orders_id = dosh_9.depot_orders_id" . " LEFT JOIN depot_orders_status_history dosh_1 ON dosh_1.depot_orders_id = do.depot_orders_id" . " AND dosh_1.status = 1";
        $q .= " WHERE dosh_9.update_time >= '{$kpi_filter_closing_date_start} 00:00:00'" . " AND dosh_9.update_time <= '{$kpi_filter_closing_date_end} 23:59:59'" . " AND dosh_9.status = 9 AND do.status NOT IN (1, 2, 3, 4, 5, 6, 7, 8)";
        $q .= " GROUP BY sp_type, item_id";
        $q .= ") dt";
        $q .= " WHERE date_start IS NOT NULL AND date_end IS NOT NULL";
        $dbq = tep_db_query($q);
        while ($r = tep_db_fetch_array($dbq)) {
            if ($r['mode'] == 1) {
                //Full DSO Order Type
                $kpi_leadtime_data_c['full-dso'][] = $r;
            } elseif ($r['mode'] == 2 || $r['mode'] == 3 || $r['mode'] == 4) {
                $kpi_leadtime_data_c['mto'][] = $r;
            }
        }
        //Design
        $q = " SELECT d.designs_category, 1 AS quantity, d.designs_id AS item_id" . ", FROM_UNIXTIME(MIN(dsh_2.status_time)) AS date_start" . ", FROM_UNIXTIME(MAX(dsh_9.status_time)) AS date_end";
        $q .= " FROM designs_status_history dsh_9 " . " LEFT JOIN designs d ON d.designs_id = dsh_9.designs_id" . " LEFT JOIN designs_status_history dsh_2 ON dsh_2.designs_id = d.designs_id AND dsh_2.status = 2";
        $q .= " WHERE dsh_9.status_time >= " . strtotime($kpi_filter_closing_date_start . " 00:00:00") . " AND dsh_9.status_time <= " . strtotime($kpi_filter_closing_date_end . " 23:59:59") . " AND dsh_9.status = 9 AND d.status = 9";
        $q .= " GROUP BY d.designs_id";
        $dbq = tep_db_query($q);
        while ($r = tep_db_fetch_array($dbq)) {
            $kpi_leadtime_data_c["design-{$r['designs_category']}"][] = $r;
        }
    }
    $today = date('d-m-Y');
    if ($kpi_status == 'c') {
        $kpi_leadtime_data = $kpi_leadtime_data_c;
    } else {
        $kpi_leadtime_data = $kpi_leadtime_data_o;
    }
    $leadtime_arr = array();
    foreach ($kpi_leadtime_data as $order_type => $klds) {
        //klds: kpi leadtime datas
        foreach ($klds as $kld) {
            $lsd = $kld['date_start'];
            $led = $kpi_status == 'o' ? $today : $kld['date_end'];
            $qty = $kld['quantity'];
            $datediff_sec = strtotime($led) - strtotime($lsd);
            $leadtime = ceil($datediff_sec / 3600 / 24);
            //in days format (round up)
            $leadtime_arr[$order_type][] = $leadtime;
            $target = $target_leadtime[$order_type];
            $total[$order_type] += $qty;
            if ($leadtime < $target) {
                $below_target[$order_type] += $qty;
            } elseif ($leadtime == $target) {
                $on_target[$order_type] += $qty;
            } elseif ($leadtime > $target + 3) {
                $above_target_gt3d[$order_type] += $qty;
            } else {
                $above_target_1to3d[$order_type] += $qty;
            }
        }
        $leadtime_avg[$order_type] = count($leadtime_arr[$order_type]) > 0 ? number_format(array_sum($leadtime_arr[$order_type]) / count($leadtime_arr[$order_type]), 2) : '-';
        $leadtime_median[$order_type] = median($leadtime_arr[$order_type], 2);
    }
    //DRAW KPI LEADTIME TABLE
    $tooltip_info_saved = ' title="press enter to save changes" ';
    $border_dotted_bottom = 'border-bottom:1px dotted #ccc; ';
    $border_dotted_right = 'border-right:1px dotted #ccc; ';
    $kpi_lead = '<h3>' . ($kpi_status == 'o' ? 'Lead time of currently open orders/process (' . date('d.m.Y') . ')' : 'Lead time of orders with closing date from ' . date('d.m.Y', strtotime($kpi_closing_date_start)) . ' to ' . date('d.m.Y', strtotime($kpi_closing_date_end))) . '</h3>';
    $kpi_lead .= '<table class="spo" cellspacing="0" cellpadding="0">';
    $kpi_lead .= '<thead>';
    $kpi_lead .= '<tr class="o">';
    $kpi_lead .= '<th class="i" colspan="2" style="' . $border_dotted_bottom . $border_dotted_right . '">Running Lead Time / Lead Time</th>';
    $kpi_lead .= '<th class="r" rowspan="2" style="' . $border_dotted_right . '">Target Lead Time<br/>in Days</th>';
    $kpi_lead .= '<th class="d" rowspan="2" style="' . $border_dotted_right . '">Below Target</th>';
    $kpi_lead .= '<th class="d" rowspan="2" style="' . $border_dotted_right . '">On Target</th>';
    $kpi_lead .= '<th class="r" rowspan="2" style="' . $border_dotted_right . '">Above Target<br/>1 to 3 days</th>';
    $kpi_lead .= '<th class="r" rowspan="2" style="' . $border_dotted_right . '">Above Target<br/>&gt; 3 days</th>';
    $kpi_lead .= '<th class="r" rowspan="2" style="' . $border_dotted_right . '">Total<br/>(based on Qty)</th>';
    $kpi_lead .= '<th class="r" rowspan="2" style="' . $border_dotted_right . '">Lead Time<br/>Average in Days</th>';
    $kpi_lead .= '<th class="r" rowspan="2">Lead Time<br/>Median in Days</th>';
    $kpi_lead .= '</tr>';
    $kpi_lead .= '<tr>';
    $kpi_lead .= '<th style="' . $border_dotted_right . '">Category</th>';
    $kpi_lead .= '<th style="' . $border_dotted_right . '">Order Type</th>';
    $kpi_lead .= '</tr>';
    $kpi_lead .= '</thead>';
    $kpi_lead .= '<tbody>';
    //Sourcing
    $kpi_lead .= '<tr class="e">';
    $kpi_lead .= '<td><strong>Sourcing</strong></td>';
    $kpi_lead .= '<td>Sourcing</td>';
    $kpi_lead .= '<td class="tac"><input type="text" class="target_leadtime w040 tac" name="lt-sourcing" value="' . $target_leadtime['sourcing'] . '"' . $tooltip_info_saved . '/></td>';
    $kpi_lead .= '<td class="tac">' . $below_target['sourcing'] . '<br/>' . kpiFormatPercentage($total['sourcing'], $below_target['sourcing']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $on_target['sourcing'] . '<br/>' . kpiFormatPercentage($total['sourcing'], $on_target['sourcing']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $above_target_1to3d['sourcing'] . '<br/>' . kpiFormatPercentage($total['sourcing'], $above_target_1to3d['sourcing']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $above_target_gt3d['sourcing'] . '<br/>' . kpiFormatPercentage($total['sourcing'], $above_target_gt3d['sourcing']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $total['sourcing'] . '<br/>' . kpiFormatPercentage($total['sourcing'], $total['sourcing']) . '</td>';
    $kpi_lead .= '<td class="tac">' . (isset($leadtime_avg['sourcing']) ? $leadtime_avg['sourcing'] : 'N/A') . '</td>';
    $kpi_lead .= '<td class="tac">' . (isset($leadtime_median['sourcing']) ? $leadtime_median['sourcing'] : 'N/A') . '</td>';
    $kpi_lead .= '</tr>';
    //Production
    $kpi_lead .= '<tr class="o">';
    $kpi_lead .= '<td rowspan="3"><strong>Production</strong></td>';
    $kpi_lead .= '<td>Depot Refill Orders</td>';
    $kpi_lead .= '<td class="tac"><input type="text" class="target_leadtime w040 tac" name="lt-depot-refill-orders" value="' . $target_leadtime['depot-refill-orders'] . '"' . $tooltip_info_saved . '/></td>';
    $kpi_lead .= '<td class="tac">' . $below_target['depot-refill-orders'] . '<br/>' . kpiFormatPercentage($total['depot-refill-orders'], $below_target['depot-refill-orders']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $on_target['depot-refill-orders'] . '<br/>' . kpiFormatPercentage($total['depot-refill-orders'], $on_target['depot-refill-orders']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $above_target_1to3d['depot-refill-orders'] . '<br/>' . kpiFormatPercentage($total['depot-refill-orders'], $above_target_1to3d['depot-refill-orders']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $above_target_gt3d['depot-refill-orders'] . '<br/>' . kpiFormatPercentage($total['depot-refill-orders'], $above_target_gt3d['depot-refill-orders']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $total['depot-refill-orders'] . '<br/>' . kpiFormatPercentage($total['depot-refill-orders'], $total['depot-refill-orders']) . '</td>';
    $kpi_lead .= '<td class="tac">' . (isset($leadtime_avg['depot-refill-orders']) ? $leadtime_avg['depot-refill-orders'] : 'N/A') . '</td>';
    $kpi_lead .= '<td class="tac">' . (isset($leadtime_median['depot-refill-orders']) ? $leadtime_median['depot-refill-orders'] : 'N/A') . '</td>';
    $kpi_lead .= '</tr>';
    $kpi_lead .= '<tr class="o">';
    $kpi_lead .= '<td>Internal Levelling Orders</td>';
    $kpi_lead .= '<td class="tac"><input type="text" class="target_leadtime w040 tac" name="lt-internal-levelling-orders" value="' . $target_leadtime['internal-levelling-orders'] . '"' . $tooltip_info_saved . '/></td>';
    $kpi_lead .= '<td class="tac">' . $below_target['internal-levelling-orders'] . '<br/>' . kpiFormatPercentage($total['internal-levelling-orders'], $below_target['internal-levelling-orders']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $on_target['internal-levelling-orders'] . '<br/>' . kpiFormatPercentage($total['internal-levelling-orders'], $on_target['internal-levelling-orders']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $above_target_1to3d['internal-levelling-orders'] . '<br/>' . kpiFormatPercentage($total['internal-levelling-orders'], $above_target_1to3d['internal-levelling-orders']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $above_target_gt3d['internal-levelling-orders'] . '<br/>' . kpiFormatPercentage($total['internal-levelling-orders'], $above_target_gt3d['internal-levelling-orders']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $total['internal-levelling-orders'] . '<br/>' . kpiFormatPercentage($total['internal-levelling-orders'], $total['internal-levelling-orders']) . '</td>';
    $kpi_lead .= '<td class="tac">' . (isset($leadtime_avg['internal-levelling-orders']) ? $leadtime_avg['internal-levelling-orders'] : 'N/A') . '</td>';
    $kpi_lead .= '<td class="tac">' . (isset($leadtime_median['internal-levelling-orders']) ? $leadtime_median['internal-levelling-orders'] : 'N/A') . '</td>';
    $kpi_lead .= '</tr>';
    $kpi_lead .= '<tr class="o">';
    $kpi_lead .= '<td>Customer Orders (MTO/MMO)</td>';
    $kpi_lead .= '<td class="tac"><input type="text" class="target_leadtime w040 tac" name="lt-cust-order-mto-mmo" value="' . $target_leadtime['cust-order-mto-mmo'] . '"' . $tooltip_info_saved . '/></td>';
    $kpi_lead .= '<td class="tac">' . $below_target['cust-order-mto-mmo'] . '<br/>' . kpiFormatPercentage($total['cust-order-mto-mmo'], $below_target['cust-order-mto-mmo']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $on_target['cust-order-mto-mmo'] . '<br/>' . kpiFormatPercentage($total['cust-order-mto-mmo'], $on_target['cust-order-mto-mmo']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $above_target_1to3d['cust-order-mto-mmo'] . '<br/>' . kpiFormatPercentage($total['cust-order-mto-mmo'], $above_target_1to3d['cust-order-mto-mmo']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $above_target_gt3d['cust-order-mto-mmo'] . '<br/>' . kpiFormatPercentage($total['cust-order-mto-mmo'], $above_target_gt3d['cust-order-mto-mmo']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $total['cust-order-mto-mmo'] . '<br/>' . kpiFormatPercentage($total['cust-order-mto-mmo'], $total['cust-order-mto-mmo']) . '</td>';
    $kpi_lead .= '<td class="tac">' . (isset($leadtime_avg['cust-order-mto-mmo']) ? $leadtime_avg['cust-order-mto-mmo'] : 'N/A') . '</td>';
    $kpi_lead .= '<td class="tac">' . (isset($leadtime_median['cust-order-mto-mmo']) ? $leadtime_median['cust-order-mto-mmo'] : 'N/A') . '</td>';
    $kpi_lead .= '</tr>';
    //Outsourcing
    $kpi_lead .= '<tr class="e">';
    $kpi_lead .= '<td><strong>Outsourcing</strong></td>';
    $kpi_lead .= '<td>External Levelling Orders</td>';
    $kpi_lead .= '<td class="tac"><input type="text" class="target_leadtime w040 tac" name="lt-external-levelling-order" value="' . $target_leadtime['external-levelling-order'] . '"' . $tooltip_info_saved . '/></td>';
    $kpi_lead .= '<td class="tac">' . $below_target['external-levelling-order'] . '<br/>' . kpiFormatPercentage($total['external-levelling-order'], $below_target['external-levelling-order']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $on_target['external-levelling-order'] . '<br/>' . kpiFormatPercentage($total['external-levelling-order'], $on_target['external-levelling-order']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $above_target_1to3d['external-levelling-order'] . '<br/>' . kpiFormatPercentage($total['external-levelling-order'], $above_target_1to3d['external-levelling-order']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $above_target_gt3d['external-levelling-order'] . '<br/>' . kpiFormatPercentage($total['external-levelling-order'], $above_target_gt3d['external-levelling-order']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $total['external-levelling-order'] . '<br/>' . kpiFormatPercentage($total['external-levelling-order'], $total['external-levelling-order']) . '</td>';
    $kpi_lead .= '<td class="tac">' . (isset($leadtime_avg['external-levelling-order']) ? $leadtime_avg['external-levelling-order'] : 'N/A') . '</td>';
    $kpi_lead .= '<td class="tac">' . (isset($leadtime_median['external-levelling-order']) ? $leadtime_median['external-levelling-order'] : 'N/A') . '</td>';
    $kpi_lead .= '</tr>';
    //Customer Order
    $kpi_lead .= '<tr class="o">';
    $kpi_lead .= '<td rowspan="2"><strong>Customer Order</strong></td>';
    $kpi_lead .= '<td>Full DSO</td>';
    $kpi_lead .= '<td class="tac"><input type="text" class="target_leadtime w040 tac" name="lt-full-dso" value="' . $target_leadtime['full-dso'] . '"' . $tooltip_info_saved . '/></td>';
    $kpi_lead .= '<td class="tac">' . $below_target['full-dso'] . '<br/>' . kpiFormatPercentage($total['full-dso'], $below_target['full-dso']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $on_target['full-dso'] . '<br/>' . kpiFormatPercentage($total['full-dso'], $on_target['full-dso']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $above_target_1to3d['full-dso'] . '<br/>' . kpiFormatPercentage($total['full-dso'], $above_target_1to3d['full-dso']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $above_target_gt3d['full-dso'] . '<br/>' . kpiFormatPercentage($total['full-dso'], $above_target_gt3d['full-dso']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $total['full-dso'] . '<br/>' . kpiFormatPercentage($total['full-dso'], $total['full-dso']) . '</td>';
    $kpi_lead .= '<td class="tac">' . (isset($leadtime_avg['full-dso']) ? $leadtime_avg['full-dso'] : 'N/A') . '</td>';
    $kpi_lead .= '<td class="tac">' . (isset($leadtime_median['full-dso']) ? $leadtime_median['full-dso'] : 'N/A') . '</td>';
    $kpi_lead .= '</tr>';
    $kpi_lead .= '<tr class="o">';
    $kpi_lead .= '<td>MTO (Full MTO and Mixed Orders)</td>';
    $kpi_lead .= '<td class="tac"><input type="text" class="target_leadtime w040 tac" name="lt-mto" value="' . $target_leadtime['mto'] . '"' . $tooltip_info_saved . '/></td>';
    $kpi_lead .= '<td class="tac">' . $below_target['mto'] . '<br/>' . kpiFormatPercentage($total['mto'], $below_target['mto']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $on_target['mto'] . '<br/>' . kpiFormatPercentage($total['mto'], $on_target['mto']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $above_target_1to3d['mto'] . '<br/>' . kpiFormatPercentage($total['mto'], $above_target_1to3d['mto']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $above_target_gt3d['mto'] . '<br/>' . kpiFormatPercentage($total['mto'], $above_target_gt3d['mto']) . '</td>';
    $kpi_lead .= '<td class="tac">' . $total['mto'] . '<br/>' . kpiFormatPercentage($total['mto'], $total['mto']) . '</td>';
    $kpi_lead .= '<td class="tac">' . (isset($leadtime_avg['mto']) ? $leadtime_avg['mto'] : 'N/A') . '</td>';
    $kpi_lead .= '<td class="tac">' . (isset($leadtime_median['mto']) ? $leadtime_median['mto'] : 'N/A') . '</td>';
    $kpi_lead .= '</tr>';
    //Design
    $kpi_lead .= '<tr class="e">';
    $kpi_lead .= '<td rowspan="' . count($design_categories) . '"><strong>Design</strong></td>';
    $des_cat_id_counter = 0;
    foreach ($design_categories as $des_cat_id => $des_cat_name) {
        $des_cat_id_counter++;
        if ($des_cat_id_counter > 1) {
            $kpi_lead .= '<tr class="e">';
        }
        $design_order_type = "design-{$des_cat_id}";
        $kpi_lead .= "<td>{$des_cat_name}</td>";
        $kpi_lead .= '<td class="tac"><input type="text" class="target_leadtime w040 tac" name="lt-design-' . $des_cat_id . '" value="' . $target_leadtime[$design_order_type] . '"' . $tooltip_info_saved . '/></td>';
        $kpi_lead .= '<td class="tac">' . $below_target[$design_order_type] . '<br/>' . kpiFormatPercentage($total[$design_order_type], $below_target[$design_order_type]) . '</td>';
        $kpi_lead .= '<td class="tac">' . $on_target[$design_order_type] . '<br/>' . kpiFormatPercentage($total[$design_order_type], $on_target[$design_order_type]) . '</td>';
        $kpi_lead .= '<td class="tac">' . $above_target_1to3d[$design_order_type] . '<br/>' . kpiFormatPercentage($total[$design_order_type], $above_target_1to3d[$design_order_type]) . '</td>';
        $kpi_lead .= '<td class="tac">' . $above_target_gt3d[$design_order_type] . '<br/>' . kpiFormatPercentage($total[$design_order_type], $above_target_gt3d[$design_order_type]) . '</td>';
        $kpi_lead .= '<td class="tac">' . $total[$design_order_type] . '<br/>' . kpiFormatPercentage($total[$design_order_type], $total[$design_order_type]) . '</td>';
        $kpi_lead .= '<td class="tac">' . (isset($leadtime_avg[$design_order_type]) ? $leadtime_avg[$design_order_type] : 'N/A') . '</td>';
        $kpi_lead .= '<td class="tac">' . (isset($leadtime_median[$design_order_type]) ? $leadtime_median[$design_order_type] : 'N/A') . '</td>';
        $kpi_lead .= '</tr>';
    }
    $kpi_lead .= '</tbody>';
    $kpi_lead .= '</table>';
    return $kpi_lead;
}
tep_db_connect();
$eao = 2;
//element adjust order
use_class('design');
use_class('elements_preorder');
use_class('elements_order');
use_class('elements_stock');
use_class('products_articles');
use_class('products_minierp');
$class_es = new elements_stock();
$class_pm = new products_minierp();
$class_pa = new products_articles();
$ean_eu_collection = array();
$max_el_per_article = 0;
$use_elements = array();
$class_d = new design($_GET['d']);
$products = $class_d->retrieveProducts();
foreach ($products as $p) {
    $query_products_categories = "SELECT * FROM products_to_categories ptc WHERE products_id={$p['products_id']}";
    $tpdbq_products_categories = tep_db_query($query_products_categories);
    $products_categories = tep_db_fetch_array($tpdbq_products_categories);
    // find what use element in this product
    $ean_eu_collection[$p['products_id'] . '-0'] = '';
    $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);
        $ean_eu_collection[$p['products_id'] . '-0'] .= $row_pue['elements_id'] . ' x ' . $row_pue['quantity'] . '|';
    }
    $mepa = count($tpdbq_products_use_elements);
    if ($mepa > $max_el_per_article) {
        $max_el_per_article = $mepa;
Ejemplo n.º 8
0
         }
         $draft->uploadImage($imgno, $image['tmp_name'], $image['name']);
         $result['result'] = webImage($draft->{'image_' . $imgno}, $thumbsize, $thumbsize, $draft_title, 'img-border');
     }
     $result['drafts_id'] = $draft->id;
     $result['draft_key'] = $draft_key;
     $result['prevdraft'] = count($drafts);
     $result['box_colors'] = drawBoxColor($draft->colors_request);
     $result['colors_added'] = getColorNumbers($draft->colors_request);
     echo ajaxReturn($result);
     exit;
 } elseif ($_POST['me_action'] == 'DELETEDRAFT') {
     $drafts_id = tep_db_prepare_input($_POST['drafts_id']);
     $draft_key = tep_db_prepare_input($_POST['draft_key']);
     $draft = new design_draft($drafts_id);
     $design = new design($draft->designs_id);
     $draft->delete();
     $drafts = $design->retrieveDrafts();
     $result = array();
     $result['drafts_id'] = $drafts_id;
     $result['draft_key'] = $draft_key;
     $result['total_drafts'] = count($drafts);
     $result['image'] = webImage($draft->image_1, $imgsize, $imgsize, $draft_title);
     echo ajaxReturn($result);
     exit;
 } elseif ($_POST['me_action'] == 'UPDATEDRAFTNAME') {
     $drafts_id = tep_db_prepare_input($_POST['drafts_id']);
     $draft_name = tep_db_prepare_input($_POST['draft_name']);
     $draft_namekey = tep_db_prepare_input($_POST['draft_namekey']);
     $draft = new design_draft($drafts_id);
     $draft->update($draft_name);
Ejemplo n.º 9
0
function user_has_admin_right(&$menu, $sl = true)
{
    if ($_SESSION['authright'] <= -8) {
        // co leader...
        return true;
    } else {
        $uri_to_check1 = $menu->get(0);
        $uri_to_check2 = $menu->get(1);
        if (count($_SESSION['authmod']) < 1 or !loggedin()) {
            if ($sl === true) {
                if (!loggedin()) {
                    $design = new design('', '', 0);
                    $menu->set_url(0, 'user');
                    load_modul_lang();
                    $tpl = new tpl('user/login.htm');
                    $design->addheader($tpl->get(0));
                    $design->header();
                    $tpl->set_out('WDLINK', 'admin.php', 1);
                    $design->footer();
                } else {
                    echo '<strong>Keine Berechtigung!</strong> <a href="index.php">Startseite</a>';
                }
            }
            return false;
        } elseif (isset($_SESSION['authmod'][$uri_to_check1]) and $_SESSION['authmod'][$uri_to_check1] == true or isset($_SESSION['authmod'][$uri_to_check1 . '-' . $uri_to_check2]) and $_SESSION['authmod'][$uri_to_check1 . '-' . $uri_to_check2] == true) {
            return true;
        } elseif (count($_SESSION['authmod']) > 0 and loggedin()) {
            if ($sl === true) {
                foreach ($_SESSION['authmod'] as $k => $v) {
                    $x = $k;
                    break;
                }
                $x = explode('-', $x);
                $menu->set_url(0, $x[0]);
                if (isset($x[1])) {
                    $menu->set_url(1, $x[1]);
                }
            }
            return true;
        }
    }
    return false;
}
Ejemplo n.º 10
0
                 case 'drafts':
                     $img_title = 'Draft ' . $row['designs_id'];
                     $des_title[] = 'Design ' . $row['designs_id'];
                     $des_title[] = $img_title;
                     $des_title[] = "";
                     $image = $row['draft_image'] == '' ? $row['designs_image_2'] == '' ? $row['designs_image_1'] : $row['designs_image_2'] : $row['draft_image'];
                     break;
                 case 'products':
                     $img_title = 'Product ' . $row['products_id'];
                     $des_title[] = 'Design ' . $row['designs_id'];
                     $des_title[] = 'Draft ' . $row['drafts_id'];
                     $des_title[] = $img_title;
                     $image = $row['products_image'] == '' ? $row['draft_image'] == '' ? $row['designs_image_2'] == '' ? $row['designs_image_1'] : $row['designs_image_2'] : $row['draft_image'] : $row['products_image'];
                     break;
             }
             $des_title[] = '<strong>"' . design::getDesignStatus($row['status']) . '"</strong>';
             $designs .= '<div class="pro-thumb" style="height:150px;">';
             $designs .= '<div>' . webImage($image, IMAGE_SIZE_THUMBNAIL_1, IMAGE_SIZE_THUMBNAIL_1, $img_title) . '</div>';
             //$designs .= '<div class="text">'.$img_title.'</div>';
             $designs .= '<div class="text">' . implode('<br />', $des_title) . '</div>';
             $designs .= '</div>';
         }
     }
 } else {
     $designs_total = 0;
 }
 $content .= '<div id="product-style">';
 $content .= '<ul>';
 $content .= '<li><a href="#prostyle-tab1"><span>Attribute Detail</span></a></li>';
 if ($styles_id != '0') {
     $content .= '<li><a href="#prostyle-tab2"><span>List of Products (' . $products_total . ')</span></a></li>';
Ejemplo n.º 11
0
    public function get_url($w = '')
    {
        global $allgAr;
        if ($w != '') {
            $this->type = $w;
        }
        // startwert und pfad zum pruefen raustuefteln.
        if ($this->type == 'contents') {
            $pfad = 'include/contents';
            $smod = $allgAr['smodul'];
        } elseif ($this->type == 'box') {
            $file = 'include/boxes/' . $this->get(0) . '.php';
            return (file_exists($file) and $this->check_rights()) ? $file : false;
        } else {
            $pfad = 'include/admin';
            $smod = 'admin';
        }
        // wennes also leer is wird das startmodul genommen
        if (empty($this->menu_ar[0])) {
            $this->set_url(0, $smod);
        }
        // diverse sachen geprueft zum zurueck geben,
        // is halt so dings wegen selfpages usw...
        if (!file_exists($pfad . '/' . $this->get(0) . '.php') and file_exists($pfad . '/selfbp/selfp/' . $this->get(0) . '.php')) {
            $this->set_url(1, $this->get(0));
            $this->set_url(0, 'self');
        } elseif (!file_exists($pfad . '/' . $this->get(0) . '.php')) {
            if (substr($smod, 0, 5) == 'self-') {
                $this->set_url(1, substr($smod, 5));
                $this->set_url(0, 'self');
            } elseif (file_exists($pfad . '/selfbp/selfp/' . $smod . '.php')) {
                $this->set_url(1, $smod);
                $this->set_url(0, 'self');
            } else {
                $this->set_url(0, $smod);
            }
        }
        // pruefen ob der client die noetigen rechte hat
        // das modul zu sehen.. bzw. den menupunkt zu sehen
        $exit = !$this->check_rights();
        // das usermodul kann aus eigener sicherheit nicht
        // gesperrt werden, sonst koennen sich member
        // usw. nicht mehr einloggen, bzw. es kann
        // sich sonst keiner registrieren. deshalb is das
        // user modul immer frei geschaltet
        $alwaysallowed = array('regist', 'login', '1', '2', 'confirm', 'remind', '13', '3', 'logout');
        if ($exit === true and $this->get(0) == 'user' and in_array($this->get(1), $alwaysallowed)) {
            $exit = false;
            debug('o');
        }
        if ($exit) {
            $title = $allgAr['title'] . ' :: Keine Berechtigung';
            $hmenu = 'Keine Berechtigung';
            $design = new design($title, $hmenu);
            if (loggedin()) {
                $design->header();
                if (is_coadmin()) {
                    echo 'Entweder diese Seite ist nicht in der Navigation verlinkt und die Option
<strong>Zugriff auf nicht im Menü verlinkte Module für alle?</strong> steht auf <strong>nein</strong> oder aber du hast kein Recht sie zu betrachten, deswegen kommt diese Meldung.<br />
Also entweder die Seite <strong>' . $this->get(0) . '</strong> in der <a href="admin.php?menu">Navigation</a> verlinken, oder die Option umstellen, ersteres wird empfohlen.';
                } else {
                    echo 'Du hast leider nicht die n&ouml;tigen Rechte, um diese Seite zu betrachten.';
                }
            } else {
                $tpl = new tpl('user/login');
                $design->addheader($tpl->get(0));
                $design->header();
                $tpl->set_out('WDLINK', 'index.php', 1);
            }
            $design->footer();
            exit;
        }
        return $this->get(0) . '.php';
    }
Ejemplo n.º 12
0
<?php

use_class('design');
if (isset($_GET['imagelimit'])) {
    $messagebox->add('File is too big, max width/height allowed is ' . $_GET['imagelimit'] . 'px');
}
if (isset($_GET['imageupload']) && $_GET['imageupload'] == 'none') {
    $messagebox->add('Please upload an image to create New Design');
}
$design = new design();
if (isset($_GET['cat']) && $_GET['cat'] == 'R') {
    $design->category = 'R';
    $content .= '<form name="newdesign" method="post" action="?open=designs-detail" enctype="multipart/form-data">';
    $content .= '<input type="hidden" name="me_action" value="CREATENEWDESIGN" />';
    $content .= '<input type="hidden" name="status" value="5" />';
    $messagebox->add('<strong>This Design will be created directly in SAMPLINGS Tab</strong>');
    $content .= $design->drawDetailTable();
    $submit = '<input id="create" type="button" value="Create Design" />';
    $content .= '<div class="buttons" style="width:390px;">' . $submit . '</div>';
    $content .= '</form>';
    $javscript .= $design->drawDetailTableJSRule('create', 'newdesign');
} else {
    $content .= '<div class="box ui-corner-all" style="margin-bottom:20px;">';
    $content .= '<h2>Any Design Categories with New Image</h2>';
    $content .= '<form name="newdesign" method="post" action="?open=designs-detail" enctype="multipart/form-data">';
    $content .= '<input type="hidden" name="me_action" value="CREATENEWDESIGN" />';
    $content .= '<div><table class="form" border="0" cellpadding="0" cellspacing="0">';
    $content .= '<tr><td class="label">Design Image</td><td><input type="file" name="image_1" /></td></tr>';
    $content .= '<tr><td class="label">Source of Idea</td><td><input type="text" id="source_of_ideas" name="source_of_ideas" style="width:100%;" disabled="disabled"/></td></tr>';
    $content .= '</table></div>';
    $content .= '<div class="buttons" style="width:410px;"><input type="submit" value="Create Design" /></div>';
Ejemplo n.º 13
0
function drawKPItable($kpi_title, $kpi_date = '', $hidetable = false)
{
    global $design;
    use_class('products_minierp');
    $class_pm = new products_minierp();
    $bgst = $class_pm->retrieveBestGoodSettings();
    $kpi_data = array();
    $kpi_target = array();
    $descats = array();
    $descat_count = array();
    $descat_percent = array();
    $kpi_type1 = in_array($kpi_title, array('WIP', 'FIN'));
    //WIP: Work In Progress, FIN: Designs Finalized
    $kpi_type2 = in_array($kpi_title, array('PCATIP', 'PCATF'));
    //PCAT:Products Category >> IP:in Progress, F:Finalized
    $kpi_type3 = in_array($kpi_title, array('PPRIP', 'PPRF'));
    //PPR:Products Price >> IP:in Progress, F:Finalized
    $kpi_type4 = in_array($kpi_title, array('WIPT', 'FINT'));
    //WIPT: Work In Progress Type, FIN: Designs Finalized Type
    $ksd = generateKPISupportData($kpi_title, $kpi_date);
    $q = $ksd['q'];
    $kpi_id = $ksd['kpi_id'];
    $kpi_header = $ksd['kpi_header'];
    $r = tep_db_query($q);
    if ($kpi_type1) {
        $kpi_target['W'] = $bgst['kpides_catnw'];
        $kpi_target['R'] = $bgst['kpides_catr'];
        while ($row = tep_db_fetch_array($r)) {
            $kpi_data[$row['designs_category']] = $row['total_designs'];
        }
        $descats = design::getDesignCategory();
        if (array_key_exists('', $kpi_data)) {
            $descats[''] = '<span class="red">Unset</span>';
        }
    } elseif ($kpi_type2) {
        $kpi_target[2] = $bgst['kpides_prodnl'];
        $kpi_target[3] = $bgst['kpides_prodbl'];
        $kpi_target[4] = $bgst['kpides_proder'];
        $kpi_target[9] = $bgst['kpides_prodch'];
        $kpi_target[28] = $bgst['kpides_prodpn'];
        $kpi_target[29] = $bgst['kpides_prodrg'];
        $kpi_target[30] = $bgst['kpides_prodset'];
        $kpi_target[33] = $bgst['kpides_prodan'];
        while ($row = tep_db_fetch_array($r)) {
            $kpi_data[$row['products_category_id']] = $row['total_designs'];
        }
        $pcs = getProductsCategorySupportData();
        $q = "SELECT {$pcs['field_id']} AS id, {$pcs['field_name']} AS name FROM {$pcs['tables']} WHERE {$pcs['filter']}";
        $dbq = tep_db_query($q);
        while ($r = tep_db_fetch_array($dbq)) {
            $descats_temp[$r['id']] = $r['name'];
        }
        //SORT Product Category as Requested by user
        $descats_sorts = array(4 => 1, 2 => 2, 3 => 3, 29 => 4, 30 => 5, 9 => 6, 28 => 7, 33 => 8, 35 => 9);
        foreach ($descats_temp as $key => $val) {
            $descats_temp2[$descats_sorts[$key]] = $key;
        }
        ksort($descats_temp2);
        foreach ($descats_temp2 as $val) {
            $descats[$val] = $descats_temp[$val];
        }
    } elseif ($kpi_type3) {
        $kpi_target[1] = $bgst['kpides_pr1target'];
        $kpi_target[2] = $bgst['kpides_pr2target'];
        $kpi_target[3] = $bgst['kpides_pr3target'];
        $kpi_target[4] = $bgst['kpides_pr4target'];
        $kpi_target[5] = $bgst['kpides_pr5target'];
        $kpi_target[6] = $bgst['kpides_pr6target'];
        $kpi_target[7] = $bgst['kpides_pr7target'];
        $kpi_target[8] = $bgst['kpides_pr8target'];
        while ($row = tep_db_fetch_array($r)) {
            if ($row['target_price'] >= $bgst['kpides_pr1bgn'] && $row['target_price'] <= $bgst['kpides_pr1end']) {
                $kpi_data[1] += $row['total_designs'];
            } elseif ($row['target_price'] >= $bgst['kpides_pr2bgn'] && $row['target_price'] <= $bgst['kpides_pr2end']) {
                $kpi_data[2] += $row['total_designs'];
            } elseif ($row['target_price'] >= $bgst['kpides_pr3bgn'] && $row['target_price'] <= $bgst['kpides_pr3end']) {
                $kpi_data[3] += $row['total_designs'];
            } elseif ($row['target_price'] >= $bgst['kpides_pr4bgn'] && $row['target_price'] <= $bgst['kpides_pr4end']) {
                $kpi_data[4] += $row['total_designs'];
            } elseif ($row['target_price'] >= $bgst['kpides_pr5bgn'] && $row['target_price'] <= $bgst['kpides_pr5end']) {
                $kpi_data[5] += $row['total_designs'];
            } elseif ($row['target_price'] >= $bgst['kpides_pr6bgn'] && $row['target_price'] <= $bgst['kpides_pr6end']) {
                $kpi_data[6] += $row['total_designs'];
            } elseif ($row['target_price'] >= $bgst['kpides_pr7bgn'] && $row['target_price'] <= $bgst['kpides_pr7end']) {
                $kpi_data[7] += $row['total_designs'];
            } elseif ($row['target_price'] > $bgst['kpides_pr8bgn']) {
                $kpi_data[8] += $row['total_designs'];
            }
        }
        $descats[1] = "{$bgst['kpides_pr1bgn']} - {$bgst['kpides_pr1end']}";
        $descats[2] = "{$bgst['kpides_pr2bgn']} - {$bgst['kpides_pr2end']}";
        $descats[3] = "{$bgst['kpides_pr3bgn']} - {$bgst['kpides_pr3end']}";
        $descats[4] = "{$bgst['kpides_pr4bgn']} - {$bgst['kpides_pr4end']}";
        $descats[5] = "{$bgst['kpides_pr5bgn']} - {$bgst['kpides_pr5end']}";
        $descats[6] = "{$bgst['kpides_pr6bgn']} - {$bgst['kpides_pr6end']}";
        $descats[7] = "{$bgst['kpides_pr7bgn']} - {$bgst['kpides_pr7end']}";
        $descats[8] = "&gt;&nbsp;{$bgst['kpides_pr8ge']}";
    } elseif ($kpi_type4) {
        $kpi_target['I'] = $bgst['kpides_typib'];
        $kpi_target['E'] = $bgst['kpides_typeb'];
        $kpi_target['T'] = $bgst['kpides_typth'];
        while ($row = tep_db_fetch_array($r)) {
            $kpi_data[$row['designs_type']] += $row['total_designs'];
        }
        $descats = design::getDesignType();
        if (array_key_exists('', $kpi_data)) {
            $descats[''] = '<span class="red">Unset</span>';
        }
    }
    $descat_count_total = array_sum($kpi_data);
    if (count($descats) > 0) {
        foreach ($descats as $key => $dc) {
            if ($descat_count_total == 0) {
                $descat_count[$key] = 0;
                $descat_percent[$key] = 0;
            } else {
                $descat_count[$key] = !isset($kpi_data[$key]) ? 0 : $kpi_data[$key];
                $descat_percent[$key] = number_format($descat_count[$key] / $descat_count_total * 100, 1);
            }
        }
    }
    $kpi_table = '';
    $kpi_table .= '<div id="' . $kpi_id . '" class="ibox ui-corner-all kpi-box" style="margin:0 0 10px 10px;float:left;' . ($hidetable ? 'display:none;' : '') . '">';
    $kpi_table .= '<input type="hidden" value="' . $kpi_title . '"/>';
    $kpi_table .= '<h3>KPI : ' . $kpi_header . '</h3>';
    $kpi_table .= '<table class="spo" border="0" cellpadding="0" cellspacing="0">';
    $kpi_table .= '<tr><td class="bold">' . (in_array($kpi_title, array('WIPT', 'FINT')) ? 'Type' : 'Category') . '</td><td class="bold" colspan="2" style="white-space:nowrap;">Total Designs</td><td class="bold" style="text-align:right;">Target</td></tr>';
    foreach ($descats as $key => $dc) {
        $kpi_table .= '<tr><td>' . $dc . '</td><td>' . $descat_count[$key] . '</td><td style="text-align:right;">' . $descat_percent[$key] . '%</td><td style="text-align:right;">' . $kpi_target[$key] . '%</td></tr>';
    }
    $kpi_table .= '<tr><td width="100" class="bold">Total Designs</td><td width="20" class="bold">' . $descat_count_total . '</td><td width="50">&nbsp;</td><td width="50">&nbsp;</td></tr>';
    $kpi_table .= '</table></div>';
    return $kpi_table;
}
Ejemplo n.º 14
0
 function get_url($w = 'contents')
 {
     global $allgAr;
     # startwert und pfad zum pruefen raustuefteln.
     if ($w == 'contents') {
         $pfad = 'include/contents';
         $smod = $allgAr['smodul'];
     } else {
         $pfad = 'include/admin';
         $smod = 'admin';
     }
     # wennes also leer is wird das startmodul genommen
     if (empty($this->menu_ar[0])) {
         $this->set_url(0, $smod);
     }
     # diverse sachen geprueft zum zurueck geben,
     # is halt so dings wegen selfpages usw...
     if (!file_exists($pfad . '/' . $this->get(0) . '.php') and file_exists($pfad . '/selfbp/selfp/' . $this->get(0) . '.php')) {
         $this->set_url(1, $this->get(0));
         $this->set_url(0, 'self');
     } elseif (!file_exists($pfad . '/' . $this->get(0) . '.php')) {
         if (substr($smod, 0, 5) == 'self-') {
             $this->set_url(1, substr($smod, 5));
             $this->set_url(0, 'self');
         } elseif (file_exists($pfad . '/selfbp/selfp/' . $smod . '.php')) {
             $this->set_url(1, $smod);
             $this->set_url(0, 'self');
         } else {
             $this->set_url(0, $smod);
         }
     }
     # pruefen ob der client die noetigen rechte hat
     # das modul zu sehen.. bzw. den menupunkt zu sehen
     $exit = false;
     if ($w == 'contents') {
         $where = "(path = '" . $this->get(0) . "' OR path = '" . $this->get(0) . "-" . $this->get(1) . "')";
         if ($this->get(0) == 'self') {
             $where = "(path = '" . $this->get(0) . "-" . $this->get(1) . "' OR path = '" . $this->get(1) . "')";
         }
         $r = @db_result(@db_query("SELECT recht FROM prefix_menu WHERE " . $where . " ORDER BY LENGTH(path) DESC"), 0);
         if ($r != '' and !has_right($r) or $r == '' and $allgAr['allg_menupoint_access'] == 0) {
             $exit = true;
         }
     }
     # das usermodul kann aus eigener sicherheit nicht
     # gesperrt werden, sonst koennen sich member
     # usw. nicht mehr einloggen, bzw. es kann
     # sich sonst keiner registrieren. deshalb is das
     # user modul immer frei geschaltet
     $alwaysallowed = array('regist', 'login', '1', '2', 'confirm', 'remind', '13', '3', 'logout');
     if ($exit === true and $this->get(0) == 'user' and in_array($this->get(1), $alwaysallowed)) {
         $exit = false;
         debug('o');
     }
     if ($exit) {
         $title = $allgAr['title'] . ' :: Keine Berechtigung';
         $hmenu = 'Keine Berechtigung';
         $design = new design($title, $hmenu);
         $design->header();
         if (loggedin()) {
             echo 'Du hast leider nicht die n&ouml;tigen Rechte... :-S';
         } else {
             $tpl = new tpl('user/login');
             $tpl->set_out('WDLINK', 'index.php', 0);
         }
         $design->footer();
         exit;
     }
     return $this->get(0) . '.php';
 }
Ejemplo n.º 15
0
session_name('sid');
session_start();
// Datenbankverbindung aufbauen und Funktionen und Klassen laden
require_once 'include/includes/config.php';
require_once 'include/includes/loader.php';
// Allgemeiner Konfig-Array
$allgAr = getAllgAr();
// Menu, Nutzerverwaltung und Seitenstatistik laden
$menu = new menu();
$m = $menu->get_complete();
user_identification($m);
// Sprachdateien oeffnen
load_global_lang();
load_modul_lang();
//Ajaxreload für Boxen
design::ajax_boxload();
site_statistic();
// Wartungsmodus
if ($allgAr['wartung'] == 1) {
    if (is_admin()) {
        @define('DEBUG', true);
        debug('Wartungsmodus aktiv !');
    } else {
        die($allgAr['wartungstext']);
    }
}
/* ENTWICKLUNGSVERSION SQL UPDATES */
require_once 'update/update.php';
// Modul oeffnen
require_once 'include/contents/' . $menu->get_url();
// Datenbank schließen
Ejemplo n.º 16
0
    $design->header($load);
    $tpl = new tpl('forum/newtopic');
    $name = '';
    if (!loggedin()) {
        $name = '<tr><td class="Cmite"0><b>' . $lang['name'] . '</b></td>';
        $name .= '<td class="Cnorm"><input type="text" value="' . unescape($xnn) . '" maxlength="15" name="Gname"></td></tr>';
    }
    if (isset($_POST['priview'])) {
        $tpl->set_out('txt', bbcode(unescape($txt)), 0);
    }
    $ar = array('name' => $name, 'txt' => escape_for_fields(unescape($txt)), 'topic' => escape_for_fields(unescape($topic)), 'fid' => $fid, 'SMILIES' => getsmilies(), 'antispam' => get_antispam('newtopic', 1));
    $tpl->set_ar_out($ar, 1);
} else {
    // save toipc
    $_SESSION['klicktime'] = $dppk_time;
    $design = new design($title, $hmenu, 0);
    $design->header($load);
    if (loggedin()) {
        $uid = $_SESSION['authid'];
        $erst = escape($_SESSION['authname'], 'string');
        db_query("UPDATE `prefix_user` SET `posts` = `posts`+1 WHERE `id` = " . $uid);
    } else {
        $erst = $xnn;
        $uid = 0;
    }
    db_query("INSERT INTO `prefix_topics` (`fid`, `name`, `erst`, `stat`) VALUES ( " . $fid . ", '" . $topic . "', '" . $erst . "', 1 )");
    $tid = db_last_id();
    // topic alert
    if (!empty($_POST['topic_alert']) and $_POST['topic_alert'] == 'yes' and loggedin()) {
        if (0 == db_result(db_query("SELECT COUNT(*) FROM `prefix_topic_alerts` WHERE `uid` = " . $_SESSION['authid'] . " AND `tid` = " . $tid), 0)) {
            db_query("INSERT INTO `prefix_topic_alerts` (`tid`,`uid`) VALUES (" . $tid . ", " . $_SESSION['authid'] . ")");
<?php

#########################################
#  Author  : D3W4 & SAHAT               #
#  Created : Mar 29, 2011 11:00:49 AM    #
#########################################
use_class('products_minierp');
use_class('design');
$design = new design();
$class_pm = new products_minierp();
$pid = tep_db_prepare_input($_GET['pid']);
$d_cat = tep_db_prepare_input($_GET['dcat']);
$d_cat_text = $design->getDesignCategory($d_cat);
$imgsize = '150';
$products = $class_pm->retrieveDetail($pid, 'p');
$design->original_products_id = $pid;
$design->category = $d_cat;
$content .= '<form name="copydesign" method="post" action="?open=designs-detail">';
$content .= '<input type="hidden" name="me_action" value="CREATENEWDESIGN" />';
$content .= '<div style="float:left;margin-left:15px;">';
//LEFT Part open
$margin_left = 15;
$content .= '<div id="image_1" style="float:left;width:' . $imgsize . 'px;height:210px;text-align:center;">';
$content .= '<label><strong>Main Image</strong><br />';
$content .= webImage($products['p']['products_image'], $imgsize, $imgsize, 'Main Image', 'img-border', '') . '</label>';
$content .= '<input type="hidden" name="image_1" value="' . $products['p']['products_image'] . '" />';
$content .= '</div>';
$margin_left += $imgsize;
$margin_left += 30;
$content .= '</div>';
//LEFT Part close
Ejemplo n.º 18
0
    design::settings_checkbox("Set_Disable_category", True, "Disable categories management");
} else {
    design::settings_checkbox("Set_Disable_category", False, "Disable categories management");
}
if (isset($const_defaultaccountname)) {
    design::settings_default_account($const_defaultaccountname);
} else {
    design::settings_default_account("None");
}
echo "<br />";
//SECTION DESKTOP INTEGRATION
design::section_legened("Desktop integration");
if (isset($const_desktop_guid)) {
    design::settings("Guid", $const_desktop_guid, "", "Text", True);
} else {
    design::settings("Guid", security::generate_guid(), "", "Text", True);
}
?>
            <script type="text/javascript">
                function Disable_Authentication()
                    {
                        if (document.getElementById("Set_Disable_authentication").checked)
                            {
                                document.getElementById("Set_Username").disabled = true;
                                document.getElementById("Set_Username").value = "";
                                document.getElementById("Set_Password").disabled = true;
                                document.getElementById("Set_Password").value = "";
                                document.getElementById("Set_Confirm_Password").disabled = true;
                                document.getElementById("Set_Confirm_Password").value = "";
                                disable_confirm_password_if_empty ();
                            }
Ejemplo n.º 19
0
<?php

defined('main') or die('no direct access');
$uid = intval($menu->get(2));
$abf = 'SELECT * FROM prefix_user WHERE id = ' . $uid;
$erg = db_query($abf);
$row = db_fetch_assoc($erg);
$title = $allgAr['title'] . ' :: Users :: Details von ' . $row['name'];
$hmenu = $extented_forum_menu . '<a class="smalfont" href="?user">Users</a><b> &raquo; </b> Details von ' . $row['name'] . $extented_forum_menu_sufix;
$design = new design($title, $hmenu, 1);
$design->addheader('<link rel="stylesheet" type="text/css" href="include/includes/css/uprofil/uprofil.css">');
$design->addheader('<script type="text/javascript" src="include/includes/js/uprofil.js"></script>');
$design->addheader('<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>');
$design->addheader('<script type="text/javascript" src="include/includes/js/jquery.textareaAutoResize.js"></script>');
$design->addheader('<script type="text/javascript" src="include/includes/js/bbcode.js"></script>');
$design->header();
//Header
include __DIR__ . DIRECTORY_SEPARATOR . 'header.php';
$tpl = new tpl('uprofil/friends.htm');
$FAnzahl = db_count_query('SELECT count(id) FROM prefix_friends WHERE uid = ' . $uid);
$limit = 6;
// Limit
$page = $menu->getA(3) == 'p' ? $menu->getE(3) : 1;
$anfang = ($page - 1) * $limit;
$MPL = db_make_sites($page, 'WHERE uid = ' . $uid, $limit, '?user-friends-' . $uid, 'friends');
$abfF = 'SELECT u.*, f.* FROM prefix_friends f LEFT JOIN prefix_user u ON u.id = f.fid WHERE f.uid = ' . $uid . ' ORDER BY f.id ASC LIMIT ' . $anfang . ',' . $limit;
$ergF = db_query($abfF);
if ($FAnzahl > 0) {
    $tpl->out(0);
    while ($rowF = db_fetch_assoc($ergF)) {
        $rowF['FNAME'] = '<a href="?user-details-' . $rowF['fid'] . '">' . $rowF['name'] . '</a>';
Ejemplo n.º 20
0
<?php

/*
Script       => ShBox 4.1
Ilch Version => 1.1Q
Entwickler   => NachtWolf / B.Masmann
Date         => 30.11.15
Seite/Sup.   => http://www.ilch.de
                http://www.nf-projekt.de
Kontakt      => Masmann82@gmx.de
*/
defined('main') or die('no direct access');
defined('admin') or die('only admin access');
$design = new design('Admins Area', 'Admins Area', 2);
$design->addheader('<link rel="stylesheet" type="text/css" href="include/images/shbox4/shbox4.css" />
                    <script type="text/javascript" charset="utf-8" src="include/includes/js/shbox4.js" /></script>
                    <script type="text/javascript" src="include/includes/js/jscolor.js" /></script>');
$design->header();
include 'include/includes/class/shbox4class.php';
$var = new ShBox4();
$tpl = new tpl('shbox4admin', 1);
if ($var->shconfig('farbe') == '1') {
    $ar = array('VERSION' => $var->version, 'FARBE' => '<a href="?shbox4admin-farben" class="btn btn-primary">Farben</a>');
    $tpl->set_ar_out($ar, 0);
} else {
    $ar = array('VERSION' => $var->version, 'FARBE' => '');
    $tpl->set_ar_out($ar, 0);
}
if (escape($menu->get(1), 'string') == 'update') {
    $var1 = escape($menu->get(2), 'string');
    $var2 = escape($_POST['id'], 'string');
Ejemplo n.º 21
0
<?php

use_class('element');
use_class('elements_attributes');
use_class('design');
$class_ea = new elements_attributes();
$design = new design();
if (isset($_GET['id'])) {
    $elements_id = tep_db_prepare_input($_GET['id']);
} elseif (isset($_POST['elements_id'])) {
    $elements_id = tep_db_prepare_input($_POST['elements_id']);
}
if (!isset($elements_id) || $elements_id == '') {
    $elements_id = null;
}
$element = new element($elements_id);
$drafts_id = tep_db_prepare_input($_GET['drafts_id']);
//we moved this to confy, since this const also used on other modules
//define('CONST_ACCESS_DESIGNS_MANAGEMENT', 'design_mgmt');
define('CONST_ACCESS_ELEMENT_LIST', 'element_list');
if (strpos($_SERVER['HTTP_REFERER'], 'designs-manage') !== false) {
    $accessed = CONST_ACCESS_DESIGNS_MANAGEMENT;
} elseif (strpos($_SERVER['HTTP_REFERER'], 'element-list') !== false) {
    $accessed = CONST_ACCESS_ELEMENT_LIST;
} else {
    $accessed = '';
}
if (!is_null($elements_id) && is_null($element->id)) {
    $messagebox->add("Element ID: <strong>{$elements_id}</strong> not found in database");
}
if (isset($_POST['me_action'])) {
 design::input_notes($TransactionNotes);
 echo "<div class='form-group'>";
 echo "<label for='fileToUpload'>Take a picture or upload attachments</label><br />";
 echo "<input type='file' name='fileToUpload' id='fileToUpload' onchange='attachment_uploadFile({$TrEditNr});' />";
 echo "<span class='help-block'></span>";
 echo "</div>\n";
 echo "<div class='table-responsive' id='attachments_table'>";
 echo "</div>\n";
 echo "<br />";
 if ($FlagNew) {
     echo "<script type='text/javascript'>";
     echo "var date_today = get_today();";
     echo "document.getElementById('Date').value=date_today;";
     echo "</script>";
 } else {
     design::input_hidden("TrEditedNr", $TrEditNr);
     echo "<script type='text/javascript'>";
     echo "populate_sub_category(false);";
     echo "</script>";
 }
 echo "<button type='submit' id='SubmitButton' name='SubmitButton' class='btn btn-lg btn-success btn-block'>{$TransactionSubmit}</button>";
 echo "<br />";
 echo "<a href='landing.php' class='btn btn-lg btn-success btn-block'>Return to menu</a>";
 echo "<br />";
 echo "<br />";
 echo "</form>";
 echo "</div>\n";
 echo "<script type='text/javascript'>";
 //Refresh Attachments table
 echo "attachment_RefreshTable({$TrEditNr});\n";
 //Manager transfer disable field
Ejemplo n.º 23
0
require_once "functions.php";
session_start();
security::redirect_if_not_loggedin();
$Guid = costant::desktop_guid();
if (isset($_GET["DeleteAttach"])) {
    attachments::delete_attachment_by_name($_GET["DeleteAttach"]);
}
if (isset($_FILES['UploadedAttachments']) && isset($_POST["Attachment_TrId"])) {
    $TrNumber = (int) $_POST['Attachment_TrId'];
    $FileName = $_FILES['UploadedAttachments']['name'];
    $FileExtension = substr($FileName, strpos($FileName, ".") + 1, strlen($FileName));
    $NewFileName = "Transaction_" . $TrNumber . "_Attach" . (attachments::get_number_of_attachments($TrNumber) + 1) . "." . $FileExtension;
    move_uploaded_file($_FILES['UploadedAttachments']['tmp_name'], "attachments/" . $NewFileName);
    echo $NewFileName;
}
if (isset($_GET["AttachmentsTable"])) {
    $TrId = $_GET["AttachmentsTable"];
    $Attachments = attachments::get_attachments_filename_array($TrId, true);
    echo "<table class = 'table'>";
    echo "<tbody>";
    for ($i = 0; $i < sizeof($Attachments); $i++) {
        echo "<tr>";
        $File = $Attachments[$i];
        design::table_cell(substr($File, strpos($File, "Attach"), strlen($File)), "");
        design::table_cell("<a href='services.php?guid={$Guid}&download_attachment={$File}'>\n                            <span class='glyphicon glyphicon-download-alt'> </span> Open</a>", "text_align_right");
        design::table_cell("<a href='#' onclick='attachment_delete(\"{$File}\",{$TrId});return false;'>\n                            <span class='glyphicon glyphicon-remove'> </span> Delete</a>", "text_align_right");
        echo "</tr>";
    }
    echo "</tbody>";
    echo "</table>";
}
Ejemplo n.º 24
0
<?php

/**
 * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL)
 * @copyright (C) 2000-2010 ilch.de
 * @version $Id$
 */
defined('main') or die('no direct access');
$title = $allgAr['title'] . ' :: ' . $lang['login'];
$hmenu = $extented_forum_menu . $lang['login'] . $extented_forum_menu_sufix;
$tpl = new tpl('user/login.htm');
if (loggedin()) {
    $design = new design($title, $hmenu, 0);
    $design->header();
    if (isset($_POST['wdlink'])) {
        $wd = $_POST['wdlink'];
    } else {
        $wd = 'index.php?' . $allgAr['smodul'];
    }
    wd($wd, $lang['yourareloged']);
    $design->footer();
} else {
    $design = new design($title, $hmenu);
    $design->addheader($tpl->get(0));
    $design->header();
    $tpl = new tpl('user/login.htm');
    $tpl->set_out('WDLINK', 'index.php?' . $allgAr['smodul'], 1);
    $design->footer();
}
Ejemplo n.º 25
0
<?php

#   Copyright by: Manuel
#   Support: www.ilch.de
defined('main') or die('no direct access');
$title = $allgAr['title'] . ' :: News';
$hmenu = 'News';
$design = new design($title, $hmenu);
$design->addheader('<link rel="alternate" type="application/atom+xml" title="News (Atom)" href="index.php?news-atom" />
<link rel="alternate" type="application/rss+xml" title="News (RSS)" href="index.php?news-rss" />');
function news_find_kat($kat)
{
    $katpfad = 'include/images/news/';
    $katjpg = $katpfad . $kat . '.jpg';
    $katgif = $katpfad . $kat . '.gif';
    $katpng = $katpfad . $kat . '.png';
    if (file_exists($katjpg)) {
        $pfadzumBild = $katjpg;
    } elseif (file_exists($katgif)) {
        $pfadzumBild = $katgif;
    } elseif (file_exists($katpng)) {
        $pfadzumBild = $katpng;
    }
    if (!empty($pfadzumBild)) {
        $kategorie = '<img style="" src="' . $pfadzumBild . '" alt="' . $kat . '">';
    } else {
        $kategorie = '<b>' . $kat . '</b><br /><br />';
    }
    return $kategorie;
}
if (!is_numeric($menu->get(1))) {
Ejemplo n.º 26
0
 function setApproveStatus($status, $username = '')
 {
     $id = $this->id;
     if ($status == 'CLEAR') {
         //CLEAR STATUS
         $sda = array();
         $sda['approve_status'] = '0';
         $sda['approve_date'] = 'null';
         $sda['approve_by'] = 'null';
         tep_db_perform('designs_drafts', $sda, 'update', "drafts_id={$id}");
         $this->approve_status = '';
         $this->approve_date = '';
         $this->approve_by = '';
         $isReadyForSamplings = false;
     } elseif ($status == 'A' || $status == 'R') {
         //A = Approved
         //R = Rejected
         $timestamp = date('Y-m-d H:i:s');
         $sda = array();
         $sda['approve_status'] = $status;
         $sda['approve_date'] = $timestamp;
         $sda['approve_by'] = $username;
         tep_db_perform('designs_drafts', $sda, 'update', "drafts_id={$id}");
         $this->approve_status = $status;
         $this->approve_date = $timestamp;
         $this->approve_by = $username;
         if ($status == 'R') {
             //Delete All Products & Elements
             $products = $this->retrieveProducts();
             $elements = $this->retrieveElements();
             foreach ($products as $p) {
                 $this->deleteProduct($p['products_id'], 'draft-killed');
             }
             foreach ($elements as $e) {
                 $this->deleteElement($e['elements_id'], 'draft-killed');
             }
         }
         use_class('design');
         $design = new design($this->designs_id);
         if ($design->status == 4) {
             $isReadyForSamplings = $design->isReadyForSamplings();
             $new_status = $design->category == 'R' ? '5' : '10-1';
             //ONLY 'R' GOES TO SAMPLINGS, OTHER NEED TO CREATE NEW ELEMENTS
             if ($isReadyForSamplings) {
                 $design->updateStatus($design->status, $new_status, 'auto-set');
             }
         } else {
             $isReadyForSamplings = false;
         }
     }
     return $isReadyForSamplings;
 }
Ejemplo n.º 27
0
<?php

#   Copyright by: Manuel
#   Support: www.ilch.de
defined('main') or die('no direct access');
$title = $allgAr['title'] . ' :: Logout';
$hmenu = $extented_forum_menu . 'Logout' . $extented_forum_menu_sufix;
$design = new design($title, $hmenu, 0);
# ausloggen
user_logout();
$design->header();
wd('?' . $allgAr['smodul'], $lang['logoutsuccessful']);
$design->footer();
Ejemplo n.º 28
0
         $image = $_FILES['image_4'];
         $imgno = '4';
         $img_title = 'Image 4';
     }
     $uploadedimgsize = @getimagesize($image['tmp_name']);
     if ($uploadedimgsize[0] > $imglimit || $uploadedimgsize[0] > $imglimit) {
         $result = 'File is too big, max width/height allowed is ' . $imglimit . 'px';
     } else {
         $design->uploadImage($imgno, $image['tmp_name'], $image['name']);
         $result = webImage($design->{'image_' . $imgno}, $imgsize, $imgsize, $img_title, 'img-border');
     }
     echo utf8_encode($result);
     exit;
 } elseif ($_POST['me_action'] == 'DELETEIMAGE') {
     $imgfield = tep_db_prepare_input($_POST['imgfield']);
     $design = new design($id);
     $result = array();
     $result['id'] = $imgfield;
     if ($imgfield == 'image_1') {
         $design->removeImage('1', true);
         $result['img'] = webImage($design->image_1, $imgsize, $imgsize, 'Main Image', 'img-border', '');
     } elseif ($imgfield == 'image_2') {
         $design->removeImage('2', true);
         $result['img'] = webImage($design->image_2, $imgsize, $imgsize, 'Alternate Image', 'img-border', '');
     } elseif ($imgfield == 'image_3') {
         $design->removeImage('3', true);
         $result['img'] = webImage($design->image_3, $imgsize, $imgsize, 'Alternate Image', 'img-border', '');
     } elseif ($imgfield == 'image_4') {
         $design->removeImage('4', true);
         $result['img'] = webImage($design->image_4, $imgsize, $imgsize, 'Alternate Image', 'img-border', '');
     }