/** * Генерирует случайное виео и вставляет его в базу данных * @throws Exception */ protected function addVideo() { $categories = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; shuffle($categories); $categoriesIds = implode(',', array_slice($categories, 0, rand(1, 3))); $name = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 10); $this->db->query("INSERT INTO video (name, categories) VALUES (:name, :categories)", ['name' => $name, 'categories' => $categoriesIds]); $videoId = $this->db->lastInsertId(); for ($i = 0; $i <= rand(10, 100); $i++) { $this->app->like($videoId); } for ($i = 0; $i <= rand(10, 100); $i++) { $this->app->dislike($videoId); } }
public function saveAttribute($dataForm, $attributeId = "") { global $mySession; $db = new Db(); $dataForm = SetupMagicQuotesTrim($dataForm); if ($attributeId == "") { $chkQry = $db->runQuery("select * from " . ATTRIBUTE . " where attribute_name like '%" . mysql_escape_string(trim($dataForm['attribute_name'])) . "' "); if ($chkQry != "" and count($chkQry) > 0) { //if Same Question exists than return false / 0 // No Data Inserted return 0; } else { $data = array(); $data['attribute_name'] = $dataForm['attribute_name']; $data['attribute_status'] = $dataForm['attribute_status']; $db->save(ATTRIBUTE, $data); $latestId = $db->lastInsertId(); return 1; } } else { $chkQry = $db->runQuery("select * from " . ATTRIBUTE . " where attribute_name like '%" . mysql_escape_string(trim($dataForm['attribute_name'])) . "' and attribute_id != '" . $attributeId . "' "); if ($chkQry != "" and count($chkQry) > 0) { //if Same Question exists than return false / 0 // No Data Inserted return 0; } else { $data = array(); $data['attribute_name'] = $dataForm['attribute_name']; $data['attribute_status'] = $dataForm['attribute_status']; $condition = "attribute_id = " . $attributeId; $db->modify(ATTRIBUTE, $data, $condition); return 1; } } }
public function saveReview($dataForm) { global $mySession; $db = new Db(); $data_update = array(); $chckArr = $db->runQuery("select * from " . PROPERTY . " where propertycode = '" . trim($dataForm['ppty_no']) . "' and status = '3'"); if (count($chckArr) > 0 && $chckArr != "") { $data_update['guest_name'] = $dataForm['full_name']; $data_update['location'] = $dataForm['location']; $check_in = explode("/", $dataForm['check_in']); $data_update['check_in'] = date('Y-m-d', strtotime($check_in[2] . "-" . $check_in[1] . "-" . $check_in[0])); $data_update['rating'] = $dataForm['rating']; $data_update['user_id'] = $mySession->LoggedUserId; $data_update['headline'] = $dataForm['headline']; $data_update['comment'] = $dataForm['comment']; $data_update['review'] = $dataForm['review']; $data_update['uType'] = $mySession->LoggedUserType == '1' ? "1" : "0"; $data_update['review_date'] = date("Y-m-d"); $data_update["property_id"] = $chckArr[0]['id']; $data_update['guest_image'] = $mySession->LoggedUser['image']; copy(SITE_ROOT . "images/" . $mySession->LoggedUser['image'], SITE_ROOT . "images/profile/" . $mySession->LoggedUser['image']); $db->save(OWNER_REVIEW, $data_update); $review_id = $db->lastInsertId(); //====== code to enter new latest review properties =============== //two cases are there //1. if already an entry is there within latest reviews //2. first entry is made for specific property $reviewPptyArr = $db->runQuery("select * from " . LATEST_REVIEW . " where r_property_id = '" . $chckArr[0]['id'] . "' "); //case 1 if (count($reviewPptyArr) > 0 && $reviewPptyArr != "") { $db->delete(LATEST_REVIEW, "r_id = " . $reviewPptyArr[0]['r_id']); $updateData = array(); $updateData['r_order'] = new Zend_Db_Expr('r_order-1'); $db->modify(LATEST_REVIEW, $updateData, "r_order > " . $reviewPptyArr[0]['r_order']); } else { $updateData = array(); $updateData['r_order'] = new Zend_Db_Expr('r_order+1'); $db->modify(LATEST_REVIEW, $updateData); $saveData = array(); $saveData['r_property_id'] = $chckArr[0]['id']; $saveData['r_order'] = '1'; //$saveData['r_review_id'] = $review_id; $saveData['r_status'] = '1'; $db->save(LATEST_REVIEW, $saveData); } //----------------------------------------------------------------- return 1; } else { return 0; } }
public function saveSubscription($dataForm, $subscriptionId = "") { global $mySession; $db = new Db(); $dataForm = SetupMagicQuotesTrim($dataForm); if (empty($subscriptionId)) { $data = array(); //code for inserting order $db->save("subscriber", $dataForm); $latestId = $db->lastInsertId(); return 1; } else { $condition = "subscriber_id = " . $subscriptionId; $db->modify("subscriber", $dataForm, $condition); return 2; } }
public function SaveSub($dataForm) { global $mySession; $db = new Db(); $value = $_POST['plan']; $dataForm = SetupMagicQuotes($dataForm); $chkQry = $db->runQuery("select * from " . SUBSCRIPTION . " where email_address='" . $dataForm['email_address'] . "'"); if ($chkQry != "" and count($chkQry) > 0) { return 0; } else { $dataInsert['first_name'] = $dataForm['first_name']; $dataInsert['last_name'] = $dataForm['last_name']; $dataInsert['email_address'] = $dataForm['email_address']; $dataInsert['username'] = $dataForm['username']; $dataInsert['password'] = md5($dataForm['password_o']); $dataInsert['address'] = $dataForm['address']; $dataInsert['country_id'] = $dataForm['country_id']; //$dataInsert['state_id']=$dataForm['state_id']; //$dataInsert['city_id']=$dataForm['city_id']; $dataInsert['zipcode'] = $dataForm['zipcode']; $dataInsert['phone_number'] = $dataForm['phone_number']; $dataInsert['mobile_number'] = $dataForm['mobile_number']; $dataInsert['id'] = $value; $dataInsert['date_joined'] = date('Y-m-d H:i:s'); $dataInsert['user_status'] = '1'; $dataInsert['user_type'] = $dataForm['signup_type']; $db->save(USERS, $dataInsert); $UserId = $db->lastInsertId(); //code to send registration email $fullName = $dataForm['first_name'] . ' ' . $dataForm['last_name']; $Url = '<a href="' . APPLICATION_URL . '">' . APPLICATION_URL . '</a>'; $templateData = $db->runQuery("select * from " . EMAIL_TEMPLATES . " where template_id='2'"); $messageText = $templateData[0]['email_body']; $subject = $templateData[0]['email_subject']; $messageText = str_replace("[NAME]", "<strong>" . $fullName . "</strong>", $messageText); $messageText = str_replace("[SITENAME]", "<strong>" . SITE_NAME . "</strong>", $messageText); $messageText = str_replace("[LOGINNAME]", "<strong>" . $dataForm['username'] . "</strong>", $messageText); $messageText = str_replace("[PASSWORD]", "<strong>" . $dataForm['password_o'] . "</strong>", $messageText); $messageText = str_replace("[SITEURL]", "<strong>" . $Url . "</strong>", $messageText); SendEmail($dataForm['email_address'], $subject, $messageText); //code to send registration email return $UserId; } }
public function SaveUser($dataForm) { global $mySession; $db = new Db(); $dataForm = SetupMagicQuotesTrim($dataForm); $chkQry = $db->runQuery("select * from " . USERS . " where email_address='" . $dataForm['email_address'] . "'"); if ($chkQry != "" and count($chkQry) > 0) { return 0; } else { if ($dataForm['photo'] == "") { if ($dataForm['sex'] == '2') { $noImage = "defaultuserfemaleprofile.png"; } else { $noImage = "defaultusermaleprofile.png"; } } else { $imageNewName = time() . "_" . $dataForm['photo']; @rename(SITE_ROOT . 'images/' . $dataForm['photo'], SITE_ROOT . 'images/' . $imageNewName); $noImage = $imageNewName; } $dataInsert['uType'] = $dataForm['uType']; $dataInsert['first_name'] = $dataForm['first_name']; $dataInsert['last_name'] = $dataForm['last_name']; $dataInsert['title'] = $dataForm['title']; $dataInsert['email_address'] = $dataForm['email_address']; $dataInsert['password'] = md5($dataForm['password']); $dataInsert['country_id'] = $dataForm['country_id']; $dataInsert['state_id'] = $dataForm['state_id']; $dataInsert['city_id'] = $dataForm['city_id']; $dataInsert['zipcode'] = $dataForm['zipcode']; $dataInsert['home_number'] = $dataForm['home_number']; $dataInsert['work_number'] = $dataForm['work_number']; $dataInsert['mobile_number'] = $dataForm['mobile_number']; $dataInsert['web'] = $dataForm['webaddress']; $dataInsert['address'] = $dataForm['address']; $dataInsert['date_joined'] = date("Y-m-d H:i:s"); $dataInsert['image'] = $noImage; $dataInsert['user_status'] = '1'; $db->save(USERS, $dataInsert); return $db->lastInsertId(); } }
public function SaveEvent($dataForm) { global $mySession; $db = new Db(); $chkQry = $db->runQuery("select * from " . EVENTS . " where event_title='" . mysql_escape_string($dataForm['event_title']) . "'"); if ($chkQry != "" and count($chkQry) > 0) { return 0; } else { $EventImagesPath = ""; for ($counter = 1; $counter <= 10; $counter++) { $eventImage = $dataForm['event_image_Path' . $counter]; if ($dataForm['event_image' . $counter] != "") { $eventImage = time() . "_" . $dataForm['event_image' . $counter]; @rename(SITE_ROOT . 'images/events/' . $dataForm['event_image' . $counter], SITE_ROOT . 'images/events/' . $eventImage); } if ($eventImage != "") { $EventImagesPath .= $eventImage . ","; } } if ($EventImagesPath != "") { $EventImagesPath = substr($EventImagesPath, 0, strlen($EventImagesPath) - 1); } if ($mySession->LoggedUserId > 0) { $dataInsert['user_id'] = $mySession->LoggedUserId; } $dataInsert['event_title'] = $dataForm['event_title']; $dataInsert['event_description'] = $dataForm['event_description']; $dataInsert['event_date'] = changeDate($dataForm['event_date'], 0); $dataInsert['event_time_from'] = $dataForm['hour_from'] . "::" . $dataForm['minute_from'] . "::" . $dataForm['ampm_from']; $dataInsert['event_time_to'] = $dataForm['hour_to'] . "::" . $dataForm['minute_to'] . "::" . $dataForm['ampm_to']; $dataInsert['event_image'] = $EventImagesPath; $dataInsert['event_venue'] = $dataForm['event_venue']; $dataInsert['event_location'] = $dataForm['address']; $dataInsert['event_status'] = '1'; $dataInsert['date_event_added'] = date('Y-m-d H:i:s'); $dataInsert['event_lat'] = $dataForm['latitude']; $dataInsert['event_long'] = $dataForm['longitude']; $db->save(EVENTS, $dataInsert); return $db->lastInsertId(); } }
protected function insert() { $cols = array_keys($this->data); $data = []; foreach ($cols as $col) { $data[':' . $col] = $this->data[$col]; } // INSERT INTO table_name (col_name, ...) VALUES (:col_name, ...) $sql = ' INSERT INTO ' . static::$table . ' (' . implode(', ', $cols) . ') VALUES (' . implode(', ', array_keys($data)) . ') '; $db = new Db(); $res = $db->execute($sql, $data); if (false === $res) { return false; } $this->id = $db->lastInsertId(); return true; }
public function savedesignimageAction() { global $mySession; $db = new Db(); $manage_image_name = array(); if (isset($_REQUEST["frontImage"]) && !empty($_REQUEST["frontImage"])) { $frontImageName = $_REQUEST['frontFileName'] . "_" . rand(10, 100) . '.png'; $frontImage = $_POST["frontImage"]; $this->saveDataUrlUserDesign($frontImage, $frontImageName); $manage_image_name['frontimage'] = $frontImageName; } if (isset($_REQUEST["backImage"]) && !empty($_REQUEST["backImage"])) { $backImageName = $_REQUEST['backFileName'] . "_" . rand(10, 100) . '.png'; $backImage = $_POST["backImage"]; $this->saveDataUrlUserDesign($backImage, $backImageName); $manage_image_name['backimage'] = $backImageName; } $db->save(MANAGEIMAGENAME, $manage_image_name); $manage_image_name['mig_id'] = $db->lastInsertId(); echo json_encode($manage_image_name); exit; }
</h4> <pre> <code class="lang-php"> <?php $DB->lastInsertId(); ?> </code> </pre> <p> Result: </p> <pre> <code class="lang-php"> ID for array("color"=>"yellow","name"=>"mango","id"=>null): <?php echo $DB->lastInsertId(); ?> </code> </pre> <h4> Get the number of queries since the object initialization </h4> <pre> <code class="lang-php"> <?php $DB->querycount; ?> </code> </pre> <p> Result:
public function SaveUser($dataForm, $SignUpfor) { global $mySession; $db = new Db(); $dataForm = SetupMagicQuotesTrim($dataForm); if ($dataForm['photo'] == "") { if ($dataForm['sex'] == '2') { $noImage = "defaultuserfemaleprofile.png"; } else { $noImage = "defaultusermaleprofile.png"; } } else { $imageNewName = time() . "_" . $dataForm['photo']; @rename(SITE_ROOT . 'images/' . $dataForm['photo'], SITE_ROOT . 'images/' . $imageNewName); $noImage = $imageNewName; } // $chkQry=$db->runQuery("select * from ".USERS." where email_address='".mysql_escape_string($dataForm['email_address'])."'"); /* if($chkQry!="" and count($chkQry)>0) { return 0; } else { */ $dataInsert['uType'] = $SignUpfor; //$dataInsert['username']=$dataForm['username']; $dataInsert['first_name'] = $dataForm['first_name']; $dataInsert['last_name'] = $dataForm['last_name']; $dataInsert['title'] = $dataForm['title']; $dataInsert['email_address'] = $dataForm['email_address']; $dataInsert['password'] = md5($dataForm['password']); $dataInsert['country_id'] = $dataForm['country_id']; $dataInsert['state_id'] = $dataForm['state_id']; $dataInsert['city_id'] = $dataForm['city_id']; $dataInsert['zipcode'] = $dataForm['zipcode']; $dataInsert['home_number'] = $dataForm['home_number']; $dataInsert['work_number'] = $dataForm['work_number']; $dataInsert['mobile_number'] = $dataForm['mobile_number']; //$dataInsert['sex']=$dataForm['sex']; $dataInsert['address'] = $dataForm['address']; $dataInsert['web'] = $dataForm['webaddress']; $dataInsert['date_joined'] = date("Y-m-d H:i:s"); $dataInsert['image'] = $noImage; $dataInsert['user_status'] = '0'; /*$lat_long = getLatLongFromAddress($dataInsert['country_id'],$dataInsert['state_id'],$dataInsert['city_id'],$dataInsert['address']); $lat_long = explode("::",$lat_long); $dataInsert['cletitude'] = $lat_long[0]; $dataInsert['clongitude'] = $lat_long[1];*/ $db->save(USERS, $dataInsert); $UserId = $db->lastInsertId(); $dataUpdate['password_reset'] = md5($UserId); $condition = " user_id = " . $UserId; $db->modify(USERS, $dataUpdate, $condition); $fullName = $dataForm['email_address']; $Url = '<a href="' . APPLICATION_URL . '">' . APPLICATION_URL . '</a>'; //$ActivationLink='<a href="'.APPLICATION_URL.'signup/activate/cId/'.md5($UserId).':'.$SignUpfor.'">'.APPLICATION_URL.'signup/activate/cId/'.md5($UserId).':'.$SignUpfor.'</a>'; $ActivationLink = APPLICATION_URL . 'signup/activate/cId/' . md5($UserId); $templateData = $db->runQuery("select * from " . EMAIL_TEMPLATES . " where template_id='4'"); $messageText = $templateData[0]['email_body']; $subject = $templateData[0]['email_subject']; $messageText = str_replace("[NAME]", $fullName, $messageText); $messageText = str_replace("[SITENAME]", SITE_NAME, $messageText); $messageText = str_replace("[SITEURL]", $Url, $messageText); $messageText = str_replace("[ACTIVATIONLINK]", $ActivationLink, $messageText); if (IS_LIVE) { $retnvalue = SendEmail($dataForm['email_address'], $subject, $messageText); } return $UserId; }
public function copyProperty($ppty_no, $param1, $param2, $param3, $param4) { global $mySession; $db = new Db(); $chkQuery = $db->runQuery("select * from " . PROPERTY . " where propertycode = '" . $ppty_no . "' "); //step1 is saved in database $data_update['propertycode'] = generate_property_no($mySession->LoggedUserId); $data_update['property_type'] = $chkQuery[0]['property_type']; $data_update['property_title'] = $chkQuery[0]['property_title']; //$data_update['telephone'] = $dataForm['telephone']; $data_update['website'] = $chkQuery[0]['website']; $data_update['brief_desc'] = $chkQuery[0]['brief_desc']; $data_update['country_id'] = $chkQuery[0]['country_id']; $data_update['state_id'] = $chkQuery[0]['state_id']; $data_update['city_id'] = $chkQuery[0]['city_id']; $data_update['sub_area_id'] = $chkQuery[0]['sub_area_id']; $data_update['local_area_id'] = $chkQuery[0]['local_area_id']; $data_update['zipcode'] = $chkQuery[0]['zipcode']; $data_update['date_added'] = date('Y-m-d'); /* other details */ $data_update['bedrooms'] = $chkQuery[0]['bedrooms']; $data_update['bathrooms'] = $chkQuery[0]['bathrooms']; $data_update['en_bedrooms'] = $chkQuery[0]['en_bedrooms']; $data_update['maximum_occupancy'] = $chkQuery[0]['maximum_occupancy']; $meta_keywords = $chkQuery[0]['property_title'] . ", " . $chkQuery[0]['bedrooms'] . " bedrooms, " . $chkQuery[0]['bathrooms'] . " bathrooms, " . $chkQuery[0]['property_type'] . ", " . $data_update['propertycode']; $meta_description = substr($chkQuery[0]['brief_desc'], 0, 200); $data_update['meta_keywords'] = addslashes($meta_keywords); $data_update['meta_description'] = addslashes($meta_description); //$data_update['status'] = '1'; $data_update['star_rating'] = $chkQuery[0]['star_rating']; $data_update['user_id'] = $mySession->LoggedUserId; $data_update['status_2'] = $chkQuery[0]['status_2']; //prd($data_update); //step 3 $data_update['big_desc'] = $chkQuery[0]['big_desc']; $data_update['amenity_ques'] = $chkQuery[0]['amenity_ques']; $data_update['airport1'] = $chkQuery[0]['airport1']; $data_update['airport2'] = $chkQuery[0]['airport2']; $data_update['distance_airport1'] = $chkQuery[0]['distance_airport1']; $data_update['distance_airport2'] = $chkQuery[0]['distance_airport2']; $data_update['status_3'] = $chkQuery[0]['status_3']; //step 4 $data_update['cletitude'] = $chkQuery[0]['cletitude']; $data_update['clongitude'] = $chkQuery[0]['clongitude']; $data_update['address'] = $chkQuery[0]['address']; $data_update['status_4'] = $chkQuery[0]['status_4']; //step 5 if ($chkQuery[0]['floor_plan'] != "") { $tmp_name = explode(".", $chkQuery[0]['floor_plan']); $randomname = "floorplan_" . $chkQuery[0]['user_id'] . "_" . time() . "." . $tmp_name[count($tmp_name) - 1]; $chkQuery[0]['floor_plan']; copy(SITE_ROOT . "images/floorplan/" . $chkQuery[0]['floor_plan'], SITE_ROOT . "images/floorplan/" . $randomname); $data_update['floor_plan'] = $randomname; } //step 7 $data_update['currency_code'] = $chkQuery[0]['currency_code']; //step 8 $data_update['rental_ques'] = $chkQuery[0]['rental_ques']; //step 9 $data_update['agent_person'] = $chkQuery[0]['agent_person']; $data_update['agent_name'] = $chkQuery[0]['agent_name']; $data_update['agent_phone'] = $chkQuery[0]['agent_phone']; $data_update['agent_address'] = $chkQuery[0]['agent_address']; $data_update['agent_email'] = $chkQuery[0]['agent_email']; $data_update['agent_website'] = $chkQuery[0]['agent_website']; $data_update['property_name'] = $chkQuery[0]['property_name']; $data_update['address1'] = $chkQuery[0]['address1']; $data_update['telephone'] = $chkQuery[0]['telephone']; $data_update['emergency_no'] = $chkQuery[0]['emergency_no']; $data_update['website'] = $chkQuery[0]['website']; $data_update['master_cal_url'] = $chkQuery[0]['master_cal_url']; /* instruction details */ $data_update['directions_to_property'] = $chkQuery[0]['directions_to_property']; $data_update['late_arrival_instruction'] = $chkQuery[0]['late_arrival_instruction']; if ($chkQuery[0]['arrival_instruction'] != "") { $tmp_name = explode(".", $chkQuery[0]['arrival_instruction']); $randomname = $tmp_name[0] . date() . time() . "." . $tmp_name[count($tmp_name) - 1]; copy(SITE_ROOT . "uploads/instructions/" . $chkQuery[0]['arrival_instruction'], SITE_ROOT . "uploads/instructions/" . $randomname); $data_update['arrival_instruction'] = $randomname; } if ($chkQuery[0]['arrival_instruction1'] != "") { $tmp_name = explode(".", $chkQuery[0]['arrival_instruction1']); $randomname = $tmp_name[0] . date() . time() . "." . $tmp_name[count($tmp_name) - 1]; copy(SITE_ROOT . "uploads/instructions/" . $chkQuery[0]['arrival_instruction1'], SITE_ROOT . "uploads/instructions/" . $randomname); $data_update['arrival_instruction1'] = $randomname; } if ($chkQuery[0]['arrival_instruction2'] != "") { $tmp_name = explode(".", $chkQuery[0]['arrival_instruction2']); $randomname = $tmp_name[0] . date() . time() . "." . $tmp_name[count($tmp_name) - 1]; copy(SITE_ROOT . "uploads/instructions/" . $chkQuery[0]['arrival_instruction2'], SITE_ROOT . "uploads/instructions/" . $randomname); $data_update['arrival_instruction2'] = $randomname; } $data_update['key_instructions'] = $chkQuery[0]['key_instructions']; $data_update['status_9'] = $chkQuery[0]['status_9']; $db->save(PROPERTY, $data_update); $mySession->property_id = $db->lastInsertId(); $mySession->ppty_no = $data_update['propertycode']; //$mySession->step = '1'; //COPY SPECIFICATION $specArr = $db->runQuery("select * from " . SPEC_ANS . " where property_id = '" . $chkQuery[0]['id'] . "' "); foreach ($specArr as $val) { $data_update1['user_id'] = $mySession->LoggedUserId; $data_update1['property_id'] = $mySession->property_id; $data_update1['spec_id'] = $val['spec_id']; $data_update1['answer'] = $val['answer']; $db->save(SPEC_ANS, $data_update1); } //COPY AMENITY STEP $amenityArr = $db->runQuery("select * from " . AMENITY_ANS . " where property_id = '" . $chkQuery[0]['id'] . "' "); $data_update1 = array(); foreach ($amenityArr as $val) { $data_update1['user_id'] = $mySession->LoggedUserId; $data_update1['property_id'] = $mySession->property_id; $data_update1['amenity_id'] = $val['amenity_id']; $data_update1['amenity_value'] = $val['amenity_value']; $db->save(AMENITY_ANS, $data_update1); } //IMAGE UPLOAD STEP 5 if ($param4 == '1') { $galleryArr = $db->runQuery("select * from " . GALLERY . " where property_id = '" . $chkQuery[0]['id'] . "' "); $data_update1 = array(); foreach ($galleryArr as $val) { $data_update1['property_id'] = $mySession->property_id; //code for duplicating image as well as naming it $gimage = explode(".", $val['image_name']); $randomname = date() . time() . $val['gallery_id'] . "." . $gimage[count($gimage) - 1]; copy(SITE_ROOT . "images/property/" . $val['image_name'], SITE_ROOT . "images/property/" . $randomname); $data_update1['image_name'] = $randomname; $data_update1['image_title'] = $val['image_title']; $db->save(GALLERY, $data_update1); } $status_update = ""; $status_update['status_5'] = $chkQuery[0]['status_5']; $condition = "id=" . $mySession->property_id; $db->modify(PROPERTY, $status_update, $condition); } //AVAILABILITY CALENDAR STEP 6 if ($param2 == '1') { $galleryArr = $db->runQuery("select * from " . CAL_AVAIL . " where property_id = '" . $chkQuery[0]['id'] . "' "); $data_update1 = array(); foreach ($galleryArr as $val) { $data_update1['property_id'] = $mySession->property_id; $data_update1['date_from'] = $val['date_from']; $data_update1['date_to'] = $val['date_to']; $data_update1['cal_status'] = $val['cal_status']; $db->save(CAL_AVAIL, $data_update1); } $status_update = ""; //step 6 $status_update['cal_default'] = $chkQuery[0]['cal_default']; $status_update['status_6'] = $chkQuery[0]['status_6']; $condition = "id=" . $mySession->property_id; $db->modify(PROPERTY, $status_update, $condition); } //RENTAL RATES STEP 7 if ($param1 == '1') { $rateArr = $db->runQuery("select * from " . CAL_RATE . " where property_id = '" . $chkQuery[0]['id'] . "' "); $data_update1 = array(); foreach ($rateArr as $val) { $data_update1['property_id'] = $mySession->property_id; $data_update1['date_from'] = $val['date_from']; $data_update1['date_to'] = $val['date_to']; $data_update1['nights'] = $val['nights']; $data_update1['prate'] = $val['prate']; $db->save(CAL_RATE, $data_update1); } //save extras $extraArr = $db->runQuery("select * from " . EXTRAS . " where property_id = '" . $chkQuery[0]['id'] . "' "); $data_update1 = array(); foreach ($extraArr as $eval) { $data_update1['property_id'] = $mySession->property_id; $data_update1['ename'] = $eval['ename']; $data_update1['eprice'] = $eval['eprice']; $data_update1['etype'] = $eval['etype']; $data_update1['stay_type'] = $eval['stay_type']; $db->save(EXTRAS, $data_update1); } $status_update = ""; $status_update['status_7'] = $chkQuery[0]['status_7']; $condition = "id=" . $mySession->property_id; $db->modify(PROPERTY, $status_update, $condition); } //RENTAL RATES EXTRAS STEP7 $extrasArr = $db->runQuery("select * from " . EXTRAS . " where property_id = '" . $chkQuery[0]['id'] . "' "); $data_update1 = array(); foreach ($extrasArr as $val) { $data_update1['property_id'] = $mySession->property_id; $data_update1['ename'] = $val['ename']; $data_update1['eprice'] = $val['eprice']; $data_update1['etype'] = $val['etype']; $db->save(EXTRAS, $data_update1); } //SPECIAL OFFERS STEP 7 if ($param3 == '1') { $offerArr = $db->runQuery("select * from " . SPCL_OFFERS . " where property_id = '" . $chkQuery[0]['id'] . "' "); $data_update1 = array(); foreach ($offerArr as $val) { $data_update1['property_id'] = $mySession->property_id; $data_update1['offer_id'] = $val['offer_id']; $data_update1['discount_offer'] = $val['discount_offer']; $data_update1['valid_from'] = $val['valid_from']; $data_update1['valid_to'] = $val['valid_to']; $data_update1['min_night'] = $val['min_night']; $data_update1['book_by'] = $val['book_by']; $data_update1['activate'] = $val['activate']; $db->save(SPCL_OFFERS, $data_update1); } } //code to check the status of the current property in process $chkstatusArr = $db->runQuery("select * from " . PROPERTY . " where id = '" . $mySession->property_id . "' "); if ($chkstatusArr[0]['status_2'] && $chkstatusArr[0]['status_3'] && $chkstatusArr[0]['status_4'] && $chkstatusArr[0]['status_5'] && $chkstatusArr[0]['status_6'] && $chkstatusArr[0]['status_7'] && $chkstatusArr[0]['status_8'] && $chkstatusArr[0]['status_9']) { $status_update = ""; $status_update['status'] = '2'; $condition = "id=" . $mySession->property_id; $db->modify(PROPERTY, $status_update, $condition); } else { $status_update = ""; $status_update['status'] = '1'; $condition = "id=" . $mySession->property_id; $db->modify(PROPERTY, $status_update, $condition); } }
public function saveproductAction() { global $mySession; $db = new Db(); $id = $this->getRequest()->getParam('id'); if ($id == "") { $this->view->pageHeading = "Add Tshirt Products"; } else { $this->view->pageHeading = "Edit Tshirt Products"; } if ($this->getRequest()->isPost()) { $request = $this->getRequest(); if ($id == "") { $myform = new Form_Tshirtcategory(); } else { $myform = new Form_Tshirtcategory($id); } if ($myform->isValid($request->getPost())) { $dataForm = $myform->getValues(); $Result = ''; // front Images if ($dataForm['image'] != "") { $widthFront = ''; $heightFront = ''; $profileImagefront = time() . "_" . $dataForm['image']; error_log('saveproductAction FRONT image: ' . $dataForm['image'] . ', will be renamed to ' . $profileImagefront); @rename(SITE_ROOT . 'images/tshirtdesigns/front/' . $dataForm['image'], SITE_ROOT . 'images/tshirtdesigns/front/' . $profileImagefront); $imagefront = IMAGES_URL . "tshirtdesigns/front/" . $profileImagefront; $info2 = getimagesize($imagefront); $width2 = $info2[0]; $height2 = $info2[1]; $widthFront = $info2[0]; $heightFront = $info2[1]; if ($width2 > 450 && $height2 > 420) { unlink(SITE_ROOT . 'images/tshirtdesigns/front/' . $profileImagefront); $mySession->errorMsg = "Front image height or width exceedes from Maximum-height=420 and/or Maximum-Width=450"; $this->view->myform = $myform; if ($id != '') { $this->view->id = $id; } $this->_redirect('tshirt/tshirtproduct'); } // frontHeigh if ($dataForm['frontHeigh'] != "") { $profileImagefront = time() . "_FH_" . $dataForm['frontHeigh']; error_log('saveproductAction FRONT highlight: ' . $dataForm['frontHeigh'] . ', will be renamed to ' . $profileImagefront); @rename(SITE_ROOT . 'images/tshirtdesigns/front/' . $dataForm['frontHeigh'], SITE_ROOT . 'images/tshirtdesigns/front/' . $profileImagefront); $imagefront = IMAGES_URL . "tshirtdesigns/front/" . $profileImagefront; $info2 = getimagesize($imagefront); $width2 = @$info2[0]; $height2 = @$info2[1]; if ($width2 != $widthFront && $height2 != $heightFront) { unlink(SITE_ROOT . 'images/tshirtdesigns/front/' . $profileImagefront); $mySession->errorMsg = "Highlighted Front image height or width should be similar to basic image : height=" . $heightFront . " VS height=" . $height2 . ", width=" . $widthFront . " VS width=" . $width2; $this->view->myform = $myform; if ($id != '') { $this->view->id = $id; } $this->_redirect('tshirt/tshirtproduct'); } } //shadow front if ($dataForm['frontShadow'] != "") { $profileImagefront = time() . "_FS_" . $dataForm['frontShadow']; error_log('saveproductAction FRONT shadow: ' . $dataForm['frontShadow'] . ', will be renamed to ' . $profileImagefront); @rename(SITE_ROOT . 'images/tshirtdesigns/front/' . $dataForm['frontShadow'], SITE_ROOT . 'images/tshirtdesigns/front/' . $profileImagefront); $imagefront = IMAGES_URL . "tshirtdesigns/front/" . $profileImagefront; $info2 = getimagesize($imagefront); $width2 = @$info2[0]; $height2 = @$info2[1]; if ($width2 != $widthFront && $height2 != $heightFront) { unlink(SITE_ROOT . 'images/tshirtdesigns/front/' . $profileImagefront); $mySession->errorMsg = "Shadow Front image height or width should be similar to basic image : height=" . $heightFront . " VS height=" . $height2 . ", width=" . $widthFront . " VS width=" . $width2; $this->view->myform = $myform; if ($id != '') { $this->view->id = $id; } $this->_redirect('tshirt/tshirtproduct'); } } } // Back if ($dataForm['backimage'] != "") { error_log('saveproductAction BACK image set'); $widthBack = ''; $heightBack = ''; $profileImagefront = time() . "_" . $dataForm['backimage']; error_log('saveproductAction BACK image: ' . $dataForm['backimage'] . ', will be renamed to ' . $profileImagefront); @rename(SITE_ROOT . 'images/tshirtdesigns/back/' . $dataForm['backimage'], SITE_ROOT . 'images/tshirtdesigns/back/' . $profileImagefront); $imagefront = IMAGES_URL . "tshirtdesigns/back/" . $profileImagefront; $info2 = getimagesize($imagefront); $width2 = @$info2[0]; $height2 = @$info2[1]; $widthBack = @$info2[0]; $heightBack = @$info2[1]; if ($width2 > 450 && $height2 > 420) { unlink(SITE_ROOT . 'images/tshirtdesigns/back/' . $profileImagefront); $mySession->errorMsg = "Back image height or width is exceeded from Maximum-height=420, Maximum-Width=450"; $this->view->myform = $myform; if ($id != '') { $this->view->id = $id; } $this->_redirect('tshirt/tshirtproduct'); } // Highlight if ($dataForm['backHeigh'] != "") { $profileImagefront = time() . "_BH_" . $dataForm['backHeigh']; error_log('saveproductAction BACK highlight: ' . $dataForm['backHeigh'] . ', will be renamed to ' . $profileImagefront); @rename(SITE_ROOT . 'images/tshirtdesigns/back/' . $dataForm['backHeigh'], SITE_ROOT . 'images/tshirtdesigns/back/' . $profileImagefront); $imagefront = IMAGES_URL . "tshirtdesigns/back/" . $profileImagefront; $info2 = getimagesize($imagefront); $width2 = @$info2[0]; $height2 = @$info2[1]; if ($width2 != $widthBack && $height2 != $heightBack) { unlink(SITE_ROOT . 'images/tshirtdesigns/back/' . $profileImagefront); $mySession->errorMsg = "Highlighted Back image height or width should be similar to basic image : height=" . $heightBack . " VS height=" . $height2 . ", width=" . $widthBack . " VS width=" . $width2; $this->view->myform = $myform; if ($id != '') { $this->view->id = $id; } $this->_redirect('tshirt/tshirtproduct'); } } //shadow if ($dataForm['backShadow'] != "") { $profileImagefront = time() . "_BS_" . $dataForm['backShadow']; error_log('saveproductAction BACK shadow: ' . $dataForm['backShadow'] . ', will be renamed to ' . $profileImagefront); @rename(SITE_ROOT . 'images/tshirtdesigns/back/' . $dataForm['backShadow'], SITE_ROOT . 'images/tshirtdesigns/back/' . $profileImagefront); $imagefront = IMAGES_URL . "tshirtdesigns/back/" . $profileImagefront; $info2 = getimagesize($imagefront); $width2 = @$info2[0]; $height2 = @$info2[1]; if ($width2 != $widthBack && $height2 != $heightBack) { unlink(SITE_ROOT . 'images/tshirtdesigns/back/' . $profileImagefront); $mySession->errorMsg = "Shadow Front image height or width should be similar to basic image : height=" . $heightBack . ", Width=" . $widthBack; $this->view->myform = $myform; if ($id != '') { $this->view->id = $id; } $this->_redirect('tshirt/tshirtproduct'); } } } if ($id == "") { // SAVING NEW, PREVIOUSLY NOT EXISTING PRODUCT error_log('saveproductAction, SAVING NEW, PREVIOUSLY NOT EXISTING PRODUCT'); // Front Main $profileImage = $dataForm['image']; if ($dataForm['image'] != "") { $profileImage = time() . "_" . $profileImage; @rename(SITE_ROOT . 'images/tshirtdesigns/front/' . $dataForm['image'], SITE_ROOT . 'images/tshirtdesigns/front/' . $profileImage); } // Front Highlighted $profileImageHeigh = $dataForm['frontHeigh']; if ($dataForm['frontHeigh'] != "") { $profileImageHeigh = time() . "_FH_" . $profileImageHeigh; @rename(SITE_ROOT . 'images/tshirtdesigns/front/' . $dataForm['frontHeigh'], SITE_ROOT . 'images/tshirtdesigns/front/' . $profileImageHeigh); $dataInsert['frontHeigh'] = $profileImageHeigh; } // Front Shadow $profileImageShadow = $dataForm['frontShadow']; if ($dataForm['frontShadow'] != "") { $profileImageShadow = time() . "_FS_" . $profileImageShadow; @rename(SITE_ROOT . 'images/tshirtdesigns/front/' . $dataForm['frontShadow'], SITE_ROOT . 'images/tshirtdesigns/front/' . $profileImageShadow); $dataInsert['frontShadow'] = $profileImageShadow; } // Back if ($_REQUEST['checkData1'] == true && $_REQUEST['checkData1'] == 'backimageData777') { // Back main $backImage = $dataForm['backimage']; if ($dataForm['backimage'] != "") { $backImage = time() . "_" . $backImage; @rename(SITE_ROOT . 'images/tshirtdesigns/back/' . $dataForm['backimage'], SITE_ROOT . 'images/tshirtdesigns/back/' . $backImage); } // Back Highlighted $backImageHeigh = $dataForm['backHeigh']; if ($dataForm['backHeigh'] != "") { $backImageHeigh = time() . "_BH_" . $backImageHeigh; @rename(SITE_ROOT . 'images/tshirtdesigns/back/' . $dataForm['backHeigh'], SITE_ROOT . 'images/tshirtdesigns/back/' . $backImageHeigh); $dataInsert['backHeigh'] = $backImageHeigh; } // Back Shadow $backImageShadow = $dataForm['backShadow']; if ($dataForm['backShadow'] != "") { $backImageShadow = time() . "_BS_" . $backImageShadow; @rename(SITE_ROOT . 'images/tshirtdesigns/back/' . $dataForm['backShadow'], SITE_ROOT . 'images/tshirtdesigns/back/' . $backImageShadow); $dataInsert['backShadow'] = $backImageShadow; } } if ($backImage != '' && $_REQUEST['checkData1'] == 'backimageData777') { $dataInsert['backimage'] = $backImage; $dataInsert['totalimage'] = '2'; } else { $dataInsert['totalimage'] = '1'; } $dataInsert['image'] = $profileImage; $dataInsert['name'] = $dataForm['title']; $dataInsert['colorcode'] = $dataForm['colorcode']; $dataInsert['status'] = 1; $dataInsert['date_added'] = date('y-m-d'); //error_log('saveproductAction, dataInsert: '.print_r($dataInsert, true)); $Result = $db->save(TSHIRT_PRODUCTS, $dataInsert); $ProductIdKM = $db->lastInsertId(); //error_log('saveproductAction, $ProductIdKM: '.$ProductIdKM); if ($Result > 0 && $ProductIdKM > 0) { $dataInsertPrice['base_price'] = $dataForm['base_price']; $dataInsertPrice['shipping_price'] = $dataForm['shippingprice']; $dataInsertPrice['campagin_id'] = $ProductIdKM; $db->save(TSHIRT_PRICE, $dataInsertPrice); $mySession->errorMsg = "Added successfully."; } } else { // UPDATING ALREADY EXISTING PRODUCT error_log('saveproductAction, UPDATING ALREADY EXISTING PRODUCT'); // Front if ($dataForm['image'] != "" && $dataForm['oldicon'] != "") { unlink(SITE_ROOT . 'images/tshirtdesigns/front/' . $dataForm['oldicon']); } $profileImage = $dataForm['oldicon']; if ($dataForm['image'] != "") { $profileImage = time() . "_" . $dataForm['image']; @rename(SITE_ROOT . 'images/tshirtdesigns/front/' . $dataForm['image'], SITE_ROOT . 'images/tshirtdesigns/front/' . $profileImage); } if ($dataForm['frontHeigh'] != "" && $dataForm['oldfrontHeigh'] != "") { unlink(SITE_ROOT . 'images/tshirtdesigns/front/' . $dataForm['oldfrontHeigh']); } $profileImageFH = $dataForm['oldfrontHeigh']; if ($dataForm['frontHeigh'] != "") { $profileImageFH = time() . "_FH_" . $dataForm['frontHeigh']; @rename(SITE_ROOT . 'images/tshirtdesigns/front/' . $dataForm['frontHeigh'], SITE_ROOT . 'images/tshirtdesigns/front/' . $profileImageFH); $dataInsert['frontHeigh'] = $profileImageFH; } if ($dataForm['frontShadow'] != "" && $dataForm['oldfrontHeigh'] != "") { unlink(SITE_ROOT . 'images/tshirtdesigns/front/' . $dataForm['oldfrontHeigh']); } $profileImageFS = $dataForm['oldfrontShadow']; if ($dataForm['frontShadow'] != "") { $profileImageFS = time() . "_FS_" . $dataForm['frontShadow']; @rename(SITE_ROOT . 'images/tshirtdesigns/front/' . $dataForm['frontShadow'], SITE_ROOT . 'images/tshirtdesigns/front/' . $profileImageFS); $dataInsert['frontShadow'] = $profileImageFS; } if ($_REQUEST['checkData1'] == true && $_REQUEST['checkData1'] == 'backimageData777') { $qry = "select * from " . TSHIRT_PRODUCTS . " where t_cat_id='" . $id . "'"; $sql = $db->runquery($qry); // Back Image if ($dataForm['backimage'] != "" && $dataForm['backoldicon'] != "") { unlink(SITE_ROOT . 'images/tshirtdesigns/back/' . $dataForm['backoldicon']); } else { if ($dataForm['backimage'] == "" && $dataForm['backoldicon'] == "" && $sql[0]['backimage'] != "") { unlink(SITE_ROOT . 'images/tshirtdesigns/back/' . $sql[0]['backimage']); } } if ($dataForm['backoldicon'] != '') { $backImage = $dataForm['backoldicon']; } if ($dataForm['backimage'] != "") { $backImage = time() . "_" . $dataForm['backimage']; @rename(SITE_ROOT . 'images/tshirtdesigns/back/' . $dataForm['backimage'], SITE_ROOT . 'images/tshirtdesigns/back/' . $backImage); } // Back Highlight if ($dataForm['backHeigh'] != "" && $dataForm['oldbacktHeigh'] != "") { unlink(SITE_ROOT . 'images/tshirtdesigns/back/' . $dataForm['oldbacktHeigh']); } else { if ($dataForm['backHeigh'] == "" && $dataForm['oldbacktHeigh'] == "" && $sql[0]['backHeigh'] != "") { unlink(SITE_ROOT . 'images/tshirtdesigns/back/' . $sql[0]['backHeigh']); } } if ($dataForm['oldbacktHeigh'] != '') { $backImageBH = $dataForm['oldbacktHeigh']; } if ($dataForm['backHeigh'] != "") { $backImageBH = time() . "_BH_" . $dataForm['backHeigh']; @rename(SITE_ROOT . 'images/tshirtdesigns/back/' . $dataForm['backHeigh'], SITE_ROOT . 'images/tshirtdesigns/back/' . $backImageBH); } $dataInsert['backHeigh'] = $backImageBH; // Back Shadow if ($dataForm['backShadow'] != "" && $dataForm['oldbackShadow'] != "") { unlink(SITE_ROOT . 'images/tshirtdesigns/back/' . $dataForm['oldbackShadow']); } else { if ($dataForm['backShadow'] == "" && $dataForm['oldbackShadow'] == "" && $sql[0]['backShadow'] != "") { unlink(SITE_ROOT . 'images/tshirtdesigns/back/' . $sql[0]['backHeigh']); } } if ($dataForm['oldbackShadow'] != '') { $backImageBS = $dataForm['oldbackShadow']; } if ($dataForm['backShadow'] != "") { $backImageBS = time() . "_BS_" . $dataForm['backShadow']; @rename(SITE_ROOT . 'images/tshirtdesigns/back/' . $dataForm['backShadow'], SITE_ROOT . 'images/tshirtdesigns/back/' . $backImageBS); } $dataInsert['backShadow'] = $backImageBS; } if ($backImage != '' && $_REQUEST['checkData1'] == 'backimageData777') { $dataInsert['backimage'] = $backImage; $dataInsert['totalimage'] = '2'; } else { $dataInsert['totalimage'] = '1'; } $dataInsert['image'] = $profileImage; $dataInsert['name'] = $dataForm['title']; $dataInsert['colorcode'] = $dataForm['colorcode']; $conditionUpdate = "t_cat_id='" . $id . "'"; //error_log('saveproductAction, dataInsert: '.print_r($dataInsert, true)); $Result = $db->modify(TSHIRT_PRODUCTS, $dataInsert, $conditionUpdate); if ($Result > 0) { $mySession->errorMsg = "Updated successfully."; } $dataUpdatePrice['base_price'] = $dataForm['base_price']; $dataUpdatePrice['shipping_price'] = $dataForm['shippingprice']; //$dataUpdate['page_position']=$dataForm['pageposition']; $conditionUpdatePrice = "campagin_id='" . $id . "'"; $db->modify(TSHIRT_PRICE, $dataUpdatePrice, $conditionUpdatePrice); } if ($Result > 0) { $this->_redirect('tshirt/products'); } else { $mySession->errorMsg = "Icon already exist with this title"; $this->view->myform = $myform; if ($id != '') { $this->view->id = $id; } $this->render('tshirtproduct'); } } else { $mySession->errorMsg = "Fill Required Fields"; $this->view->myform = $myform; if ($id != '') { $this->view->id = $id; } $this->render('tshirtproduct'); } } else { $this->_redirect('tshirt/products'); } }
public function onrequestpayAction() { global $mySession; $db = new Db(); $spclOffer = implode(",", $mySession->spclOfferId); $extras = implode(",", $mySession->extrasId); //$dataForm['property_id'] = $mySession->pptyId; $dataForm['property_id'] = $mySession->bookingUser['property_id']; $dataForm['user_id'] = $mySession->bookingUser['user_id']; $dataForm['date_from'] = date('Y-m-d', strtotime($mySession->arrivalDate)); $dataForm['date_to'] = date('Y-m-d', strtotime($mySession->arrivalDate . " + " . $mySession->noOfNights . " day")); $dataForm['offer_id'] = $spclOffer; $dataForm['min_rate'] = $mySession->minrate; //$dataForm['extras_id'] = $extras; $dataForm['children'] = $mySession->Children; $dataForm['adult'] = $mySession->Adults; $dataForm['infants'] = $mySession->Infants; $dataForm['total'] = $mySession->Infants; $dataForm['rental_amt'] = $mySession->totalCost; $dataForm['booking_date'] = date('Y-m-d'); $dataForm['booking_type'] = '1'; $dataForm['paid_status'] = '0'; $db->save(BOOKING, $dataForm); $bookingId = $db->lastInsertId(); //code to save data in calendar table /*$dataForm = array(); $dataForm['property_id'] = $mySession->pptyId; $dataForm['date_from'] = date('Y-m-d',strtotime($mySession->arrivalDate)); $dataForm['date_to'] = date('Y-m-d',strtotime($mySession->arrivalDate." + ".$mySession->noOfNights." day")); $dataForm['cal_status'] = '0'; save_calendar_stat($mySession->pptyId,$dataForm['date_from'],$dataForm['date_to']);*/ //saving in the booking extra table foreach ($mySession->extrasId as $values) { $extrasArr = $db->runQuery("select ename,eprice*exchange_rate as eprice,etype,stay_type from " . EXTRAS . " \n\t\t\t inner join " . PROPERTY . " on " . PROPERTY . ".id = " . EXTRAS . ".property_id\n\t\t\t\t\t\t\t\t\t\tinner join " . CURRENCY . " on " . CURRENCY . ".currency_code = " . PROPERTY . ".currency_code\n\t\t\t\t\t\t\t\t\t\twhere eid = '" . $values . "'\t "); $dataForm = array(); $dataForm['booking_id'] = $bookingId; $dataForm['option_name'] = $extrasArr[0]['ename']; $dataForm['option_price'] = $extrasArr[0]['eprice']; $dataForm['option_status'] = $extrasArr[0]['etype']; $dataForm['stay_type'] = $extrasArr[0]['stay_type']; $db->save(BOOKING_EXTRA, $dataForm); } // $extrasArr = $db->runQuery("select ename,eprice*exchange_rate as eprice,etype,stay_type from ".EXTRAS." // inner join ".PROPERTY." on ".PROPERTY.".id = ".EXTRAS.".property_id // inner join ".CURRENCY." on ".CURRENCY.".currency_code = ".PROPERTY.".currency_code // where property_id = '".$mySession->pptyId."' and etype = '1' "); $extrasArr = $db->runQuery("select ename,eprice*exchange_rate as eprice,etype,stay_type from " . EXTRAS . " \n\t\t\t\t\t\t\t\t\tinner join " . PROPERTY . " on " . PROPERTY . ".id = " . EXTRAS . ".property_id\n \t\t\t\t\t\t\t\t inner join " . CURRENCY . " on " . CURRENCY . ".currency_code = " . PROPERTY . ".currency_code\n\t\t\t\t\t\t\t\t\twhere property_id = '" . $mySession->bookingUser['property_id'] . "' and etype = '1' "); //saving for the compulosry extras table foreach ($extrasArr as $values) { $dataForm = array(); $dataForm['booking_id'] = $bookingId; $dataForm['option_name'] = $values['ename']; $dataForm['option_price'] = $values['eprice']; $dataForm['option_status'] = $values['etype']; $dataForm['stay_type'] = $values['stay_type']; $db->save(BOOKING_EXTRA, $dataForm); } $mySession->sucessMsg = "Thank you.. Property has been Booked Successfully"; $pptyno = $db->runQuery("select propertycode from " . PROPERTY . " where id = '" . $mySession->pptyId . "' "); $fullName = $mySession->LoggedUserName; $Url = '<a href="' . APPLICATION_URL . '">' . APPLICATION_URL . '</a>'; $templateData = $db->runQuery("select * from " . EMAIL_TEMPLATES . " where template_id='7'"); $messageText = $templateData[0]['email_body']; $subject = $templateData[0]['email_subject']; $messageText = str_replace("[NAME]", $fullName, $messageText); $messageText = str_replace("[SITENAME]", SITE_NAME, $messageText); $messageText = str_replace("[SITEURL]", APPLICATION_URL, $messageText); $messageText = str_replace("[PROPERTYNO]", $pptyno[0]['propertycode'], $messageText); SendEmail($dataForm['email_address'], $subject, $messageText); __bookSessionClear(); $this->_redirect("contents/pages/slug/bookingsucess"); }
default: die('Unsupported File Please upload txt file!'); //output error } } else { die('Something wrong with upload! Is "upload_max_filesize" set correctly?'); } //if all files are uploaded correctly, following things happen, it is a part of validation //get first three text fields and assign to variables $lesson_name = filter_var($_POST["name"], FILTER_SANITIZE_STRING); $description = filter_var($_POST["description"], FILTER_SANITIZE_STRING); $lecturer = filter_var($_POST["lecturer"], FILTER_SANITIZE_STRING); //insert text field values into lesson table $lessons = $db->query("INSERT INTO lesson(name, description, lecture) VALUES (:nam,:des,:lec)", array("nam" => $lesson_name, "des" => $description, "lec" => $lecturer)); //get the id of last inserted row $lessonID = $db->lastInsertId(); //upload files separately into the unique folder of the uploads folder $UploadDirectory1 = '../../../data/uploaded_lessons/' . $lessonID . '/' . 'videos/'; $UploadDirectory2 = '../../../data/uploaded_lessons/' . $lessonID . '/' . 'slides/'; $UploadDirectory3 = '../../../data/uploaded_lessons/' . $lessonID . '/'; //get file name $File_Name = strtolower($_FILES['FileInput1']['name']); //rename video file always as 1.mp4 $NewFileName = "1.mp4"; //if not directly by above name create it. if (!file_exists($UploadDirectory1)) { mkdir($UploadDirectory1, 0755, true); } //move temporary uploaded file into the folder created above if (move_uploaded_file($_FILES['FileInput1']['tmp_name'], $UploadDirectory1 . $NewFileName)) { // die('Success! File Uploaded.');
function addfeatureAction() { $db = new Db(); $feature = $this->getRequest()->getPost('feature'); $this->_helper->viewRenderer->setNoRender(); $this->_helper->layout->disableLayout(); $msg = array(); if (empty($feature)) { $msg['result'] = 'false'; $msg['reason'] = 'feature value is empty'; } else { //check if feature is already available $chkData = $db->runQuery(" select * from " . LOCATION_FEATURES . " where lower(feature_name) = '" . strtolower($feature) . "' "); if ($chkData != "" && count($chkData)) { $msg['result'] = 'false'; $msg['reason'] = 'duplicate value found'; exit(json_encode($msg)); } $data = array(); $data['feature_name'] = $feature; $db->save(LOCATION_FEATURES, $data); $id = $db->lastInsertId(); $msg['result'] = 'true'; $msg['featureVal'] = $feature; $msg['featureId'] = $id; } echo json_encode($msg); }
/** * 向表中插入一条数据 * @param array $data 要添加的数据 * @param bool $multi 是否添加多条数据 */ public function add($data, $multi = false) { $this->lastInsertId = 0; $ret = Db::insert($this->tbl, $data, $multi); if ($ret) { $this->lastInsertId = Db::lastInsertId(); $this->id = $this->lastInsertId; $this->data[$this->priKey] = $this->id; return true; } else { $errors = Db::errors(); if (APP_DEBUG) { trigger_error('Error occured on insert data to database.' . var_export($errors, true)); } else { trigger_error('Error occured on insert data to database.'); } return false; } }
protected function insert() { //columns of table $cols = array_keys($this->data); // refactor $this->data keys with ':key' $data = []; foreach ($cols as $col) { $data[':' . $col] = $this->data[$col]; } //generating query: INSERT INTO table (col1, col2) VALUES (:col1, :col2) $sql = 'INSERT INTO ' . static::$table . ' (' . implode(', ', $cols) . ') VALUES (' . implode(', ', array_keys($data)) . ')'; $db = new Db(); if ($db->exec($sql, $data)) { return $db->lastInsertId(); } return false; }
function save() { // update if ($this->id) { if (is_null($this->data_new)) { return; } $fields = ""; $values = array(); if ($this->udate) { $fields = "udate = NOW()"; } foreach ($this->data_new as $key => $val) { if ($fields) { $fields .= ", "; } $fields .= "`" . str_replace("`", "", $key) . "` = ?"; $values[] = $val; } if (count($values)) { $sql = "UPDATE `{$this->table}` SET {$fields} WHERE id = " . (int) $this->id; return Db::query($sql, $values); } return true; } else { $fields = ""; $values = array(); $explicit_values = ""; // adate if ($this->adate) { if ($fields) { $fields .= ", "; } $fields .= "adate"; if ($explicit_values) { $explicit_values .= ", "; } $explicit_values .= "NOW()"; } // udate if ($this->udate) { if ($fields) { $fields .= ", "; } $fields .= "udate"; if ($explicit_values) { $explicit_values .= ", "; } $explicit_values .= "NOW()"; } foreach ($this->data_new as $key => $val) { if ($fields) { $fields .= ", "; } $fields .= "`" . str_replace("`", "", $key) . "`"; $values[] = $val; } $placeholders = rtrim(str_repeat("?, ", count($values)), ", "); if ($explicit_values) { $placeholders = ",{$placeholders}"; } $sql = "INSERT INTO `{$this->table}` ({$fields}) VALUES ({$explicit_values}{$placeholders})"; if (Db::query($sql, $values)) { $this->id = Db::lastInsertId(); return true; } return false; } }
public function processbookAction() { global $mySession; $db = new Db(); $dataForm = array(); $dataextraForm = array(); $request = $this->getRequest(); if ($this->getRequest()->isPost()) { $post = $request->getPost(); $dateFrom = explode("/", $post['date_from']); $dateFrom = $dateFrom[1] . "/" . $dateFrom[0] . "/" . $dateFrom[2]; $dateTo = explode("/", $post['departureDates']); $dateTo = $dateTo[1] . "/" . $dateTo[0] . "/" . $dateTo[2]; $spclOffer = $post['spclOffrId']; $extras = implode(",", $post['extras']); $dataForm['property_id'] = $post['propertyId']; //$dataForm['property_id'] = $mySession->bookingUser['property_id']; $dataForm['user_id'] = $post['userId']; $dataForm['date_from'] = date('Y-m-d', strtotime($dateFrom)); $dataForm['date_to'] = date('Y-m-d', strtotime($dateTo)); $dataForm['offer_id'] = $spclOffer; $dataForm['min_rate'] = $post['totalAmount']; //$dataForm['extras_id'] = $extras; $dataForm['children'] = $post['Children']; $dataForm['adult'] = $post['Adults']; $dataForm['infants'] = $post['Infants']; // $dataForm['total'] = $mySession->Infants; // $dataForm['rental_amt'] = $post['finalAmount']; $dataForm['booking_date'] = date('Y-m-d'); //TO DO $dataForm['booking_type'] = '0'; // if (!empty($dataForm['depositAmount'])) { $dataForm['paid_status'] = '1'; // } else { // $dataForm['paid_status'] = '0'; // } $dataForm['rental_amt'] = $post['totalAmount']; $dataForm['telephonic'] = '1'; $db->save(BOOKING, $dataForm); $bookingId = $db->lastInsertId(); //code to save in payment table $dataForm['user_id'] = $post['userId']; $dataForm['property_id'] = $post['propertyId']; $dataForm['amount_paid'] = $post['finalAmount']; $dataForm['booking_id'] = $bookingId; $dataForm['payment_date'] = date('Y-m-d'); $db->save(PAYMENT, $dataForm); //code to save data in calendar table /* $dataForm = array(); $dataForm['property_id'] = $mySession->pptyId; $dataForm['date_from'] = date('Y-m-d',strtotime($mySession->arrivalDate)); $dataForm['date_to'] = date('Y-m-d',strtotime($mySession->arrivalDate." + ".$mySession->noOfNights." day")); $dataForm['cal_status'] = '0'; save_calendar_stat($mySession->pptyId,$dataForm['date_from'],$dataForm['date_to']); */ //saving in the booking extra table foreach ($post['extras'] as $values) { $extrasArr = $db->runQuery("select ename,eprice*exchange_rate as eprice,etype,stay_type from " . EXTRAS . " \n\t\t\t inner join " . PROPERTY . " on " . PROPERTY . ".id = " . EXTRAS . ".property_id\n\t\t\t\t\t inner join " . CURRENCY . " on " . CURRENCY . ".currency_code = " . PROPERTY . ".currency_code\n where eid = '" . $values . "'\t "); $dataForm = array(); $dataForm['booking_id'] = $bookingId; $dataForm['option_name'] = $extrasArr[0]['ename']; $dataForm['option_price'] = $extrasArr[0]['eprice']; $dataForm['option_status'] = $extrasArr[0]['etype']; $dataForm['stay_type'] = $extrasArr[0]['stay_type']; $db->save(BOOKING_EXTRA, $dataForm); } $extrasArr = $db->runQuery("select ename,eprice*exchange_rate as eprice,etype,stay_type from " . EXTRAS . " \n inner join " . PROPERTY . " on " . PROPERTY . ".id = " . EXTRAS . ".property_id\n \t\t\t\t\tinner join " . CURRENCY . " on " . CURRENCY . ".currency_code = " . PROPERTY . ".currency_code\n\t\t\t\t\twhere property_id = '" . $post['propertyId'] . "' and etype = '1' "); //saving for the compulosry extras table foreach ($extrasArr as $values) { $dataForm = array(); $dataForm['booking_id'] = $bookingId; $dataForm['option_name'] = $values['ename']; $dataForm['option_price'] = $values['eprice']; $dataForm['option_status'] = $values['etype']; $dataForm['stay_type'] = $values['stay_type']; $db->save(BOOKING_EXTRA, $dataForm); } $mySession->sucessMsg = "Thank you.. Property has been Booked Successfully"; $pptyno = $db->runQuery("select propertycode from " . PROPERTY . " where id = '" . $post['propertyId'] . "' "); // $fullName = $mySession->LoggedUserName; // // $Url = '<a href="' . APPLICATION_URL . '">' . APPLICATION_URL . '</a>'; // $templateData = $db->runQuery("select * from " . EMAIL_TEMPLATES . " where template_id='7'"); // $messageText = $templateData[0]['email_body']; // $subject = $templateData[0]['email_subject']; // // $messageText = str_replace("[NAME]", $fullName, $messageText); // $messageText = str_replace("[SITENAME]", SITE_NAME, $messageText); // $messageText = str_replace("[SITEURL]", APPLICATION_URL, $messageText); // $messageText = str_replace("[PROPERTYNO]", $pptyno[0]['propertycode'], $messageText); // // SendEmail($dataForm['email_address'], $subject, $messageText); //===== code for adding popular properties //two cases //1. when booked property is already in the list of slides property //2. when booked property is not in the list of slides property $identifyArr = $db->runQuery("select * from " . SLIDES_PROPERTY . " where lppty_property_id = '" . $post['propertyId'] . "' and lppty_type = '1' "); if ($identifyArr != "" and count($identifyArr) > 0) { $db->delete(SLIDES_PROPERTY, 'lppty_id= "' . $identifyArr[0]['lppty_id'] . '" '); $updateData = array(); $updateData['lppty_order'] = new Zend_Db_Expr('lppty_order-1'); $updateData['lppty_status'] = '1'; $db->modify(SLIDES_PROPERTY, $updateData, "lppty_type='1' and lppty_order > '" . $identifyArr[0]['lppty_order'] . "' "); } else { $updateData = array(); $updateData['lppty_order'] = new Zend_Db_Expr('lppty_order+1'); $updateData['lppty_status'] = '1'; $db->modify(SLIDES_PROPERTY, $updateData, "lppty_type='1'"); $saveData = array(); $saveData['lppty_property_id'] = $post['propertyId']; $saveData['lppty_type'] = '1'; $saveData['lppty_order'] = '1'; $db->save(SLIDES_PROPERTY, $saveData); } //--------------------------------------- //__bookSessionClear(); $this->_redirect("booking"); } else { $this->_redirect("booking/manage"); } }
public function saveSpecification($dataForm, $specId = "") { global $mySession; $db = new Db(); $dataForm = SetupMagicQuotesTrim($dataForm); if ($specId == "") { $chkQry = $db->runQuery("select * from " . SPECIFICATION . " where question like '%" . mysql_escape_string(trim($dataForm['question'])) . "' and cat_id = '" . $dataForm['category'] . "' "); if ($chkQry != "" and count($chkQry) > 0) { //if Same Question exists than return false / 0 // No Data Inserted return 0; } else { $data_update['cat_id'] = $dataForm['category']; $data_update['question'] = $dataForm['question']; $data_update['spec_type'] = $dataForm['input_type']; $data_update['mandatory'] = $dataForm['mandatory']; $data_update['status'] = $dataForm['spec_status']; //code for inserting order $orderArr = $db->runQuery("select * from " . SPECIFICATION . " where cat_id = '" . $dataForm['category'] . "' "); $data_update['spec_order'] = count($orderArr) + 1; $db->save(SPECIFICATION, $data_update); $latestId = $db->lastInsertId(); for ($x = 1; $x <= 53; $x++) { $options_add = "options_add" . $x; if (trim($dataForm[$options_add]) != "") { $data_update1['spec_id'] = $latestId; $data_update1['option'] = sanisitize_input($dataForm[$options_add]); $db->save(SPEC_CHILD, $data_update1); } } return 1; } } else { // echo "select * from ".SPECIFICATION." where question like '%".mysql_escape_string(trim($dataForm['question']))."' and cat_id = '".$dataForm['category']."' "; // exit; $chkQry = $db->runQuery("select * from " . SPECIFICATION . " where question like '%" . mysql_escape_string(trim($dataForm['question'])) . "' and spec_id != '" . $specId . "' and cat_id = '" . $dataForm['category'] . "' "); if ($chkQry != "" and count($chkQry) > 0) { //if Same Question exists than return false / 0 // No Data Inserted return 0; } else { $data_update['cat_id'] = $dataForm['category']; $data_update['question'] = $dataForm['question']; $data_update['spec_type'] = $dataForm['input_type']; $data_update['status'] = $dataForm['spec_status']; $data_update['mandatory'] = $dataForm['mandatory']; $condition = "spec_id = " . $specId; $db->modify(SPECIFICATION, $data_update, $condition); $specsId = ""; $db->delete(SPEC_CHILD, $condition); for ($x = 1; $x <= 53; $x++) { $options_add = "options_add" . $x; if (trim($dataForm[$options_add]) != "") { $data_update1['spec_id'] = $specId; $data_update1['option'] = $dataForm[$options_add]; $db->save(SPEC_CHILD, $data_update1); } } return 1; } } }
public function SaveBusiness($dataForm) { global $mySession; $db = new Db(); "select * from " . SERVICE_BUSINESS . " where business_title='" . mysql_escape_string($dataForm['business_title']) . "' and zipcode='" . $dataForm['zipcode'] . "'"; // $chkQry=$db->runQuery("select * from ".SERVICE_BUSINESS." where business_title='".mysql_escape_string($dataForm['business_title'])."' and zipcode='".$dataForm['zipcode']."'"); if ($chkQry != "" and count($chkQry) > 0) { return 0; } else { $BusinessImagesPath = ""; for ($counter = 1; $counter <= 10; $counter++) { $businessImage = $dataForm['old_business_image' . $counter]; if ($dataForm['business_image' . $counter] != "") { $businessImage = time() . "_" . $dataForm['business_image' . $counter]; @rename(SITE_ROOT . 'images/businesses/' . $dataForm['business_image' . $counter], SITE_ROOT . 'images/businesses/' . $businessImage); } if ($businessImage != "") { $BusinessImagesPath .= $businessImage . ","; } } if ($BusinessImagesPath != "") { $BusinessImagesPath = substr($BusinessImagesPath, 0, strlen($BusinessImagesPath) - 1); } $myLatLongData = getLatLongFromAddress($dataForm['country_id'], $dataForm['state_id'], $dataForm['city_name'], $dataForm['address']); $explode = explode("::", $myLatLongData); $Lat = $explode[0]; $Long = $explode[1]; $dataInsert['user_id'] = $mySession->LoggedUserId; $dataInsert['business_title'] = strip_magic_slashes($dataForm['business_title']); $dataInsert['business_category_id'] = $dataForm['business_category_id']; $dataInsert['business_subcategory_id'] = $dataForm['business_subcategory_id']; $dataInsert['description'] = strip_magic_slashes($dataForm['description']); $dataInsert['search_keywords'] = strip_magic_slashes($dataForm['search_keywords']); $dataInsert['address'] = strip_magic_slashes($dataForm['address']); $dataInsert['city_name'] = strip_magic_slashes($dataForm['city_name']); $dataInsert['zipcode'] = $dataForm['zipcode']; $dataInsert['state_id'] = $dataForm['state_id']; $dataInsert['country_id'] = $dataForm['country_id']; $dataInsert['phone_number'] = $dataForm['phone_number']; $dataInsert['email_address'] = $dataForm['email_address']; $dataInsert['website'] = $dataForm['website']; $dataInsert['business_image'] = $BusinessImagesPath; $dataInsert['business_lat'] = $Lat; $dataInsert['business_long'] = $Long; $dataInsert['business_status'] = '1'; $dataInsert['date_business_added'] = date('Y-m-d H:i:s'); //echo "imagepath=".$dataInsert['business_image'];exit(); $db->save(SERVICE_BUSINESS, $dataInsert); return $db->lastInsertId(); } }
if (isset($_POST["invoice"])) { ?> <?php $receivingAddress = $config[0]["config_address"]; $user_id = $_SESSION['user_id']; $newAddr = json_decode(file_get_contents("https://blockchain.info/api/receive?method=create&address={$receivingAddress}"), true)[input_address]; $currency = $_POST['currency']; $currency_value = number_format($_POST['value'], 2); $invoice_btc_value = $_POST['btcValue']; $note = $_POST['note']; $date = date("D M d Y H:i:s O"); $date_expiry = date("D M d Y H:i:s O", strtotime($date) + 900); $db = new Db(); $db->query("INSERT INTO\n invoices(invoice_user_id, invoice_address, invoice_fiat, invoice_fiat_value, invoice_btc_value, invoice_paid, invoice_date, invoice_date_expiry, invoice_note)\n VALUES('{$user_id}', '{$newAddr}', '{$currency}', '{$currency_value}', '{$invoice_btc_value}', '0', '{$date}', '{$date_expiry}', '{$note}')"); header('Location: invoice.php?id=' . $db->lastInsertId()); ?> <?php } else { ?> <?php $currencies = json_decode(file_get_contents("https://blockchain.info/ticker"), true); $currency_default = $config[0]["config_currency"]; if (isset($_GET["currency"])) { $currency_default = $_GET["currency"]; } $quote = $currencies[$currency_default]["sell"]; $symbol = $currencies[$currency_default]["symbol"]; ?>
public function savesetgoal($dataForm) { global $mySession; $db = new Db(); $data_insert['user_id'] = $mySession->TeeLoggedID; $data_insert['base_price'] = $mySession->baseprice; $data_insert['goal'] = $mySession->no_of_t; $data_insert['selling_price'] = $mySession->setgoalvalues['sellingprice']; $data_insert['customimage'] = $mySession->customimage; $data_insert['draft_date'] = date('Y-m-d H:i:s'); if ($mySession->selectedIdValueKM != '' && isset($mySession->selectedIdValueKM)) { $data_insert['SelectedProduct'] = $mySession->selectedIdValueKM; } if (isset($mySession->recreation_product) && $mySession->recreation_product != "") { $data_insert['normalImageData'] = $mySession->recreation_product; } $db->save(LAUNCHCAMPAIGN, $data_insert); $campid = $db->lastInsertId(); //error_log('savesetgoal() data_insert: '.print_r($data_insert, true).', created new campaign (draft) id: '.$campid); $datainsert['campaign_id'] = $campid; $datainsert['user_id'] = $mySession->TeeLoggedID; $db->save(DRAFTS, $datainsert); return $campid; }
/** * test_ExecAndTransaction_ExecWithInTrans() * * exec()のテスト(トランザクションあり) */ public function test_ExecAndTransaction_ExecWithInTrans() { $params = ["driver" => $GLOBALS['DB_DRIVER'], "user" => $GLOBALS['DB_USER'], "pass" => $GLOBALS['DB_PASSWORD'], "dbname" => $GLOBALS['DB_DBNAME'], "host" => $GLOBALS['DB_HOST'], "persistent" => false]; $instance = new Db(); $instance->connect($params); // commit pattern $this->assertTrue($instance->beginTransaction()); $this->assertTrue($instance->inTransaction()); $this->assertEquals(1, $instance->exec('INSERT INTO risoluto_db_test(id, column1, column2) values ("10", "TEST_A", "TEST_B");')); $this->assertEquals(2, $this->getconnection()->getRowCount('risoluto_db_test')); $this->assertEquals(10, $instance->lastInsertId()); $this->assertEquals(10, $instance->lastInsertId('id')); $this->assertTrue($instance->commit()); $this->assertFalse($instance->inTransaction()); $this->assertEquals(3, $this->getconnection()->getRowCount('risoluto_db_test')); // Rollback pattern $before_val = $this->getconnection()->createQueryTable('risoluto_db_test', 'SELECT id, column1, column2 FROM risoluto_db_test WHERE id="10";'); $this->assertTrue($instance->beginTransaction()); $this->assertTrue($instance->inTransaction()); $this->assertEquals(1, $instance->exec('UPDATE risoluto_db_test SET column1="TEST_C", column2="TEST_C" WHERE id="10";')); $this->assertEquals(3, $this->getconnection()->getRowCount('risoluto_db_test')); $this->assertEquals(1, $instance->exec('DELETE FROM risoluto_db_test WHERE id="10";')); $this->assertEquals(3, $this->getconnection()->getRowCount('risoluto_db_test')); $this->assertTrue($instance->rollBack()); $this->assertFalse($instance->inTransaction()); $after_val = $this->getconnection()->createQueryTable('risoluto_db_test', 'SELECT id, column1, column2 FROM risoluto_db_test WHERE id="10";'); $this->assertEquals(3, $this->getconnection()->getRowCount('risoluto_db_test')); $this->assertTablesEqual($before_val, $after_val); // Cleaning $this->assertEquals(1, $instance->exec('DELETE FROM risoluto_db_test WHERE id="10";')); $this->assertEquals(2, $this->getconnection()->getRowCount('risoluto_db_test')); $instance->disConnect(); unset($instance); }
public function signupdb($dataForm) { $db = new Db(); global $mySession; $chckuname = $db->runquery("Select emailid from users where emailid='" . $dataForm['signupemailid'] . "'"); if (count($chckuname) > 0 && $chckuname != "") { return 0; } else { $data_insert['public_name'] = $dataForm['publicname']; $data_insert['emailid'] = $dataForm['signupemailid']; $data_insert['password'] = md5($dataForm['signuppass']); $data_insert['user_status'] = 0; $data_insert['active_status'] = 0; $db->save(USERS, $data_insert); $userid = $db->lastInsertId(); // only at insert tym $emailid = $dataForm['signupemailid']; $ActivationLink = '<a href="' . APPLICATION_URL . 'login/activate/Id/' . md5($userid) . '">' . APPLICATION_URL . 'login/activate/Id/' . md5($userid) . '</a>'; $templateData = $db->runQuery("select * from " . EMAIL_TEMPLATES . " where template_id='2'"); $messageText = $templateData[0]['email_body']; $subject = $templateData[0]['email_subject']; $messageText = str_replace("[NAME]", $emailid, $messageText); $messageText = str_replace("[SITENAME]", SITE_NAME, $messageText); $messageText = str_replace("[LOGINNAME]", $dataForm['signupemailid'], $messageText); $messageText = str_replace("[PASSWORD]", $dataForm['signuppass'], $messageText); $messageText = str_replace("[SITEURL]", APPLICATION_URL, $messageText); $messageText = str_replace("[ACTIVATIONLINK]", $ActivationLink, $messageText); SendEmail($dataForm['signupemailid'], $subject, $messageText); return 1; } }
public function paythroughcreditAction() { global $mySession; $db = new Db(); $this->_helper->layout->setLayout('myaccount'); $url = $this->getRequest()->getParam('url'); if ($this->getRequest()->isPost()) { $userId = $mySession->TeeLoggedID; $request = $this->getRequest(); $myform = new Form_Indexpayement(); //$myform=new Form_Indexpayement($url); if ($myform->isValid($request->getPost())) { $dataForm = $myform->getValues(); //$packageId=$this->getRequest()->getParam('packageId'); $Data = $db->runQuery("select * from " . LAUNCHCAMPAIGN . " WHERE url='" . $url . "'"); //$getamount=$mySession->price; require_once "paypal_pro.inc.php"; $emai_id = $dataForm['emailid']; //require_once("includes/config.php"); $firstName = urlencode($dataForm['fname']); $lastName = urlencode($dataForm['lname']); $creditCardType = urlencode($dataForm['creditcardtype']); $creditCardNumber = urlencode($dataForm['creditcardno']); $expDateMonth = urlencode($dataForm['exprymonth']); $padDateMonth = str_pad($expDateMonth, 2, '0', STR_PAD_LEFT); $expDateYear = urlencode($dataForm['expryyear']); $cvv2Number = urlencode($dataForm['cvvno']); $address1 = urlencode($dataForm['address']); //$address2 = urlencode($_POST['address2']); $city = urlencode($dataForm['city']); $state = urlencode($dataForm['state']); $zip = urlencode($dataForm['zipcode']); $amount = $mySession->totalamt; $currencyCode = "USD"; $paymentAction = urlencode("Sale"); if ($_POST['recurring'] == 1) { $profileStartDate = urlencode(date('Y-m-d h:i:s')); $billingPeriod = urlencode($_POST['billingPeriod']); // or "Day", "Week", "SemiMonth", "Year" $billingFreq = urlencode($_POST['billingFreq']); // combination of this and billingPeriod must be at most a year $initAmt = $amount; $failedInitAmtAction = urlencode("ContinueOnFailure"); $desc = urlencode("Recurring \$" . $amount); $autoBillAmt = urlencode("AddToNextBilling"); $profileReference = urlencode("Anonymous"); $methodToCall = 'CreateRecurringPaymentsProfile'; $nvpRecurring = '&BILLINGPERIOD=' . $billingPeriod . '&BILLINGFREQUENCY=' . $billingFreq . '&PROFILESTARTDATE=' . $profileStartDate . '&INITAMT=' . $initAmt . '&FAILEDINITAMTACTION=' . $failedInitAmtAction . '&DESC=' . $desc . '&AUTOBILLAMT=' . $autoBillAmt . '&PROFILEREFERENCE=' . $profileReference; } else { $nvpRecurring = ''; $methodToCall = 'doDirectPayment'; } $nvpstr = '&PAYMENTACTION=' . $paymentAction . '&AMT=' . $amount . '&CREDITCARDTYPE=' . $creditCardType . '&ACCT=' . $creditCardNumber . '&EXPDATE=' . $padDateMonth . $expDateYear . '&CVV2=' . $cvv2Number . '&FIRSTNAME=' . $firstName . '&LASTNAME=' . $lastName . '&STREET=' . $address1 . '&CITY=' . $city . '&STATE=' . $state . '&ZIP=' . $zip . '&COUNTRYCODE=US&CURRENCYCODE=' . $currencyCode . $nvpRecurring; /*$paypalPro = new paypal_pro('sdk-three_api1.sdk.com', 'QFZCWN5HZM8VBG7Q', 'A.d9eRKfd1yVkRrtmMfCFLTqa6M9AyodL0SJkhYztxUi8W9pCXF6.4NI', '', '', TRUE, FALSE ); */ $paypalPro = new paypal_pro('8ndra_api1.seznam.cz', 'J3K2SD2RXGG3ZTUY', 'AFcWxV21C7fd0v3bYYYRCpSSRl31A1bWIW8aO685Dq4z21-5wttwtLoY', '', '', TRUE, FALSE); $resArray = $paypalPro->hash_call($methodToCall, $nvpstr); $ack = strtoupper($resArray["ACK"]); if ($ack != "SUCCESS") { echo '<table border="0" cellspacing="4" cellpadding="4" align="center" style="padding-top:40px; padding-bottom:80px;">'; //echo "if"; echo '<tr>'; echo '<td colspan="2" style="font-weight:bold; font-size:20px; color:Green" align="center">Error! Please check that u will provide all information correctly :(</td>'; echo '</tr>'; echo '<tr>'; echo '<td align="left" style="font-size:18px;"> TIMESTAMP:</td>'; echo '<td style="font-size:18px; color:#006633;">' . $resArray["TIMESTAMP"] . '</td>'; echo '</tr>'; echo '<tr>'; echo '<td align="left" style="font-size:18px;"> Correlation ID:</td>'; echo '<td style="font-size:18px; color:#006633;">' . $resArray['CORRELATIONID'] . '</td>'; echo '</tr>'; echo '<tr>'; echo '<td align="left" style="font-size:18px;">ACK:</td>'; echo '<td style="font-size:18px; color:#006633;">' . $resArray['ACK'] . '</td>'; echo '</tr>'; echo '<td align="left" style="font-size:18px;"> VERSION:</td>'; echo '<td style="font-size:18px; color:#006633;">' . $resArray["VERSION"] . '</td>'; echo '</tr>'; echo '<tr>'; echo '<td align="left" style="font-size:18px;"> BUILD:</td>'; echo '<td style="font-size:18px; color:#006633;">' . $resArray["BUILD"] . '</td>'; echo '</tr>'; echo '<tr>'; echo '<td align="left" style="font-size:18px;"> L_ERRORCODE0:</td>'; echo '<td style="font-size:18px; color:#006633;">' . $resArray["L_ERRORCODE0"] . '</td>'; echo '</tr>'; echo '<td align="left" style="font-size:18px;"> L_SHORTMESSAGE0:</td>'; echo '<td style="font-size:18px; color:#006633;">' . $resArray["L_SHORTMESSAGE0"] . '</td>'; echo '</tr>'; echo '<td align="left" style="font-size:18px;"> L_LONGMESSAGE0:</td>'; echo '<td style="font-size:18px; color:#006633;">' . $resArray["L_LONGMESSAGE0"] . '</td>'; echo '</tr>'; echo '<td align="left" style="font-size:18px;"> L_SEVERITYCODE0:</td>'; echo '<td style="font-size:18px; color:#006633;">' . $resArray["L_SEVERITYCODE0"] . '</td>'; echo '</tr>'; echo '</tr>'; echo '<td align="left" style="font-size:18px;"> L_SEVERITYCODE0:</td>'; echo '<td style="font-size:18px; color:#006633;">' . $resArray["L_SEVERITYCODE0"] . '</td>'; echo '</tr>'; echo '<tr>'; echo '<td align="left" style="font-size:18px;"> AMT:</td>'; echo '<td style="font-size:18px; color:#006633;">' . $resArray["AMT"] . '</td>'; echo '</tr>'; echo '</table>'; } else { echo '<table border="0" cellspacing="4" cellpadding="4" align="center" style="padding-top:40px; padding-bottom:80px;">'; //echo "success"; echo '<tr>'; echo '<td colspan="2" style="font-weight:bold; font-size:20px; color:Green" align="center">Thank You For Your Payment :)</td>'; echo '</tr>'; echo '<tr>'; echo '<td align="left" style="font-size:18px;"> Transaction ID:</td>'; echo '<td style="font-size:18px; color:#006633;">' . $resArray["TRANSACTIONID"] . '</td>'; echo '</tr>'; echo '<tr>'; echo '<td align="left" style="font-size:18px;"> Amount:</td>'; echo '<td style="font-size:18px; color:#006633;">' . $currencyCode . $resArray['AMT'] . '</td>'; echo '</tr>'; echo '</table>'; $qty = $mySession->totalquantity; $Data = $db->runQuery("select * from " . LAUNCHCAMPAIGN . " WHERE url='" . $url . "'"); //echo "select * from ".LAUNCHCAMPAIGN." WHERE url='".$url."'"; die; $no_ofsold = $Data[0]['sold']; $no_ofsold = $no_ofsold + $qty; //echo "No. Of T sold :".$no_ofsold; die; $data_update['sold'] = $no_ofsold; $condition = "url='" . $url . "'"; $addrs = $dataForm['address'] . " , " . $dataForm['city'] . " , " . $dataForm['state']; //echo "address: ".$addrs; die; //prd($condition); $db->modify(LAUNCHCAMPAIGN, $data_update, $condition); $idqry = $db->runquery("select * from " . LAUNCHCAMPAIGN . " where url='" . $url . "'"); $userid = $idqry[0]['user_id']; $useremail = $db->runquery("select * from " . USERS . " where user_id='" . $userid . "'"); $emailidcreator = $useremail[0]['emailid']; //echo "after payment mail to : ".$emailidcreator; die; $templateData = $db->runQuery("select * from " . EMAIL_TEMPLATES . " where template_id='14'"); $messageText = $templateData[0]['email_body']; $subject = $templateData[0]['email_subject']; $messageText = str_replace("[NAME]", $emailidcreator, $messageText); $messageText = str_replace("[SITENAME]", SITE_NAME, $messageText); //$messageText=str_replace("[ORDERNO]",$orderno,$messageText); //echo "msg text".$messageText; SendEmail($emailidcreator, $subject, $messageText); $dataInsert['name'] = $dataForm['fname'] . " " . $dataForm['lname']; $dataInsert['total_quantity'] = $mySession->totalquantity; $dataInsert['emailid'] = $dataForm['emailid']; $dataInsert['teeurl'] = $url; $dataInsert['size'] = $mySession->sizes; $dataInsert['t_image'] = 'designtee.png'; //$dataInsert['quantity']=$mySession->seeqty; $dataInsert['totalamt'] = $mySession->totalamt; $dataInsert['amount'] = $mySession->amount; $dataInsert['shipping_address'] = $addrs; $dataInsert['order_date'] = date('Y-m-d H:i:s'); // prd($dataInsert); $db->save(ORDER_RECORD, $dataInsert); $id = $db->lastInsertId(); $orderno = '000D' . $id; //echo "Your Order No. is: ".$orderno; $myObj = new Myaccountdb(); $data = $myObj->emailorder($orderno, $dataForm['emailid']); //$mySession->errorMsg="Your Order No. is: ".$orderno; if ($data == 1) { $mySession->errorMsg = "Order Placed. Order Number Mailed to you"; } $mySession->sizes = ""; unset($mySession->sizes); $mySession->totalquantity = ""; unset($mySession->totalquantity); $mySession->amount = ""; unset($mySession->amount); $mySession->totalamt = ""; unset($mySession->totalamt); } } } }
public function onrequestpayAction() { global $mySession; $db = new Db(); $spclOffer = implode(",", $mySession->spclOfferId); $extras = implode(",", $mySession->extrasId); $dataForm['property_id'] = $mySession->pptyId; //$dataForm['property_id'] = $mySession->bookingUser['property_id']; $dataForm['user_id'] = $mySession->bookingUser['user_id']; $dataForm['date_from'] = date('Y-m-d', strtotime($mySession->arrivalDate)); $dataForm['date_to'] = date('Y-m-d', strtotime($mySession->arrivalDate . " + " . $mySession->noOfNights . " day")); $dataForm['offer_id'] = $spclOffer; $dataForm['min_rate'] = $mySession->minrate == '' ? '34' : $mySession->minrate; //$dataForm['extras_id'] = $extras; $dataForm['children'] = $mySession->Children; $dataForm['adult'] = $mySession->Adults; $dataForm['infants'] = $mySession->Infants; $dataForm['total'] = $mySession->Infants; $dataForm['rental_amt'] = $mySession->totalCost; $dataForm['booking_date'] = date('Y-m-d'); $dataForm['booking_type'] = '1'; $dataForm['paid_status'] = '0'; //echo "<pre />"; print_r($dataForm);exit; $db->save(BOOKING, $dataForm); $bookingId = $db->lastInsertId(); //code to save data in calendar table /* $dataForm = array(); $dataForm['property_id'] = $mySession->pptyId; $dataForm['date_from'] = date('Y-m-d',strtotime($mySession->arrivalDate)); $dataForm['date_to'] = date('Y-m-d',strtotime($mySession->arrivalDate." + ".$mySession->noOfNights." day")); $dataForm['cal_status'] = '0'; save_calendar_stat($mySession->pptyId,$dataForm['date_from'],$dataForm['date_to']); */ //saving in the booking extra table foreach ($mySession->extrasId as $values) { $extrasArr = $db->runQuery("select ename,eprice*exchange_rate as eprice,etype,stay_type from " . EXTRAS . " \n\t\t\t inner join " . PROPERTY . " on " . PROPERTY . ".id = " . EXTRAS . ".property_id\n\t\t\t\t\t\t\t\t\t\tinner join " . CURRENCY . " on " . CURRENCY . ".currency_code = " . PROPERTY . ".currency_code\n\t\t\t\t\t\t\t\t\t\twhere eid = '" . $values . "'\t "); $dataForm = array(); $dataForm['booking_id'] = $bookingId; $dataForm['option_name'] = $extrasArr[0]['ename']; $dataForm['option_price'] = $extrasArr[0]['eprice']; $dataForm['option_status'] = $extrasArr[0]['etype']; $dataForm['stay_type'] = $extrasArr[0]['stay_type']; $db->save(BOOKING_EXTRA, $dataForm); } $extrasArr = $db->runQuery("select ename,eprice*exchange_rate as eprice,etype,stay_type from " . EXTRAS . " \n\t\t\t\t\t\t\t\t\tinner join " . PROPERTY . " on " . PROPERTY . ".id = " . EXTRAS . ".property_id\n \t\t\t\t\t\t\t\t inner join " . CURRENCY . " on " . CURRENCY . ".currency_code = " . PROPERTY . ".currency_code\n\t\t\t\t\t\t\t\t\twhere property_id = '" . $mySession->pptyId . "' and etype = '1' "); //saving for the compulosry extras table foreach ($extrasArr as $values) { $dataForm = array(); $dataForm['booking_id'] = $bookingId; $dataForm['option_name'] = $values['ename']; $dataForm['option_price'] = $values['eprice']; $dataForm['option_status'] = $values['etype']; $dataForm['stay_type'] = $values['stay_type']; $db->save(BOOKING_EXTRA, $dataForm); } $mySession->sucessMsg = "Thank you.. Property has been Booked Successfully"; $pptyno = $db->runQuery("select propertycode from " . PROPERTY . " where id = '" . $mySession->pptyId . "' "); $fullName = $mySession->LoggedUserName; $Url = '<a href="' . APPLICATION_URL . '">' . APPLICATION_URL . '</a>'; $templateData = $db->runQuery("select * from " . EMAIL_TEMPLATES . " where template_id='7'"); $messageText = $templateData[0]['email_body']; $subject = $templateData[0]['email_subject']; $messageText = str_replace("[NAME]", $fullName, $messageText); $messageText = str_replace("[SITENAME]", SITE_NAME, $messageText); $messageText = str_replace("[SITEURL]", APPLICATION_URL, $messageText); $messageText = str_replace("[PROPERTYNO]", $pptyno[0]['propertycode'], $messageText); SendEmail($dataForm['email_address'], $subject, $messageText); //===== code for adding popular properties //two cases //1. when booked property is already in the list of slides property //2. when booked property is not in the list of slides property $identifyArr = $db->runQuery("select * from " . SLIDES_PROPERTY . " where lppty_property_id = '" . $mySession->pptyId . "' and lppty_type = '1' "); if ($identifyArr != "" and count($identifyArr) > 0) { $db->delete(SLIDES_PROPERTY, 'lppty_id= "' . $identifyArr[0]['lppty_id'] . '" '); $updateData = array(); $updateData['lppty_order'] = new Zend_Db_Expr('lppty_order-1'); $updateData['lppty_status'] = '1'; $db->modify(SLIDES_PROPERTY, $updateData, "lppty_type='1' and lppty_order > '" . $identifyArr[0]['lppty_order'] . "' "); } else { $updateData = array(); $updateData['lppty_order'] = new Zend_Db_Expr('lppty_order+1'); $updateData['lppty_status'] = '1'; $db->modify(SLIDES_PROPERTY, $updateData, "lppty_type='1'"); $saveData = array(); $saveData['lppty_property_id'] = $mySession->pptyId; $saveData['lppty_type'] = '1'; $saveData['lppty_order'] = '1'; $db->save(SLIDES_PROPERTY, $saveData); } //--------------------------------------- //__bookSessionClear(); $this->_redirect("contents/pages/slug/bookingsucess"); }