Exemplo n.º 1
0
     $users = getUsersForOrders($orders);
     break;
 case 'admin_order':
     $order = getOrder($order_id);
     $user = getUserForOrder($order['user_id']);
     if (!$user) {
         setSession('admin', array('error' => 'database_error'));
     } else {
         unset($_SESSION['admin']['error']);
     }
     $tiraj = getTiraj($order['tiraj']);
     if (!$tiraj) {
         setSession('admin', array('error' => 'database_error'));
     }
     if (!empty($order['paper_type'])) {
         $paper = getPaperType($order['paper_type']);
     }
     if ($order['layout']) {
         $layouts = getOrderLayouts($order_id);
     }
     if (isset($_POST['edit_order'])) {
         $order_id = $_POST['order_id'];
         $order_status = $_POST['order_status'];
         editOrder($order_id, $order_status);
         redirect();
     }
     break;
 case 'admin_del_order':
     $order_id = $_POST['id'];
     deleteOrder($order_id);
     removeOrderLayouts($order_id);
Exemplo n.º 2
0
function offerOrder1()
{
    if (isset($_POST['confirm_template'])) {
        if (isset($_POST['TMPL'])) {
            $save['type_sides'] = (int) abs($_POST['TMPL']['type_side']);
            $save['img_out_1'] = $_POST['TMPL']['img_out_1'];
            if ($save['type_sides'] == 2) {
                $save['img_out_2'] = $_POST['TMPL']['img_out_2'];
            } else {
                $save['img_out_2'] = NULL;
            }
        } else {
            $save['type_sides'] = NULL;
            $save['img_out_1'] = NULL;
            $save['img_out_2'] = NULL;
        }
    } else {
        setSession('error', 'Ошибка!');
        redirect();
    }
    if (isset($_POST['confirm_copy_rights'])) {
        if (isset($_POST['wishes'])) {
            $save = array();
            $save['wishes'] = $_POST['wishes'];
            $error = '';
            if (!isset($_POST['printing_type'])) {
                $error .= '<li>Не выбран тираж</li>';
            } else {
                $save['printing_type'] = getPrintingType($_POST['printing_type']);
                if (!$save['printing_type']) {
                    $error .= 'Ошибка!';
                }
            }
            if (!isset($_POST['paper_type'])) {
                $error .= '<li>Не выбрано количество</li>';
            } else {
                $save['paper_type'] = getPaperType((int) abs($_POST['paper_type']));
            }
            if (!isset($_POST['kolvo'])) {
                $error .= '<li>Не выбрано количество</li>';
            } else {
                $save['tiraj'] = $save['printing_type']['id'];
                $save['kolvo'] = $_POST['kolvo'] != 0 ? (int) abs($_POST['kolvo']) : 1;
            }
            if (isset($_POST['EXTRA'])) {
                $extra = getExtra();
                foreach ($extra as $ext) {
                    if (isset($_POST['EXTRA'][$ext['name']])) {
                        $save['dop_uslugi'] .= $_POST['EXTRA'][$ext['name']] . ',';
                    }
                }
            } else {
                $save['dop_uslugi'] = NULL;
            }
            if (isset($_POST['edit_template'])) {
                $save['type'] = 'Визитки';
            } else {
                $save['type'] = 'Макеты';
            }
            if (isset($_POST['TMPL'])) {
                $save['type_sides'] = (int) abs($_POST['TMPL']['type_side']);
                $save['img_out_1'] = $_POST['TMPL']['img_out_1'];
                if ($save['type_sides'] == 2) {
                    $save['img_out_2'] = $_POST['TMPL']['img_out_2'];
                } else {
                    $save['img_out_2'] = NULL;
                }
            } else {
                $save['type_sides'] = NULL;
                $save['img_out_1'] = NULL;
                $save['img_out_2'] = NULL;
            }
            if ($error == '') {
                unset($_SESSION['error']);
                unset($_SESSION['errors']);
                $totalSum = ($save['printing_type']['price'] + $save['paper_type']['price']) * $save['kolvo'];
                $_SESSION['basket'][] = array('type' => $save['type'], 'tiraj' => $save['tiraj'], 'kolvo' => $save['kolvo'], 'type_sides' => $save['type_sides'], 'wishes' => $save['wishes'], 'paper_type' => $save['paper_type'], 'image_face' => $save['img_out_1'], 'image_back' => $save['img_out_2'], 'dop_uslugi' => $save['dop_uslugi'], 'totalSum' => $totalSum);
                redirectTo('/basket');
            } else {
                setSession('errors', $error);
                redirect();
            }
        }
    } else {
        setSession('error', 'Ошибка!');
        redirect();
    }
}