Exemplo n.º 1
0
function updateApprovedDealNotApproved($deal)
{
    $controllerDeal = new ControllerDeal();
    $controllerCatDealAssoc = new ControllerCatDealAssoc();
    $deal->title = htmlspecialchars(trim(strip_tags($_POST['title'])));
    $deal->subtitle = htmlspecialchars(trim(strip_tags($_POST['subtitle'])));
    $deal->desc = htmlspecialchars(trim(strip_tags($_POST['desc'])));
    $deal->price = htmlspecialchars(trim(strip_tags($_POST['price'])));
    $deal->price_off = htmlspecialchars(trim(strip_tags($_POST['price_off'])));
    $deal->photo_url = htmlspecialchars(trim(strip_tags($_POST['photo_url'])));
    $deal->gmt_date_added = gmdate('Y-m-d H:i:s', time());
    $deal->no_of_days_expire = htmlspecialchars(trim(strip_tags($_POST['no_of_days_expire'])));
    $deal->is_featured = htmlspecialchars(trim(strip_tags($_POST['is_featured'])));
    $deal->lat = htmlspecialchars(trim(strip_tags($_POST['lat'])));
    $deal->lon = htmlspecialchars(trim(strip_tags($_POST['lon'])));
    $deal->is_approved = 0;
    $deal->address = htmlspecialchars(trim(strip_tags($_POST['address'])));
    $deal->currency_symbol = htmlspecialchars(trim(strip_tags($_POST['currency_symbol'])));
    $deal->is_deleted = 0;
    // $deal->user_id = 0;
    $deal->updated_at = time();
    if (isset($_POST['chk_categories'])) {
        $array = $_POST['chk_categories'];
        $controllerCatDealAssoc->deleteCatDealsByDealId($deal->deal_id);
        foreach ($array as $category_id) {
            $assoc = $controllerCatDealAssoc->getCategoryDealAssocByCategoryIdAndDealId($category_id, $deal->deal_id);
            if ($assoc == null) {
                $catDeal = new CatDealAssoc();
                $catDeal->category_id = $category_id;
                $catDeal->deal_id = $deal->deal_id;
                $catDeal->created_at = time();
                $catDeal->updated_at = time();
                $catDeal->is_deleted = 0;
                $controllerCatDealAssoc->insertCategoryDealAssoc($catDeal);
            } else {
                if ($assoc->is_deleted == 1) {
                    $controllerCatDealAssoc->restoreCategoryDealAssoc($category_id, $deal->deal_id);
                }
            }
        }
    }
    if (!empty($_FILES["file_upload"]["name"])) {
        $deal->photo_url = uploadFile("file_upload", "deal_photo");
    }
    $controllerDeal->updateDeal($deal);
    echo "<script type='text/javascript'>location.href='unapproved_deals.php';</script>";
}
Exemplo n.º 2
0
<?php

require '../header_rest.php';
$controllerRest = new ControllerRest();
$controllerDeal = new ControllerDeal();
$controllerCategory = new ControllerCategory();
$controllerCatDealAssoc = new ControllerCatDealAssoc();
$controllerUser = new ControllerUser();
$categories = array();
if (!empty($_POST['category_ids'])) {
    $categories = explode(",", $_POST['category_ids']);
}
$deal_id = 0;
if (!empty($_POST['deal_id'])) {
    $deal_id = $_POST['deal_id'];
}
$desc = "";
if (!empty($_POST['desc'])) {
    $desc = $_POST['desc'];
}
$no_of_days_expire = "";
if (!empty($_POST['no_of_days_expire'])) {
    $no_of_days_expire = $_POST['no_of_days_expire'];
}
$photo_url = "";
if (!empty($_POST['photo_url'])) {
    $photo_url = $_POST['photo_url'];
}
$price = "";
if (!empty($_POST['price'])) {
    $price = $_POST['price'];