Exemplo n.º 1
0
function addApprovedDeal()
{
    $controllerDeal = new ControllerDeal();
    $controllerCatDealAssoc = new ControllerCatDealAssoc();
    $deal = new Deal();
    $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 = 1;
    $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->created_at = time();
    $deal->updated_at = time();
    if (!empty($_FILES["file_upload"]["name"])) {
        $deal->photo_url = uploadFile("file_upload", "deal_photo");
    }
    $controllerDeal->insertDeal($deal);
    $deal_id = $controllerDeal->getLastInsertedId();
    if (isset($_POST['chk_categories'])) {
        $array = $_POST['chk_categories'];
        foreach ($array as $category_id) {
            $catDeal = new CatDealAssoc();
            $catDeal->category_id = $category_id;
            $catDeal->deal_id = $deal_id;
            $catDeal->created_at = time();
            $catDeal->updated_at = time();
            $catDeal->is_deleted = 0;
            $controllerCatDealAssoc->insertCategoryDealAssoc($catDeal);
        }
    }
    echo "<script type='text/javascript'>location.href='approved_deals.php';</script>";
}
Exemplo n.º 2
0
 $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->updated_at = time();
 $itm->created_at = time();
 $itm->gmt_date_added = gmdate('Y-m-d H:i:s', time());
 $itm->is_featured = 0;
 $itm->is_deleted = 0;
 $itm->is_approved = 0;
 $itm->user_id = $user_id;
 $itm->currency_symbol = $currency_symbol;
 $controllerDeal->insertDeal($itm);
 $deal_id = $controllerDeal->getLastInsertedId();
 $len = count($categories);
 if ($len > 0) {
     for ($x = 0; $x < $len; $x++) {
         $catId = $categories[$x];
         $cat = new Category();
         $cat->deal_id = $deal_id;
         $cat->category_id = $catId;
         $cat->updated_at = time();
         $cat->created_at = time();
         $controllerCatDealAssoc->insertCategoryDealAssoc($cat);
     }
 }
 $results = $controllerRest->getDealByDealId($deal_id);
 $dealObj = getJSONObject($results);
 $resultsCategories = $controllerRest->getResultAllCategories($deal_id);