public function actionTradeSubmit() { $cart = new EShoppingCart(); $cart->init(); $positions = $cart->getPositions(); $tradeInfo = ""; foreach ($positions as $position) { if ($position->id != 100) { //если это не доставка $tradeInfo = $tradeInfo . $position->name . " " . $tradeInfo . $position->article . " " . $position->attributes . " -" . $position->count . "шт (цена за шт.:" . $position->priceForThisCount / $position->count . "р.) :" . $position->priceForThisCount . "р.\r\n"; } } $trade = new Trades(); $trade->name = $_POST["name"]; $trade->phone = $_POST["phone"]; $trade->email = $_POST["email"]; $trade->address = $_POST["address"]; $trade->paymentType = $_POST["paymentType"]; $trade->tradeInfo = $tradeInfo; $trade->date = new CDbExpression('NOW()'); $trade->totalPrice = $_POST["totalPrice"]; $res = $trade->save(); if ($res == false) { echo "error"; return; } $message = "Поступила новвый заказ!\r\n\r\n" . "Номер заказа: " . $trade->id . "\r\n\r\n" . $tradeInfo . "\r\n\r\n"; $message = $message . "Доставка"; if ($_POST["address"] == "") { $message = $message . ":\r\nсамовывоз"; } else { $message = $message . " +200р.\r\nАдрес:" . $_POST["address"]; } $message = $message . "\r\n\r\nИтого: " . $_POST["totalPrice"] . "р."; if ($_POST["paymentType"] == "nal") { $message = $message . "\r\n\r\nОплата наличными."; } else { $message = $message . "\r\n\r\nОплата онлайн."; } $message = $message . "\r\n\r\nКонтакты:\r\nИмя:" . $_POST["name"] . "\r\nТелефон:" . $_POST["phone"] . "\r\nEmail:" . $_POST["email"]; mail("*****@*****.**", "Dominanta:Поступила новвый заказ!", $message); echo $trade->id; }
setvar("type_id", $item['type_id']); setvar("item", $item); } $tpl_file = "offer_edit"; template($tpl_file); exit; } if ($do == "update" && !empty($id)) { $vals = array(); $vals['modified'] = $time_stamp; $conditions[] = "status='1'"; $pre_update_time = $pdb->GetOne("select modified from {$tb_prefix}trades where id=" . $id . " and member_id=" . $the_memberid); if ($pre_update_time > $time_stamp - $tMaxHours * 3600) { flash("only_one_time_within_hours"); } $result = $trade->save($vals, "update", $id, null, $conditions); if (!$result) { flash("action_failed"); } else { flash("success"); } } if ($do == "refresh" && !empty($id)) { $vals = array(); $pre_submittime = $pdb->GetOne("select submit_time from {$tb_prefix}trades where id=" . $id . " and member_id=" . $the_memberid); if ($pre_submittime > $time_stamp - $tMaxDay * 86400) { flash("allow_refresh_day"); } $vals['submit_time'] = $time_stamp; $vals['expire_days'] = 1; $vals['expire_time'] = $time_stamp + 24 * 3600 * $vals['expire_days'];
$highlight_style = $_POST['highlight']['style']; //array $highlight_color = array_search(strtoupper($_POST['highlight']['color']), $viewhelper->colorarray); $stylebin = ''; for ($i = 1; $i <= 3; $i++) { $stylebin .= empty($highlight_style[$i]) ? '0' : '1'; } $highlight_style = bindec($stylebin); if ($highlight_style < 0 || $highlight_style > 7 || $highlight_color < 0 || $highlight_color > 8) { } else { $highlight_style = $highlight_style . $highlight_color; $vals['highlight'] = $highlight_style; } if (!empty($id)) { $vals['modified'] = $time_stamp; $updated = $trade->save($vals, "update", $id); } else { $vals['submit_time'] = empty($vals['submit_time']) ? $time_stamp : $vals['submit_time']; $vals['expire_time'] = empty($vals['expire_time']) ? $time_stamp + 60 * 60 * 24 * 30 : $vals['expire_time']; $vals['created'] = $vals['modified'] = $time_stamp; $updated = $trade->save($vals); $last_insert_key = "{$tb_prefix}trades_id"; $id = $trade->{$last_insert_key}; } if (!$updated) { flash(); } else { if ($_PB_CACHE['setting']['keyword_bidding']) { $keyword->setIds($vals['title'] . $vals['content'], 'trades', true, $id); } flash("success", "offer.php?do=search&page=" . $_REQUEST['page'] . "&type_id=" . $vals['type_id']);