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
} else {
    if ($deal_id > 0) {
        $itm = $controllerDeal->getDealByDealId($deal_id);
        $itm->title = $title;
        $itm->subtitle = $subtitle;
        $itm->desc = $desc;
        $itm->price = $price;
        $itm->price_off = $price_off;
        $itm->photo_url = $photo_url;
        $itm->no_of_days_expire = $no_of_days_expire;
        $itm->address = $address;
        $itm->lat = $lat;
        $itm->lon = $lon;
        $itm->currency_symbol = $currency_symbol;
        $itm->updated_at = time();
        $controllerDeal->updateDeal($itm);
        $len = count($categories);
        if ($len > 0) {
            $controllerCatDealAssoc->deleteCatDealsByDealId($deal_id);
            for ($x = 0; $x < $len; $x++) {
                $catId = $categories[$x];
                $assoc = $controllerCatDealAssoc->getCategoryDealAssocByCategoryIdAndDealId($catId, $deal_id);
                if ($assoc == null) {
                    $cat = new CatDealAssoc();
                    $cat->deal_id = $deal_id;
                    $cat->category_id = $catId;
                    $cat->updated_at = time();
                    $cat->created_at = time();
                    $controllerCatDealAssoc->insertCategoryDealAssoc($cat);
                } else {
                    $controllerCatDealAssoc->restoreCategoryDealAssoc($catId, $deal_id);