public function UpdateSinglePrice($id_user, $single_price, $price = false) { $f['single_price'] = $single_price; $this->db->StartTrans(); if (!$this->db->Update(_DB_PREFIX_ . 'supplier', $f, "id_user = "******"id_supplier = " . $id_user))) { $this->db->FailTrans(); return false; } } $this->db->CompleteTrans(); if (isset($succesUpdate)) { $res = $this->GetAssortimentProductIds($id_user); $arr = array(); foreach ($res as $v) { $arr[] = $v['id_product']; } $Products = new Products(); if (!$Products->RecalcSitePrices($arr)) { return false; } } return true; }
unset($_GET); $url = explode('?', $_SERVER['REQUEST_URI']); header('Location: ' . $url[0]); exit; } $arr['a.id_supplier'] = $id_supplier; //Подключение/отключение поставщика if (isset($_POST['suppliers_activity'])) { $update_supplier['active'] = $_POST['supplier_active']; $update_supplier['id_user'] = $id_supplier; $Supplier->UpdateSupplier($update_supplier, true); // if($_POST['supplier_active'] == 1){ // $Products->UpdateActivityProducttSupplier($update_supplier['id_user']); // } } $Supplier->SetFieldsById($id_supplier, 1); //экспорт в exel if (isset($_GET['export'])) { $Products->SetProductsList1($id_supplier, $order, '', $arr); $Products->GenExcelAssortFile($Products->GetExportAssortRows($Products->list, $id_supplier), $Supplier->fields['article'] . ' ' . date('d.m')); exit(0); } elseif (isset($_GET['export_usd'])) { $Products->SetProductsList1($id_supplier, $order, '', $arr); $Products->GenExcelAssortFile($Products->GetExportAssortRowsUSD($Products->list, $id_supplier), $Supplier->fields['article'] . ' ' . date('d.m') . ' usd'); exit(0); } // Импорт if (isset($_FILES['import_file'])) { // Проверяем загружен ли файл if (is_uploaded_file($_FILES['import_file']['tmp_name'])) { // Проверяе объем файла
} $User = new Users(); $Supplier = new Suppliers(); unset($parsed_res); if (isset($GLOBALS['REQAR'][1]) && is_numeric($GLOBALS['REQAR'][1])) { $id_user = $GLOBALS['REQAR'][1]; } else { header('Location: /404/'); exit; } $tpl->Assign('h1', 'Редактирование поставщика'); $ii = count($GLOBALS['IERA_LINKS']); $GLOBALS['IERA_LINKS'][$ii]['title'] = "Пользователи"; $GLOBALS['IERA_LINKS'][$ii++]['url'] = '/adm/users/'; $GLOBALS['IERA_LINKS'][$ii]['title'] = "Редактирование поставщика"; if (!$Supplier->SetFieldsById($id_user, 1)) { die('Ошибка при выборе пользователя.'); } if (isset($_POST['clear-assort'])) { if ($Supplier->DelSupplierAssort($id_user)) { echo '<script>alert("Все прошло успешно!");</script>'; } else { echo '<script>alert("Произошла ошибка. Обратитесь к администратору");</script>'; } } if (isset($_POST['smb'])) { require_once $GLOBALS['PATH_block'] . 't_fnc.php'; // для ф-ции проверки формы list($err, $errm) = Supplier_form_validate(array('passwd')); if (!$err) { if ($id = $Supplier->UpdateSupplier($_POST)) {
/** * Привязка поставщика к товару с админки * @param [type] $arr [description] */ public function AddToAssortWithAdm($arr) { $suppliers = new Suppliers(); $suppliers->SetFieldsById($arr['id_supplier'], 1); $supp_fields = $suppliers->fields; $f['id_product'] = $arr['id_product']; $f['id_supplier'] = $arr['id_supplier']; // $f['product_limit'] = trim($arr['product_limit']); $f['inusd'] = $arr['inusd']; if ($arr['inusd'] != 1) { $f['price_opt_otpusk'] = trim($arr['price_opt_otpusk']); $f['price_mopt_otpusk'] = trim($arr['price_mopt_otpusk']); $f['price_opt_otpusk_usd'] = round($arr['price_opt_otpusk'] / $supp_fields['currency_rate'], 2); $f['price_mopt_otpusk_usd'] = round($arr['price_mopt_otpusk'] / $supp_fields['currency_rate'], 2); } else { $f['price_opt_otpusk'] = round($arr['price_opt_otpusk_usd'] * $supp_fields['currency_rate'], 2); $f['price_mopt_otpusk'] = round($arr['price_mopt_otpusk_usd'] * $supp_fields['currency_rate'], 2); $f['price_opt_otpusk_usd'] = trim($arr['price_opt_otpusk_usd']); $f['price_mopt_otpusk_usd'] = trim($arr['price_mopt_otpusk_usd']); } $f['price_opt_recommend'] = $f['price_opt_otpusk'] * $supp_fields['koef_nazen_opt']; $f['price_mopt_recommend'] = $f['price_mopt_otpusk'] * $supp_fields['koef_nazen_mopt']; $f['edited'] = date('Y-m-d'); if (isset($arr['sup_comment']) && $arr['sup_comment'] !== '') { $f['sup_comment'] = $arr['sup_comment']; } $this->db->StartTrans(); //Заполнение массива для проверки на совпадения $check['id_product'] = $arr['id_product']; $check['id_supplier'] = $arr['id_supplier']; if (!$this->db->Insert(_DB_PREFIX_ . 'assortiment', $f)) { $this->db->FailTrans(); return true; } $this->db->CompleteTrans(); $this->RecalcSitePrices(array($arr['id_product'])); return false; }
<?php $GLOBALS['IERA_LINKS'][] = array('title' => $header, 'url' => _base_url . '/cabinet/assortment/'); $Products = new Products(); $Supplier = new Suppliers(); $Order = new Orders(); $Unit = new Unit(); $supplier = $Supplier->SetFieldsById($_SESSION['member']['id_user']); $check_sum = $Supplier->GetCheckSumSupplierProducts($Supplier->fields['id_user']); $tpl->Assign("check_sum", $check_sum); $tpl->Assign("supplier", $Supplier->fields); //*********************************Заполнение рабочих дней if (isset($GLOBALS['Rewrite'])) { $cabinet_page = $GLOBALS['Rewrite']; $tpl->Assign('cabinet_page', $cabinet_page); } else { header('Location: ' . _base_url . '/cabinet/assortment/'); } if (isset($cabinet_page) && $cabinet_page == "productsonmoderation") { $header = "Товары на модерации"; $GLOBALS['IERA_LINKS'][] = array('title' => $header, 'url' => _base_url . '/cabinet/productsonmoderation/'); $list = $Products->GetProductsOnModeration($_SESSION['member']['id_user']); $tpl->Assign('list', $list); $parsed_res = array('issuccess' => true, 'html' => $tpl->Parse($GLOBALS['PATH_tpl'] . 'products_on_moderation.tpl')); } elseif (isset($cabinet_page) && $cabinet_page == "promo_orders") { $header = "Заказы с промо-кодом"; $GLOBALS['IERA_LINKS'][] = array('title' => $header, 'url' => _base_url . '/cabinet/promo_orders/'); $orders = $Order->GetOrdersByPromoSupplier($_SESSION['member']['id_user']); $tpl->Assign('orders', $orders); $parsed_res = array('issuccess' => true, 'html' => $tpl->Parse($GLOBALS['PATH_tpl'] . 'promo_orders.tpl')); } elseif (isset($cabinet_page) && $cabinet_page == "promo_codes") {
<?php if (!_acl::isAllow('product_moderation')) { die("Access denied"); } unset($parsed_res); $dbtree = new dbtree(_DB_PREFIX_ . 'category', 'category', $db); $Products = new Products(); $suppliers = new Suppliers(); $tpl->Assign('h1', 'Товары на модерации'); $ii = count($GLOBALS['IERA_LINKS']); $GLOBALS['IERA_LINKS'][$ii]['title'] = "Товары на модерации"; $prods = $Products->GetProductsOnModeration(); $list = $suppl = array(); foreach ($prods as $prod) { if ($prod['moderation_status'] != 2) { $suppliers->SetFieldsById($prod['id_supplier']); $suppl[$prod['id_supplier']] = $suppliers->fields; $list[$prod['id_supplier']][] = $prod; } } // Формирование списка категорий для выпадающего списка $category = $Products->generateCategory(); $tpl->Assign('category', $category); $tpl->Assign('list', $list); $tpl->Assign('suppliers', $suppl); $tpl_center .= $tpl->Parse($GLOBALS['PATH_tpl'] . 'cp_moderation.tpl');
public function SendOrdersToSuppliers($supplier, $id_supplier, $orders, $contragent, $sorders) { global $db; $Suppliers = new Suppliers(); $Suppliers->SetFieldsById($id_supplier); $c1 = 30; $c2 = 45; $c3 = 96; $c4 = 350; $c5 = 80; $c6 = 80; $c7 = 50; $c8 = 95; $otpusk = 0; $kotpusk = 0; $this->Body = "\n\t\t\t<style>\n\t\t\t* {\n\t\t\t\tpadding: 0;\n\t\t\t\tmargin: 0;\n\t\t\t}\n\t\t\t.logo { font-size: 28px; color: #00F; font-weight: bold; }\n\n\t\t\t.undln { text-decoration: underline; }\n\t\t\t.lb { border-left: 1px dashed #000; padding-left: 5px; }\n\n\t\t\t.table_header { margin-left: 3px; width: 827px; }\n\t\t\t.table_header .top td { padding: 10px 0 15px 0; font-size: 14px; }\n\t\t\t.table_header .first_col { width: 150px; }\n\t\t\t.table_header .second_col { width: 300px; }\n\t\t\t.table_header .top span.invoice { margin-left: 20px; font-size: 18px; text-decoration: underline; }\n\n\t\t\t.bl { border-left: 1px solid #000; }\n\t\t\t.br { border-right: 1px solid #000; }\n\t\t\t.bt { border-top: 1px solid #000; }\n\t\t\t.bb { border-bottom: 1px solid #000 !important; }\n\t\t\t.bn { border: none !important; }\n\t\t\t.bla { text-align: left; }\n\n\t\t\t.bnb { border-bottom: none !important; }\n\n\t\t\t.blf { border-left: 1px solid #FFF; }\n\t\t\t.brf { border-right: 1px solid #FFF; }\n\t\t\t.bbf { border-bottom: 1px solid #FFF; }\n\n\t\t\t.table_main { margin: 10px 0 0 1px; clear: both; }\n\t\t\t.table_main td { padding: 1px 1px 0; font-size: 12px; text-align: center; border-right: 1px #000 solid; border-bottom: 1px #000 solid; vertical-align: middle; font-size: 14px; font-weight: 900; }\n\t\t\t.table_main th { text-align: center; vertical-align: middle; font-weight: lighter; font-size: 11px;}\n\t\t\t.table_main td.name { padding: 1px; font-size: 12px; text-align: left; border-right: 1px #000 solid; border-bottom: 1px solid #000; }\n\t\t\t.table_main .hdr td { font-weight: bold; padding: 1px; }.\n\t\t\t.table_main .hdr1 td { text-align: left; }\n\t\t\t.table_main td.postname {\n\t\t\t\ttext-align: left;\n\t\t\t}\n\t\t\t.table_main .main td { height: 50px; font-size: 14px; font-weight: 900; }\n\t\t\t.table_main .main td.img { width: 56px; }\n\n\t\t\t.table_sum { margin: 10px 0 0 1px; }\n\t\t\t.table_sum td { padding: 1px 1px 0; font-size: 12px; text-align: center; vertical-align: middle; }\n\t\t\t.table_sum td.name { padding: 1px; font-size: 12px; text-align: left; }\n\n\t\t\t.adate { font-size: 11px; margin-left: 177px; }\n\t\t\t.note_red { color: #f00; font-size: 14px; font-weight: 900; }\n\t\t\t.note_grin { color: #f00; font-size: 22px; font-weight: 900; }\n\n\t\t\t.break { page-break-before: always; }\n\t\t\t.break_after { page-break-after: always; }\n\t\t\t.dash { border-bottom: 1px #f00 dashed; margin-bottom: 10px; }\n\t\t</style>"; $this->Body .= "<div style=\"display: block; \">\n\t\t\t<p style=\"margin: 1px 0 0 10px; font-size: 14px; font-weight: bold;\">\n\t\t\t\t<div style=\"float:left\">\n\t\t\t\t\t<span class=\"logo\">" . $_SERVER['SERVER_NAME'] . "</span>\n\t\t\t\t</div>\n\t\t\t</p>\n\t\t\t</div>\n\t\t\t<div style=\"clear: both; float:left; margin: 10px; font-size: 14px; font-weight: bold; width: 383px; padding-left: 10px;\">\n\t\t\t\t<b>" . $supplier['name'] . ", " . $supplier['phone'] . ", " . $supplier['place'] . "</b>\n\t\t\t</div>\n\t\t\t<div style=\"float:left; margin: 10px; white-space: normal; width: 383px; padding-left: 10px;\" class=\"bl\">\n\t\t\t\t<p>" . $contragent['descr'] . "</p>\n\t\t\t</div>\n\t\t\t<div style=\"clear: both;\"> </div>\n\t\t\t<table cellspacing=\"0\" border=\"1\" style=\"width: 827px; clear: both; float: left; margin-top: 10px\" class=\"table_main\">\n\t\t\t\t<thead>\n\t\t\t\t\t<tr class=\"hdr\">\n\t\t\t\t\t\t<th class=\"br bl bt bb\">№ заказа</th>\n\t\t\t\t\t\t<th class=\"br bt bb\">Сумма по отп. ценам</th>\n\t\t\t\t\t\t<th class=\"br bt bb\">Сумма факт</th>\n\t\t\t\t\t</tr>\n\t\t\t\t</thead>\n\t\t\t\t<tbody>"; foreach ($sorders[$id_supplier] as $k => $o) { $this->Body .= "<tr class=\"hdr\">\n\t\t\t\t\t<td class=\"bl bb\">" . $k . "</td>\n\t\t\t\t\t<td class=\"note_red bb\">" . $o['order_otpusk'] . "</td>\n\t\t\t\t\t<td class=\"bb br\"> </td>\n\t\t\t\t</tr>"; $otpusk += $o['order_otpusk']; $kotpusk += isset($o['site_sum']) ? $o['site_sum'] : 0; } $this->Body .= "<tr class=\"hdr\">\n\t\t\t\t\t<td class=\"bnb\" style=\"text-align:right\">Сумма</td>\n\t\t\t\t\t<td class=\"note_red\">" . $otpusk . "</td>\n\t\t\t\t\t<td class=\"bb br\"> </td>\n\t\t\t\t</tr>\n\t\t\t\t<tr class=\"hdr\">\n\t\t\t\t\t<td class=\"bnb note_red\" style=\"text-align: right; font-size: 13pt;\">Скидка</td>\n\t\t\t\t\t<td class=\"bb bt br\"> </td>\n\t\t\t\t\t<td class=\"bb bt br\"> </td>\n\t\t\t\t</tr>\n\t\t\t\t<tr class=\"hdr\">\n\t\t\t\t\t<td class=\"bnb note_red\" style=\"text-align: right; font-size: 13pt;\">Сумма к оплате</td>\n\t\t\t\t\t<td class=\"bb br\"> </td>\n\t\t\t\t\t<td class=\"bb br\"> </td>\n\t\t\t\t</tr>\n\t\t\t</tbody>\n\t\t</table>"; $this->Subject = "Заказы " . $GLOBALS['CONFIG']['invoice_logo_text'] . " от " . (date("d") + 1) . "-" . date("m") . "-" . date("Y"); foreach ($supplier['orders'] as $order_key => $order) { $this->Body .= "<table class=\"table_main\" border=\"1\" cellspacing=\"0\">\n\t\t\t<col style=\"width:" . $c1 . ";\" />\n\t\t\t<col style=\"width:" . $c2 . ";\" />\n\t\t\t<col style=\"width:" . $c3 . ";\" />\n\t\t\t<col style=\"width:" . $c4 . ";\" />\n\t\t\t<col style=\"width:" . $c5 . ";\" />\n\t\t\t<col style=\"width:" . $c6 . ";\" />\n\t\t\t<col style=\"width:" . $c7 . ";\" />\n\t\t\t<col style=\"width:" . $c8 . ";\" />\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th colspan=\"9\" style=\"border: 0;\">\n\t\t\t\t\t\t<p style=\"font-size: 20px; font-weight: bold; width: 827px; text-align: center\">\n\t\t\t\t\t\t\t№ " . $order_key . " - <b style=\"font-size:16px;color:Red\">" . $orders[$order_key]['note2'] . "</b>\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</th>\n\t\t\t\t</tr>\n\t\t\t\t<tr class=\"hdr\">\n\t\t\t\t\t<th class=\"bt br bl bb\">№</th>\n\t\t\t\t\t<th class=\"bt br bb\">Арт</th>\n\t\t\t\t\t<th class=\"bt br bb\">Фото</th>\n\t\t\t\t\t<th class=\"bt br bb\">Название</th>\n\t\t\t\t\t<th class=\"bt br bb\">Цена 1шт.</th>\n\t\t\t\t\t<th class=\"bt br bb\">Заказано, шт</th>\n\t\t\t\t\t<th class=\"bt br bb\">факт</th>\n\t\t\t\t\t<th class=\"bt br bb\">Сумма</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t<tbody>"; $ii = 1; $sum = 0; $qty = 0; $weight = 0; $volume = 0; $sum_otpusk = 0; foreach ($order as &$i) { if ($i['opt_qty'] > 0 && $i['id_supplier'] == $id_supplier) { $this->Body .= "<tr class=\"main\">\n\t\t\t\t\t\t<td class=\"bl bb\">" . $ii++ . "</td>\n\t\t\t\t\t\t<td class=\"bb\">" . $i['art'] . "</td>\n\t\t\t\t\t\t<td class=\"bb\">\n\t\t\t\t\t\t\t<img height=\"96\" width=\"96\" src=\"" . $_SERVER['SERVER_NAME'] . '/' . G::GetImageUrl($i['img_1'], 'medium') . "\" />\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td class=\"name bb\">"; if ($i['note_opt'] != '') { $this->Body .= "<span class=\"note_red\">" . $i['note_opt'] . "</span><br>"; } $this->Body .= $i['name'] . "</td>\n\t\t\t\t\t\t<td class=\"bb\">"; if (!$supplier['is_partner']) { $this->Body .= $i['price_opt_otpusk']; } $this->Body .= "</td>\n\t\t\t\t\t\t<td class=\"bb\">" . $i['opt_qty'] . "</td>\n\t\t\t\t\t\t<td class=\"bb\"> </td>\n\t\t\t\t\t\t<td class=\"bb\">"; if (!$supplier['is_partner']) { $this->Body .= round($i['price_opt_otpusk'] * $i['opt_qty'], 2); } $this->Body .= "</td>\n\t\t\t\t\t</tr>"; $sum_otpusk = round($sum_otpusk + round($i['price_opt_otpusk'] * $i['opt_qty'], 2), 2); $qty += $i['opt_qty']; $volume += $i['volume'] * $i['opt_qty']; $weight += $i['weight'] * $i['opt_qty']; $sum = round($sum + $i['opt_sum'], 2); } if ($i['mopt_qty'] > 0 && $i['id_supplier_mopt'] == $id_supplier) { $this->Body .= "<tr class=\"main\">\n\t\t\t\t\t\t<td class=\"bl bb\">" . $ii++ . "</td>\n\t\t\t\t\t\t<td class=\"bb\">" . $i['art'] . "</td>\n\t\t\t\t\t\t<td class=\"bb\">\n\t\t\t\t\t\t\t<img height=\"96\" width=\"96\" src=\"http:" . $_SERVER['SERVER_NAME'] . '/' . G::GetImageUrl($i['img_1'], 'medium') . "\" />\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td class=\"name bb\">"; if ($i['note_mopt'] != '') { $this->Body .= "<span class=\"note_red\">" . $i['note_mopt'] . "</span><br>"; } $this->Body .= $i['name'] . "</td>\n\t\t\t\t\t\t<td class=\"bb\">"; if (!$supplier['is_partner']) { $this->Body .= $i['price_mopt_otpusk']; } $this->Body .= "</td>\n\t\t\t\t\t\t<td class=\"bb\">" . $i['mopt_qty'] . "</td>\n\t\t\t\t\t\t<td class=\"bb\"> </td>\n\t\t\t\t\t\t<td class=\"bb\">"; if (!$supplier['is_partner']) { $this->Body .= round($i['price_mopt_otpusk'] * $i['mopt_qty'], 2); } $this->Body .= "</td>\n\t\t\t\t\t</tr>"; $sum_otpusk = round($sum_otpusk + round($i['price_mopt_otpusk'] * $i['mopt_qty'], 2), 2); $qty += $i['mopt_qty']; $volume += $i['volume'] * $i['mopt_qty']; $weight += $i['weight'] * $i['mopt_qty']; $sum = round($sum + $i['mopt_sum'], 2); } } $this->Body .= "<tr class=\"table_sum\">\n\t\t\t\t<td class=\"bn\"> </td>\n\t\t\t\t<td class=\"bn\"> </td>\n\t\t\t\t<td class=\"bn\"> </td>\n\t\t\t\t<td class=\"bn\"> </td>\n\t\t\t\t<td class=\"bn\"> </td>\n\t\t\t\t<td class=\"bn\"> </td>\n\t\t\t\t<td class=\"bn\" style=\"text-align:right\">Сумма:</td>\n\t\t\t\t<td class=\"br bb bl\">"; if (!$supplier['is_partner']) { $this->Body .= "<div class=\"note_red\">" . $sum_otpusk . "</div>"; } $this->Body .= "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody>\n\t\t\t</table>"; } $this->isHTML(true); if ($supplier['make_csv'] == 1) { $this->AddAttachment($_SERVER['DOCUMENT_ROOT'] . "/temp/" . $supplier['real_phone'] . '.csv', $supplier['real_phone'] . '.csv'); } if (is_null($supplier['real_email']) == false) { // Добавляем адрес в список получателей $this->AddAddress($supplier['real_email']); if (!$this->Send()) { $this->ClearAddresses(); $this->ClearAttachments(); if ($this->echo) { echo "Не могу отослать письмо! \n<br>"; } $return = false; } else { $this->ClearAddresses(); $this->ClearAttachments(); if ($this->echo) { echo "Письмо отослано! \n<br>"; } $return = true; } return $return; } else { return false; } }