Ejemplo n.º 1
0
    $sID = array_pop($dbc->fetch_row($sR));
}
/* 1. Validate credentials of the operator.  */
$uid = 0;
if (!$validatedUser && !$auditedUser && $logged_in) {
    $validatedUser = validateUserQuiet('pricechange', $subdepartment);
}
if ($validatedUser) {
    $validatedUID = getUID($validatedUser);
    $uid = $validatedUID;
} elseif ($auditedUser) {
    /* 2el. Notify dept manager of the new values.  */
    if (!empty($likeCode)) {
        \COREPOS\Fannie\API\lib\AuditLib::itemUpdate($upc, $likeCode);
    } else {
        \COREPOS\Fannie\API\lib\AuditLib::itemUpdate($upc);
    }
}
/* 2. Insert or update per-coop products data  */
/* For WEFC_Toronto only
 * Store the raw versions of products.description and productUser.description in products_WEFC_Toronto.
*/
if (isset($FANNIE_COOP_ID) && $FANNIE_COOP_ID == "WEFC_Toronto") {
    $table_name = "products_{$FANNIE_COOP_ID}";
    if ($dbc->table_exists("{$table_name}")) {
        $coop_array = array("description" => $dbc->escape(substr($_REQUEST['descript'], 0, 255)), "search_description" => isset($_REQUEST['puser_description']) ? $dbc->escape(substr($_REQUEST['puser_description'], 0, 255)) : '');
        $checkR = $dbc->query("SELECT upc FROM {$table_name} WHERE upc='{$upc}'");
        if ($dbc->num_rows($checkR) == 0) {
            $coop_array['upc'] = $dbc->escape($upc);
            $dbc->smart_insert("{$table_name}", $coop_array);
        } else {
Ejemplo n.º 2
0
 function save_item($isNew)
 {
     $FANNIE_PRODUCT_MODULES = $this->config->get('PRODUCT_MODULES');
     $FANNIE_URL = $this->config->get('URL');
     $upc = FormLib::get_form_value('upc', '');
     if ($upc === '' || !is_numeric($upc)) {
         return '<span style="color:red;">Error: bad UPC:</span> ' . $upc;
     }
     $upc = BarcodeLib::padUPC($upc);
     $audited = false;
     if (FannieAuth::validateUserQuiet('pricechange')) {
         // validated; nothing to do
     } elseif (FannieAuth::validateUserQuiet('audited_pricechange')) {
         $audited = true;
     } elseif (($range = FannieAuth::validateUserLimited('pricechange')) !== false) {
         // validated for certain departments; nothing to do
     } else {
         // not authorized to make edits
         return '<span style="color:red;">Error: Log in to edit</span>';
     }
     uasort($FANNIE_PRODUCT_MODULES, array('ItemEditorPage', 'sortModules'));
     $form = new \COREPOS\common\mvc\FormValueContainer();
     foreach ($FANNIE_PRODUCT_MODULES as $class => $params) {
         $mod = new $class();
         $mod->setConnection($this->connection);
         $mod->setConfig($this->config);
         $mod->setForm($form);
         $mod->SaveFormData($upc);
     }
     /* push updates to the lanes */
     $dbc = $this->connection;
     $dbc->selectDB($this->config->get('OP_DB'));
     $FANNIE_COOP_ID = $this->config->get('COOP_ID');
     if (isset($FANNIE_COOP_ID) && $FANNIE_COOP_ID == 'WEFC_Toronto') {
         updateAllLanes($upc, array('products', 'productUser'));
     } else {
         updateProductAllLanes($upc);
     }
     if ($audited) {
         $lc = FormLib::get('likeCode', -1);
         $no_update = FormLib::get('LikeCodeNoUpdate', false);
         if ($lc != -1 && !$no_update) {
             \COREPOS\Fannie\API\lib\AuditLib::itemUpdate($upc, $lc);
         } else {
             \COREPOS\Fannie\API\lib\AuditLib::itemUpdate($upc);
         }
     }
     $ret = "<table class=\"table\">";
     foreach ($FANNIE_PRODUCT_MODULES as $class => $params) {
         $mod = new $class();
         $rows = $mod->summaryRows($upc);
         foreach ($rows as $row) {
             $ret .= '<tr>' . $row . '</tr>';
         }
     }
     $ret .= '</table>';
     return $ret;
 }