function get($cond) { try { return parent::get($cond); } catch (Exception $e) { throw new Exception("Course is not exists", self::NOT_EXISTS); } }
} } if ($action == 'builddoc') { $result = 0; $error = 0; if (empty($forbarcode)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BarcodeValue")), null, 'errors'); $error++; } if (empty($fk_barcode_type)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BarcodeType")), null, 'errors'); $error++; } if (!$error) { // Get encoder (barcode_type_coder) from barcode type id (barcode_type) $stdobject = new GenericObject($db); $stdobject->barcode_type = $fk_barcode_type; $result = $stdobject->fetch_barcode(); if ($result <= 0) { $error++; setEventMessages('Failed to get bar code type information ' . $stdobject->error, $stdobject->errors, 'errors'); } } if (!$error) { $code = $forbarcode; $generator = $stdobject->barcode_type_coder; // coder (loaded by fetch_barcode). Engine. $encoding = strtoupper($stdobject->barcode_type_code); // code (loaded by fetch_barcode). Example 'ean', 'isbn', ... $diroutput = $conf->barcode->dir_temp; dol_mkdir($diroutput);
define('NOREQUIREMENU', '1'); } if (!defined('NOREQUIREHTML')) { define('NOREQUIREHTML', '1'); } if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); } if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); } if (!defined('NOREQUIRETRAN')) { define('NOREQUIRETRAN', '1'); } require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/genericobject.class.php'; $action = GETPOST('action', 'alpha'); $id = GETPOST('id', 'int'); $value = GETPOST('value', 'int'); $field = GETPOST('field', 'alpha'); $element = GETPOST('element', 'alpha'); $object = new GenericObject($db); /* * View */ top_httphead(); print '<!-- Ajax page called with url ' . $_SERVER["PHP_SELF"] . '?' . $_SERVER["QUERY_STRING"] . ' -->' . "\n"; // Registering new values if ($action == 'set' && !empty($id)) { $object->setValueFrom($field, $value, $element, $id); }
require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/genericobject.class.php'; /* * View */ top_httphead(); print '<!-- Ajax page called with url ' . $_SERVER["PHP_SELF"] . '?' . $_SERVER["QUERY_STRING"] . ' -->' . "\n"; // Registering the location of boxes if (isset($_POST['roworder']) && !empty($_POST['roworder']) && (isset($_POST['table_element_line']) && !empty($_POST['table_element_line'])) && (isset($_POST['fk_element']) && !empty($_POST['fk_element'])) && (isset($_POST['element_id']) && !empty($_POST['element_id']))) { $roworder = GETPOST('roworder', 'alpha', 2); $table_element_line = GETPOST('table_element_line', 'alpha', 2); $fk_element = GETPOST('fk_element', 'alpha', 2); $element_id = GETPOST('element_id', 'int', 2); dol_syslog("AjaxRow roworder=" . $roworder . " table_element_line=" . $table_element_line . " fk_element=" . $fk_element . " element_id=" . $element_id, LOG_DEBUG); $rowordertab = explode(',', $roworder); foreach ($rowordertab as $value) { if (!empty($value)) { $newrowordertab[] = $value; } } $row = new GenericObject($db); $row->table_element_line = $table_element_line; $row->fk_element = $fk_element; $row->id = $element_id; $row->line_ajaxorder($newrowordertab); // Reorder line to have position of chilren lines sharing same counter than parent lines // This should be useless because there is no need to have children sharing same counter than parent, but well, it's cleaner into database. if (in_array($fk_element, array('fk_facture', 'fk_propal', 'fk_commande'))) { $result = $row->line_order(true); } }
/** * Осуществляет вставку новой записи в прайс-лист * @param array $arFieldVals массив с значениями полей; key->имя поля, value->значение * @return bool Возвращает успех или неудачу */ public function insertItem($arFieldVals) { $gprice_gen_obj = new GeneralPrice(0, $this->_dbase); if (!isset($this->_alloysFieldsNamesArray)) { $this->_alloysFieldsNamesArray = $this->_dbase->getFieldsNames('alloys'); } if (!isset($this->_productFieldsNamesArray)) { $this->_productFieldsNamesArray = $this->_dbase->getFieldsNames('production'); } // возможно, логичнее сделать проверку на необходимые размеры на клиенте // составляем запросы для поучения id_alloys и id_production и заполняем некоторые поля general_price foreach ($arFieldVals as $field => $value) { if (in_array($field, $this->_alloysFieldsNamesArray)) { $alloy_fields[$field] = array($arFieldVals[$field]); // array() ставим, чтобы корректно отработала функция _getFilterQuery() continue; } elseif (in_array($field, $this->_productFieldsNamesArray)) { $product_fields[$field] = array($arFieldVals[$field]); // array() ставим, чтобы корректно отработала функция _getFilterQuery() continue; } else { $gprice_gen_obj->__set($field, $value); } } $alloy_query = $this->_getFilterQuery('alloys', $alloy_fields, array('id')); $product_query = $this->_getFilterQuery('production', $product_fields, array('id')); // проверяем наличие записей в alloys и production, удовлетворяющих заданным требованиям try { $ids = $this->_dbase->select($alloy_query); $alloy_id = $ids[0]['id']; $ids = $this->_dbase->select($product_query); $product_id = $ids[0]['id']; } catch (Exception $e) { print $e->getMessage(); return false; } // если такой записи в alloys нет, то создаем ее и записываем полученный id if (!($alloy_id > 0)) { $alloy_gen_obj = new Alloy(0, $this->_dbase); foreach ($alloy_fields as $field => $value) { $alloy_gen_obj->__set($field, $value[0]); } if (!$alloy_gen_obj->save()) { return false; } $alloy_id = $alloy_gen_obj->id; } // если такой записи в production нет, то создаем ее и записываем полученный id if (!($product_id > 0)) { $class_name = getProductGenObject($product_fields); $s = "\$product_gen_obj = new {$class_name}(0, \$this->_dbase);"; eval($s); foreach ($product_fields as $field => $value) { $product_gen_obj->__set($field, $value[0]); } if (!$product_gen_obj->save()) { return false; } $product_id = $product_gen_obj->id; } // задаем недостающие поля для $gprice_gen_obj->alloy_id = $alloy_id; $gprice_gen_obj->product_id = $product_id; if (!$gprice_gen_obj->save()) { return false; } $gprice_id = $gprice_gen_obj->id; // получаем все необходимые записи общего прайс-листа из таблицы general_price $query = "SELECT `id` FROM `metotech_metalls`.`special_prices` WHERE `price_name` = '" . mysql_real_escape_string($this->_priceName) . "'"; try { $ids = $this->_dbase->select($query); $sprice_id = $ids[0]['id']; } catch (Exception $e) { print $e->getMessage(); return false; } $mapping_gen_obj = new GenericObject(); $mapping_gen_obj->initialize(0, 'prices_mapping', $this->_dbase); $mapping_gen_obj->sprice_id = $sprice_id; $mapping_gen_obj->gprice_id = $gprice_id; if (!$mapping_gen_obj->save()) { return false; } return true; }