public function isEnded() { if ($this->getHidden() == TRUE || $this->getStartDate() < NOW() || $this->getEndDate() > NOW()) { return true; } return false; }
public function Store($pUserId, $pIdentifier, $pTitle, $pBody) { $New = false; if (!$pIdentifier) { $pIdentifier = $this->CreateUniqueIdentifier(); $this->Set('Created', NOW()); $New = true; } else { $this->Retrieve(array('Owner_FK' => $pUserId, 'Identifier' => $pIdentifier)); if ($this->Get('Total') > 0) { $this->Fetch(); } else { $this->Set('Created', NOW()); $New = true; } } if (!$pUserId) { return false; } $this->Set('Owner_FK', $pUserId); $this->Set('Identifier', $pIdentifier); $this->Set('Title', $pTitle); $this->Set('Body', $pBody); $this->Set('Updated', NOW()); $this->Save(); return $this->Get('Identifier'); }
public function addstaffajax() { $config['upload_path'] = "uploads/staffs/"; $config['allowed_types'] = "gif|jpg|jpeg|png"; $config['max_size'] = "5000"; $config['max_width'] = "1907"; $config['max_height'] = "1280"; //$this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('photo')) { echo $this->upload->display_errors(); } else { $data = $this->upload->data(); $this->records = array('staffid' => $this->input->post('staffid', true), 'staffuserid' => $this->input->post('staffuserid', true), 'firstname' => $this->input->post('firstname', true), 'middlename' => $this->input->post('middlename', true), 'lastname' => $this->input->post('lastname', true), 'sphone' => $this->input->post('sphone', true), 'mailingaddress' => $this->input->post('mailingaddress', true), 'birthdate' => $this->input->post('birthdate', true), 'email' => $this->input->post('email', true), 'joindate' => NOW(), 'photo' => $data['file_name'], 'birthdate' => $this->input->post('birthdate', true), 'enrollmentstatus' => $this->input->post('enrollmentstatus', true), 'isActive' => 1); $this->urecords = array('username' => $this->input->post('staffuserid', true), 'created_on' => NOW(), 'first_name' => $this->input->post('firstname', true), 'phone' => $this->input->post('sphone', true), 'last_name' => $this->input->post('lastname', true)); $this->ugrpuprecords = array('user_id' => $this->input->post('id', true), 'group_id' => 5); $this->results = $this->common_model->insertRecords($this->common_model->_staffs, $this->records); $this->results = $this->common_model->insertRecords($this->common_model->_usersTable, $this->urecords); $this->results = $this->common_model->insertRecords($this->common_model->_users_groups, $this->ugrpuprecords); if ($this->results) { $this->status['status'] = 1; $this->status['msg'] = "Staff"; } else { $this->status['status'] = 0; $this->status['msg'] = "Something went wrong when saving the file, please try again."; } echo jsonEncode($this->status); } }
function insertRecord() { //print_r($this->input->post()); exit(); $data = array(); $data['first_name'] = $this->input->post('first_name', TRUE); $data['last_name'] = $this->input->post('last_name', TRUE); $data['email_addr'] = strtolower($this->input->post('email_addr', TRUE)); $data['tel_number'] = $this->input->post('tel_number', TRUE); $data['post_code'] = $this->input->post('post_code', TRUE); $data['enq_reason'] = $this->input->post('enq_reason', TRUE); $data['receive_update_news'] = $this->input->post('receive_update_news', TRUE); $data['how_reach'] = $this->input->post('how_reach', TRUE); $data['enquiry'] = $this->input->post('enquiry', TRUE); $data['souceSiteUser'] = '******'; $data['enq_creator_id'] = $this->loggId; $data['next_follow_up'] = date('Y-m-d'); /** * If any index is has false then empty string assign */ foreach ($data as $key => $val) { if (!$data[$key]) { $data[$key] = '0'; } } $data['insert_time'] = date('Y-m-d', NOW()); $data['next_follow_up'] = $data['insert_time']; $status = $this->db->insert($this->tbl, $data); if (!$status) { return FALSE; } $enquiry_id = $this->db->insert_id(); //fetch email details $email_dtls = $this->Emailsmodel->fetchDetails('enquiry_registration'); //Send Confirmation email $emailData = array(); $emailData['DATE'] = date("jS F, Y"); $emailData['NAME'] = $data['first_name'] . $data['last_name']; $emailData['EMAILADDR'] = $data['email_addr']; $search = array(); $replace = array(); $search[] = '{DATE}'; $replace[] = $emailData['DATE']; $search[] = '{NAME}'; $replace[] = $emailData['NAME']; $search[] = '{EMAILADDR}'; $replace[] = $emailData['EMAILADDR']; $emailBody = str_ireplace($search, $replace, $email_dtls['email_content']); //print_r($emailBody); exit(); $this->email->initialize($this->config->item('EMAIL_CONFIG')); $this->email->from(DWS_EMAIL_NOREPLY, DWS_EMAIL_FROM); $this->email->to($data['email_addr']); $this->email->subject($email_dtls['email_subject']); $this->email->message($emailBody); $status = $this->email->send(); $data['enquiry_id'] = $enquiry_id; return $data; }
function a10(&$db) { //project $close = NOW(); $close->sub(new DateInterval('P1M')); $sql = "UPDATE " . $db->prefix . "a10_project\n\t\t\tSET close_date='" . $close->format('Y-m-d') . "', accounting_idref=1;"; $db->exec($sql); return true; }
public function Create($pType, $pIdentifier, $pUserId) { $this->Protect('Reference_FK', null); $this->Set('User_FK', $pUserId); $this->Set('Type', $pType); $this->Set('Identifier', $pIdentifier); $this->Set('Stamp', NOW()); $this->Save(); return true; }
public static function startCouponSaving($coupon, $customerId) { $instance = new self(); $instance->couponId = $coupon->getCouponId(); $instance->requiredNumberOfProducts = $coupon->getRequiredNumberOfProducts(); $validUntil = Date('Y:m:d', strtotime($coupon->getValidity())); $instance->customerId = $customerId; $instance->creationDate = NOW(); $instance->validUntil = $validUntil; $instance->state = CouponState::OPEN; return $instance; }
public function onSalesOrderInvoicePay($observer) { Mage::log(" : onSalesOrderInvoicePay stap 1 ", null, 'custom.log'); try { $couponDao = new CouponDao(); $invoice = $observer->getEvent()->getInvoice(); $order = $invoice->getOrder(); // Method 1 unset($this->usedDiscountCoupons); // Unset $array. $this->usedDiscountCoupons = array(); // Reset $array to an empty array. foreach ($order->getAllItems() as $item) { // Do something with $item here... $name = $item->getName(); $price = $item->getPrice(); $_product = Mage::getModel('catalog/product')->load($item->getProductId()); $manufacturerName = $_product->getAttributeText('manufacturer'); $coupon = $couponDao->loadCouponByBrand($manufacturerName); if ($coupon != null) { for ($i = 1; $i <= $item->getQtyOrdered(); $i++) { $couponSaving = $couponDao->loadInInVoiceCouponSaving($coupon->getCouponId(), $order->getCustomerId()); if ($couponSaving != null) { $couponDao->setCouponSavingToUsed($couponSaving); } else { if ($price >= $coupon->getMinPrice() && !$this->discountCouponUsed($order, $manufacturerName)) { $couponSaving = $couponDao->loadCouponSaving($coupon->getCouponId(), $order->getCustomerId(), CouponState::OPEN); if ($couponSaving == null) { $couponSavingNew = CouponSaving::startCouponSaving($coupon, $order->getCustomerId()); $couponSaving = $couponDao->createCouponSaving($couponSavingNew); } $couponSavingId = $couponSaving->getCouponSavingId(); if (NOW() >= $couponSaving->getValidUntil()) { $couponDao->updateCouponSaving($couponSaving); $couponSavingNew = CouponSaving::startCouponSaving($coupon, $order->getCustomerId()); $couponSavingNew = $couponDao->createCouponSaving($couponSavingNew); $couponSavingIdNew = $couponSavingNew->getCouponSavingId(); $couponDao->createStamp($couponSavingIdNew, $name, $price, $order->getIncrementId()); } else { $couponDao->createStamp($couponSavingId, $name, $price, $order->getIncrementId()); $couponDao->updateCouponSaving($couponSaving); } } } } } } } catch (Exception $e) { Mage::log("exception " + $e, null); } return $this; }
private function _IsPast($pTime, $pDistance) { if (!$pTime) { return false; } $now = strtotime(NOW()); $diff = $now - $pTime; $diffMinutes = $diff / 60; if ($diffMinutes < $pDistance) { return false; } return true; }
public function Store($pContext, $pId, $pBody, $pParent, $pOwner) { $this->Protect('Entry_PK'); $this->Set('Body', $pBody); $this->Set('Parent_ID', $pParent); $this->Set('Owner', $pOwner); $this->Set('Created', NOW()); $this->Set('Context', $pContext); $this->Set('Context_FK', $pId); $this->Set('Status', 1); $this->Set('Address', $_SERVER['REMOTE_ADDR']); $this->Save(); return true; }
public function Index($pContext, $pContext_FK, $pKeywords) { $this->Retrieve(array('Context' => $pContext, 'Context_FK' => $pContext_FK)); if ($this->Get('Total') > 0) { $this->Fetch(); } else { $this->Set('Created', NOW()); } $this->Set('Context', $pContext); $this->Set('Context_FK', $pContext_FK); $this->Set('Keywords', $pKeywords); $this->Set('Updated', NOW()); $this->Save(); return true; }
public function Send($pData = array()) { if ($this->_Source != 'Component') { return false; } include_once ASD_PATH . 'components/postal/controllers/postal.php'; $Controller = new cPostalPostalController(); $Type = strtolower($pData['Type']); $SenderFullname = $pData['SenderFullname']; $SenderAccount = $pData['SenderAccount']; $RecipientEmail = $pData['RecipientEmail']; $MailSubject = $pData['MailSubject']; $Byline = $pData['Byline']; $Subject = $pData['Subject']; $Body = str_replace("\n", "<br />", $pData['Body']); $LinkDescription = $pData['LinkDescription']; $Link = $pData['Link']; $Stamp = $this->GetSys('Date')->Format(NOW(), true); $data = array('account' => $SenderAccount, 'source' => ASD_DOMAIN); $AccountLink = $this->GetSys('Event')->Trigger('Create', 'User', 'Link', $data); $View = $Controller->GetView($Type); list($username, $domain) = explode('@', $SenderAccount); $IconData = array('username' => $username, 'domain' => $domain, 'width' => 64, 'height' => 64); $View->Find('.icon', 0)->src = $this->GetSys('Event')->Trigger('On', 'User', 'Icon', $IconData); $View->Find('.fullname', 0)->innertext = $SenderFullname; $View->Find('.fullname', 0)->href = $AccountLink; $View->Find('.account', 0)->innertext = $SenderAccount; $View->Find('.account', 0)->href = $AccountLink; $View->Find('.byline-description', 0)->innertext = $Byline; $View->Find('.subject', 0)->innertext = $Subject; $View->Find('.body', 0)->innertext = $Body; $View->Find('.stamp', 0)->innertext = $Stamp; $View->Find('.link-description', 0)->innertext = $LinkDescription; $View->Find('.link', 0)->src = $Link; $View->Find('.link', 0)->innertext = $Link; $View->Find('.link', 0)->href = $Link; $from = "no-reply@" . ASD_DOMAIN; $fromName = "Appleseed"; $to = $RecipientEmail; $toName = $RecipientEmail; $subject = $MailSubject; $body = $View->Buffer(); $Mailer = $this->GetSys("Mailer"); if (!$Mailer->Send($from, $fromName, $to, $toName, $subject, $body)) { return false; } return true; }
public function EndFooterDisplay($pData = null) { $Model = new cModel('Janitor'); $Model->Retrieve(array('Task' => 'Janitorial')); $Model->Fetch(); $lastUpdated = strtotime($Model->Get('Updated')); $now = strtotime(NOW()); $diff = $now - $lastUpdated; $diffMinutes = $diff / 60; // If we've recently updated, don't ping the Janitor. if ($diffMinutes < 1) { return true; } $this->_Janitorial(); return true; }
public function InviteCode($pAddress, $pUserId) { $this->Retrieve(array('Account_FK' => $pUserId, 'Active' => 1)); if ($this->Get('Total') == 0) { return false; } $this->Fetch(); $this->Protect('Invite_PK'); $this->Set('Recipient', $pAddress); $this->Set('Active', 2); // Pending $this->Set('Stamp', NOW()); if ($this->Save(array('Invite_PK' => $this->Get('Invite_PK')))) { return $this->Get('Value'); } return false; }
public function returnConsignment($shipment_id, $consignment_number, $transfer_id) { try { $shipment = Mage::getModel("sales/order_shipment")->loadByIncrementId($shipment_id); $consignment = Mage::getModel('dpd/consignment'); $consignment->setTransferId($transfer_id); if (Mage::getStoreConfig('dpd/misc/emailcustomer') == TRUE) { $customer = array(); $customer['name'] = $shipment->getOrder()->getCustomerFirstname() . ' ' . $shipment->getOrder()->getCustomerLastname(); $customer['email'] = $shipment->getOrder()->getCustomerEmail(); $consignment->setEmail($customer['email']); } $consignment->setConsignment($consignment_number); $consignment->setReturned(NOW()); $consignment->setStatus(3); $consignment->save(); if (Mage::getStoreConfig('dpd/advanced/activity') == 1) { Mage::log('Shipment #' . $shipment_id . '(' . $transfer_id . ') returned (' . $consignment_number . ')', null, 'madcapsule_system.log'); } } catch (Exception $e) { Mage::log('Unable to update tracking for shipment #' . $shipment_id . ' (' . $consignment_number . ')', null, 'madcapsule_system.log'); return; } $track = Mage::getModel('sales/order_shipment_track')->setShipment($shipment)->setData('title', 'DPD')->setData('number', $consignment_number)->setData('carrier_code', 'custom')->setData('order_id', $shipment->getData('order_id'))->save(); /* $tracking_add = Mage::getModel('sales/order_shipment_api')->addTrack($shipment_id, 'custom', 'DPD', $consignment_number); */ if ($tracking_add && Mage::getStoreConfig('dpd/advanced/activity') == 1) { Mage::log('Tracking added: ' . $consignment_number . ' for shipment #' . $shipment_id . '', null, 'madcapsule_system.log'); } if (Mage::getStoreConfig('dpd/misc/emailcustomer') == TRUE) { $emailTemplate = Mage::getModel('core/email_template')->loadDefault('madcapsule_dpd_tracking_template'); $emailTemplateVariables = array(); $emailTemplateVariables['consignment'] = $consignment_number; $emailTemplate->setTemplateSubject('Your order has been dispatched'); $storeEmail = Mage::getStoreConfig('trans_email/ident_general/email'); $storeContact = Mage::getStoreConfig('trans_email/ident_general/name'); $emailTemplate->setSenderEmail($storeEmail); $emailTemplate->setSenderName($storeContact); $emailTemplate->send($customer['email'], $customer['name'], $emailTemplateVariables); if (Mage::getStoreConfig('dpd/advanced/activity') == 1) { Mage::log('DPD tracking email sent to ' . $customer['email'] . '', null, 'madcapsule_system.log'); } } }
function addmp3info($type, $rlsname, $genre, $year, $hertz, $tp, $bitrate, $bittype, $fromnet, $ann = true) { $w = mysql_query("SELECT COUNT(id) AS tid FROM mp3info WHERE rlsname = " . sqlesc($rlsname) . "") or exit("Err1 " . mysql_error()); $qw = mysql_fetch_assoc($w); if ($qw['tid'] == 0) { $fromdata = explode(":", trim($fromnet)); $fromdata[1] = "#" . $fromdata[1]; mysql_query("INSERT INTO mp3info ( `rlsname` , `genre` , `year` , `hertz` , `type` , `bitrate` , `bittype` , `unixtime` , `addedon` , `fromnet` ) VALUES (" . sqlesc($rlsname) . "," . sqlesc($genre) . "," . sqlesc($year) . "," . sqlesc($hertz) . "," . sqlesc($tp) . "," . sqlesc($bitrate) . "," . sqlesc($bittype) . "," . time() . "," . NOW() . "," . sqlesc($fromnet) . ")") or exit('Err2 ' . mysql_error()); $id = mysql_insert_id(); mysql_query("INSERT INTO frominfodata ( `infoid` , `type` , `time` , `nick` , `chan` , `network` ) VALUES (" . $id . "," . sqlesc($type) . "," . time() . "," . sqlesc($fromdata[0]) . "," . sqlesc($fromdata[1]) . "," . sqlesc($fromdata[2]) . ")") or exit('Err3 ' . mysql_error()); if ($ann == true) { $sbotdata = array($type, $rlsname, $genre, $year, $hertz, $tp, $bitrate, $bittype); sendbot(join(" ", $sbotdata)); return; } else { return; } } }
public function Queue($pOwnerId, $pAction, $pActionOwner, $pActionLink, $pSubjectOwner, $pContext, $pContextOwner, $pContextLink, $pTitle, $pIcon, $pComment, $pDescription, $pIdentifier, $pCreated = null, $pUpdated = null) { if ($pIdentifier) { $this->Retrieve(array('Owner_FK' => $pOwnerId, 'Identifier' => $pIdentifier)); if ($this->Get('Total') > 0) { $this->Fetch(); } else { $this->Set('Incoming_PK', null); } } else { $this->Set('Incoming_PK', null); } $this->Protect('Incoming_PK'); $this->Set('Owner_FK', $pOwnerId); $this->Set('Action', $pAction); $this->Set('ActionOwner', $pActionOwner); $this->Set('ActionLink', $pActionLink); $this->Set('SubjectOwner', $pSubjectOwner); $this->Set('Context', $pContext); $this->Set('ContextOwner', $pContextOwner); $this->Set('ContextLink', $pContextLink); $this->Set('Title', $pTitle); $this->Set('Icon', $pIcon); $this->Set('Comment', $pComment); $this->Set('Description', $pDescription); $this->Set('Identifier', $pIdentifier); if ($pCreated) { $this->Set('Created', $pCreated); } else { $this->Set('Created', NOW()); } if ($pUpdated) { $this->Set('Updated', $pUpdated); } else { $this->Set('Updated', NOW()); } $this->Save(); if ($this->Get('Error')) { return false; } return true; }
/** * Function used to insert log * @param VARCHAR $type, type of action * @param ARRAY $details_array , action details array */ function insert($type, $details_array) { global $db, $userquery; $a = $details_array; $ip = $_SERVER['REMOTE_ADDR']; $agent = $_SERVER['HTTP_USER_AGENT']; $userid = getArrayValue($a, 'userid'); $username = $a['username']; $useremail = getArrayValue($a, 'useremail'); $userlevel = getArrayValue($a, 'userlevel'); $action_obj_id = getArrayValue($a, 'action_obj_id'); $action_done_id = getArrayValue($a, 'action_done_id'); $userid = $userid ? $userid : $userquery->udetails['userid']; $username = $username ? $username : $userquery->udetails['username']; $useremail = $useremail ? $useremail : $userquery->udetails['email']; $userlevel = $userlevel ? $userlevel : getArrayValue($userquery->udetails, 'level'); $success = $a['success']; $details = getArrayValue($a, 'details'); $db->insert(tbl('action_log'), array('action_type', 'action_username', 'action_userid', 'action_useremail', 'action_ip', 'date_added', 'action_success', 'action_details', 'action_userlevel', 'action_obj_id', 'action_done_id'), array($type, $username, $userid, $useremail, $ip, NOW(), $success, $details, $userlevel, $action_obj_id, $action_done_id)); }
public function Queue($pOwnerId, $pRecipient, $pAction, $pActionOwner, $pActionLink, $pSubjectOwner, $pContext, $pContextOwner, $pContextLink, $pTitle, $pIcon, $pComment, $pDescription, $pIdentifier) { $this->Protect('Outgoing_PK', null); $this->Set('Owner_FK', $pOwnerId); $this->Set('Recipient', $pRecipient); $this->Set('Action', $pAction); $this->Set('ActionOwner', $pActionOwner); $this->Set('ActionLink', $pActionLink); $this->Set('SubjectOwner', $pSubjectOwner); $this->Set('Context', $pContext); $this->Set('ContextOwner', $pContextOwner); $this->Set('ContextLink', $pContextLink); $this->Set('Title', $pTitle); $this->Set('Icon', $pIcon); $this->Set('Comment', $pComment); $this->Set('Description', $pDescription); $this->Set('Identifier', $pIdentifier); $this->Set('Created', NOW()); $this->Set('Updated', NOW()); $this->Create(); return true; }
public function writeOrderImei($orderNo, $orderInfo, $log_file) { $sql = "SELECT imeiCode,creationDate FROM po_purchase_order_shipping_imei WHERE orderno = '" . $orderNo . "'"; $read = Mage::getSingleton("core/resource")->getConnection('core_read'); $results = $read->fetchAll($sql); foreach ($results as $item) { $sql = "INSERT INTO `wms_sales_order_imei`(institution_code, orderNo, imeiCode, createTime, deleteFlag, has_packScan) VALUES ('0102' ,'" . $orderNo . "','" . $item['imeiCode'] . "', '" . NOW() . "', 'N' , '1' );" . PHP_EOL; @file_put_contents($log_file, $sql . PHP_EOL, FILE_APPEND); } }
Description: <br /><textarea name="description" cols="20" rows="2"><?php echo $row["description"]; ?> </textarea> <br /> Old Start Date: <?php echo $row["startDate"]; ?> <br /> <?php if ($row["startDate"] > NOW()) { ?> New Start Date: <input type="date" name="startdate" id="start date" style="width:140px!important;height:25px" /> <?php } else { if ($row["endDate"] <= NOW()) { ?> Unable to change Start Date as project is ongoing! <?php } else { echo "Project has ended!"; } } ?> <br /><br /> Old End Date: <?php echo $row["endDate"]; ?> <br /> New End Date: <input type="date" name="enddate" id="start date" style="width:140px!important;height:25px" />
function incrementDownload($Array) { global $db; if (!isset($_COOKIE[$Array['photo_id'] . "_downloaded"])) { $db->update(tbl('photos'), array('downloaded'), array('|f|downloaded+1'), ' photo_id = "' . $Array['photo_id'] . '"'); setcookie($Array['photo_id'] . "_downloaded", NOW(), time() + 1800); } }
} foreach ($results['data'] as $result) { // break if you find a photo created later than the latest if (isset($latest_date) && (int) $result["created_time"] <= $latest_date) { break; } // escape properties in _POST into variables $name = $sqli->escapeString($result["user"]["username"]); $date = $sqli->escapeString($result["created_time"]); if ($result["location"]["name"]) { $location = $sqli->escapeString($result["location"]["name"]); } else { // find address from google maps? $latitude = $sqli->escapeString($result["location"]["latitude"]); $longitude = $sqli->escapeString($result["location"]["longitude"]); $location = '(location not given)'; } $comments = $sqli->escapeString($result["caption"]["text"]); $file_https = preg_replace('/http:.*[^\\s]/', 'https://', $result["images"]["standard_resolution"]["url"]); $file_name = $sqli->escapeString($file_https); $date = date('m\\/d\\/y', $date); !isset($date) ? $date = date('m\\/d\\/y', NOW()) : ''; $sql = "INSERT INTO uploads (`name`, `date`, `location`, `photo`, `email`, `comments`, `date_added`)\n VALUES ('{$name}', '{$date}', '{$location}', '{$file_name}', 'NA', '{$comments}', NOW());"; $sqli_result = $sqli->query($sql); if (!$sqli_result) { die('ispy insert not completed: ' . $sqli->lastErrorMsg); } // free result set // mysqli_free_result($mysqli_result); } $sqli->close();
function insertFranchiseRecord() { $data = array(); $numeric = array('receive_update_news', 'enq_reason'); $data['first_name'] = $this->input->post('first_name', TRUE); $data['last_name'] = $this->input->post('last_name', TRUE); $data['email_addr'] = strtolower($this->input->post('email_addr', TRUE)); $data['tel_number'] = $this->input->post('tel_number', TRUE); $data['post_code'] = $this->input->post('post_code', TRUE); $data['enq_reason'] = $this->input->post('enq_reason', TRUE); $data['receive_update_news'] = $this->input->post('receive_update_news', TRUE); $data['how_reach'] = $this->input->post('how_reach', TRUE); $data['enquiry'] = $this->input->post('enquiry', TRUE); $data['franchise'] = $this->input->post('franchiseeId', TRUE); /** * If any index is has false then empty string assign */ foreach ($data as $key => $val) { if (!$data[$key]) { $data[$key] = ''; } if (in_array($key, $numeric) && empty($data[$key])) { $data[$key] = '0'; } } $data['event_related'] = setDefault($_POST['event_id'], 0, 1); $data['event_id'] = setDefault($_POST['event_id'], 0); $data['event_creator_id'] = setDefault($_POST['event_user_id'], 0); $data['insert_time'] = date('Y-m-d', NOW()); $data['next_follow_up'] = $data['insert_time']; $data['souceSiteUser'] = 3; $status = $this->db->insert($this->tbl, $data); if (!$status) { return false; } $enquiry_id = $this->db->insert_id(); $data['enquiry_id'] = $enquiry_id; return $data; }
/** * Used to rate photo */ function rate_collection($id, $rating) { global $db, $json; if (!is_numeric($rating) || $rating <= 9) { $rating = 0; } if ($rating >= 10) { $rating = 10; } $c_rating = $this->current_rating($id); $voters = $c_rating['voters']; $new_rate = $c_rating['rating']; $rated_by = $c_rating['rated_by']; if (phpversion < '5.2.0') { $voters = $json->json_decode($voters, TRUE); } else { $voters = json_decode($voters, TRUE); } if (!empty($voters)) { $already_voted = array_key_exists(userid(), $voters); } if (!userid()) { e(lang("please_login_to_rate")); } elseif (userid() == $c_rating['userid'] && !config('own_collection_rating')) { e(lang("you_cannot_rate_own_collection")); } elseif (!empty($already_voted)) { e(lang("you_hv_already_rated_photo")); } elseif ($c_rating['allow_rating'] == 'no' || !config('collection_rating')) { e(lang("collection_rating_not_allowed")); } else { $voters[userid()] = array('rate' => $rating, 'time' => NOW()); if (phpversion < '5.2.0') { $voters = $json->json_encode($voters); } else { $voters = json_encode($voters); } $t = $c_rating['rated_by'] * $c_rating['rating']; $rated_by = $c_rating['rated_by'] + 1; $new_rate = ($t + $rating) / $rated_by; $db->update(tbl('collections'), array('rating', 'rated_by', 'voters'), array("{$new_rate}", "{$rated_by}", "|no_mc|{$voters}"), " collection_id = " . $id . ""); $userDetails = array("object_id" => $id, "type" => "collection", "time" => now(), "rating" => $rating, "userid" => userid(), "username" => username()); /* Updating user details */ update_user_voted($userDetails); e(lang("thnx_for_voting"), "m"); } $return = array("rating" => $new_rate, "rated_by" => $rated_by, 'total' => 10, "id" => $id, "type" => "collection", "disable" => "disabled"); return $return; }
/** * Create user avatar collection */ function cb_create_user_avatar_collection($uid = null) { global $db, $userquery, $cbcollection; if (is_null($uid)) { $uid = userid(); } if (!$uid) { return; } if (is_array($uid)) { $user = $uid; } else { $user = $userquery->get_user_details($uid); } if (!empty($user)) { if ($user['avatar_collection'] == 0) { /* User has no avatar collection. Create one */ $details = array('collection_name' => ($user['username'] ? $user['username'] : '******') . ' Avatars', 'collection_description' => 'Collection of user avatars', 'collection_tags' => ' ', 'category' => '#' . $cbcollection->get_avatar_collection_id() . '#', 'userid' => $user['userid'], 'date_added' => NOW(), 'is_avatar_collection' => 'yes', 'type' => 'photos', 'active' => 'yes', 'public_upload' => 'no', 'broadcast' => 'public', 'allow_comments' => 'yes'); /* Insert collection */ $insert_id = $db->insert(tbl($cbcollection->section_tbl), array_keys($details), array_values($details)); if ($insert_id) { /* update user column avatar_collection */ $db->update(tbl('users'), array('avatar_collection'), array($insert_id), " userid = '" . $user['userid'] . "' "); return $insert_id; } } else { return $user['avatar_collection']; } } }
public function swith2QuoteAction() { //unique id for c2q session $c2qId = Mage::getSingleton('adminhtml/session')->getUpdateQuoteId(); //null; //pool error messages $errorMsg = array(); $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote(); $baseToQuoteRate = $quote->getData('base_to_quote_rate'); $currencyCode = $quote->getData('quote_currency_code'); $customerId = $quote->getCustomer()->getId(); if (!$customerId && $quote->getData('customer_email')) { $this->_saveCustomerAfterQuote($quote); $customerId = $quote->getCustomer()->getId(); } $billingAddress = $quote->getBillingAddress(); $shipAddress = $quote->getShippingAddress(); $email = $quote->getCustomer()->getEmail(); $items = $quote->getAllItems(); if (!Mage::getStoreConfig('qquoteadv/general/enabled', $quote->getStoreId())) { $errorMsg[] = $this->__("Module is disabled"); } if (empty($customerId)) { $errorMsg[] = $this->__("Customer not recognized for new quote"); } if (empty($email)) { $errorMsg[] = $this->__("Customer's email was undefined"); } if (!count($items)) { $errorMsg[] = $this->__("There was an error, because the product quantities were not defined"); } foreach ($items as $item) { // TODO : // Function doesn't work on all installations! // Check if product is a configurable product $checkConfigurable = Mage::helper('qquoteadv')->isConfigurable($item, $item->getData('qty')); if ($checkConfigurable != false) { $qty = $checkConfigurable; } else { $qty = $item->getData('qty'); } $check = Mage::helper('qquoteadv')->isQuoteable($item, $qty); if ($check->getHasErrors()) { $errors = $check->getErrors(); $errorMsg = array_merge($errorMsg, $errors); } } Mage::unregister('conf_parent'); //#return back in case any error found if (count($errorMsg)) { $this->_redirectErr($errorMsg); return; } //#c2q insert data if ($customerId && $email) { $modelCustomer = Mage::getModel('qquoteadv/qqadvcustomer'); $copyShippingParams = array('shipping_amount' => 'shipping_amount', 'base_shipping_amount' => 'base_shipping_amount', 'shipping_amount_incl_tax' => 'shipping_amount_incl_tax', 'base_shipping_amount_incl_tax' => 'base_shipping_amount_incl_tax', 'base_shipping_tax_amount' => 'base_shipping_tax_amount', 'shipping_tax_amount' => 'shipping_tax_amount', 'address_shipping_method' => 'shipping_method', 'address_shipping_description' => 'shipping_description'); $shipRates = $shipAddress->getShippingRatesCollection(); $copyRateParams = array(); $rate = null; foreach ($shipRates as $rates) { if ($rates['code'] == $shipAddress->getShippingMethod()) { $rate = $rates; $copyRateParams = array('shipping_method' => 'method', 'shipping_description' => 'method_description', 'shipping_method_title' => 'method_title', 'shipping_carrier' => 'carrier', 'shipping_carrier_title' => 'carrier_title', 'shipping_code' => 'code'); break; } } $shipStreet = ""; $billStreet = ""; $shipAddressExists = false; foreach ($shipAddress->getStreet() as $addressLine) { if ($addressLine != "") { $shipAddressExists = true; } } $billAddressExists = false; foreach ($billingAddress->getStreet() as $addressLine) { if ($addressLine != "") { $shipAddressExists = true; } } if ($shipAddressExists) { $shipStreet = implode(',', $shipAddress->getStreet()); } if ($billAddressExists) { $billStreet = implode(',', $billingAddress->getStreet()); } if (!$c2qId) { $name = $billingAddress->getFirstname(); if ($name != "") { // && count($quote->getCustomer()->getAddresses()) ){ /* @var $helper Ophirah_Qquoteadv_Helper_Data */ $helper = Mage::helper('qquoteadv'); /* @var $admin Mage_Admin_Model_Session */ $admin = Mage::getSingleton('admin/session'); $qcustomer = array('created_at' => NOW(), 'updated_at' => NOW(), 'customer_id' => $customerId, 'currency' => $currencyCode, 'base_to_quote_rate' => $baseToQuoteRate, 'prefix' => $billingAddress->getPrefix(), 'firstname' => $billingAddress->getFirstname(), 'middlename' => $billingAddress->getMiddlename(), 'lastname' => $billingAddress->getLastname(), 'suffix' => $billingAddress->getSuffix(), 'company' => $billingAddress->getCompany(), 'email' => $email, 'country_id' => $billingAddress->getCountryId(), 'region' => $billingAddress->getRegion(), 'city' => $billingAddress->getCity(), 'address' => $billStreet, 'postcode' => $billingAddress->getPostcode(), 'telephone' => $billingAddress->getTelephone(), 'fax' => $billingAddress->getFax(), 'store_id' => $quote->getStoreId(), 'user_id' => $helper->getExpectedQuoteAdminId($modelCustomer, $admin->getUserId()), 'shipping_prefix' => $shipAddress->getData("prefix"), 'shipping_firstname' => $shipAddress->getData("firstname"), 'shipping_middlename' => $shipAddress->getData("middlename"), 'shipping_lastname' => $shipAddress->getData("lastname"), 'shipping_suffix' => $shipAddress->getData("suffix"), 'shipping_company' => $shipAddress->getData("company"), 'shipping_country_id' => $shipAddress->getData("country_id"), 'shipping_region' => $shipAddress->getData("region"), 'shipping_region_id' => $shipAddress->getData("region_id"), 'shipping_city' => $shipAddress->getData("city"), 'shipping_address' => $shipStreet, 'shipping_postcode' => $shipAddress->getData("postcode"), 'shipping_telephone' => $shipAddress->getData("telephone"), 'shipping_fax' => $shipAddress->getData("fax")); foreach ($copyShippingParams as $key) { $qcustomer[$key] = $shipAddress->getData($key); } foreach ($copyRateParams as $key => $value) { $qcustomer[$key] = $rate[$value]; } //#add customer to c2q try { $c2qId = $modelCustomer->addQuote($qcustomer)->getQuoteId(); //#save c2q id into session $this->getCustomerSession()->setQuoteadvId($c2qId); } catch (Exception $e) { Mage::log($e->getMessage()); } } else { $errorMsg[] = $this->__("There was an error, because the customer address was undefined"); } } else { $this->getCustomerSession()->setQuoteadvId($c2qId); $shipStreet = implode(',', $shipAddress->getStreet()); $billingStreet = $shipStreet; $params = array(); $params['currency'] = $currencyCode; $params['shipping_address'] = $shipStreet; //$params['shipping_title'] = $rates[$value]; $billingParams = array('firstname', 'lastname', 'middlename', 'suffix', 'company', 'country_id', 'region_id', 'city'); foreach ($billingParams as $value) { //Mage::Log('CSP'.$key.":".$shipAddress->getData($value)); $params[$value] = $billingAddress->getData($value); } $params['street'] = $billingStreet; foreach ($shipAddress->getData() as $key => $value) { $params["shipping_" . $key] = $value; } foreach ($copyShippingParams as $key => $value) { //Mage::Log('CSP'.$key.":".$shipAddress->getData($value)); $params[$key] = $shipAddress->getData($value); } foreach ($copyRateParams as $key => $value) { // Mage::Log('CRP'.$key.":".$rate[$value]); $params[$key] = $rate[$value]; } if (count($params) > 0) { try { $modelCustomer = Mage::getModel('qquoteadv/qqadvcustomer')->updateQuote($c2qId, $params); } catch (Exception $e) { Mage::log($e->getMessage()); } } $qCollection = Mage::getModel('qquoteadv/qqadvproduct'); $ids = $qCollection->getIdsByQuoteId($c2qId); if ($ids) { foreach ($ids as $lineId) { try { // remove item to quote mode Mage::getModel('qquoteadv/qqadvproduct')->deleteQuote($lineId); } catch (Exception $e) { $errorQuote[] = $e->getMessage(); } } } } //#return back in case any error found if (count($errorMsg)) { $this->_redirectErr($errorMsg); return; } //#parse in case quote has items foreach ($quote->getAllVisibleItems() as $item) { $superAttribute = $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct()); $optionalAttrib = ''; if (isset($superAttribute['info_buyRequest'])) { if (isset($superAttribute['info_buyRequest']['uenc'])) { unset($superAttribute['info_buyRequest']['uenc']); } $superAttribute['info_buyRequest']['qty'] = $item->getQty(); $optionalAttrib = serialize($superAttribute['info_buyRequest']); } if ($item->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) { $original_price = $item->getPrice(); } else { $original_price = $item->getProduct()->getPrice(); } // Only Custom Prices needs to be recalculated by currency rate if ($item->getOriginalCustomPrice()) { $rate = $baseToQuoteRate; $customPrice = $item->getOriginalCustomPrice(); } else { $rate = 1; $customPrice = $item->getPrice() * $baseToQuoteRate; } $params = array('product_id' => $item->getProductId(), 'qty' => $item->getQty(), 'price' => $item->getPrice() / $rate, 'custom_price' => $customPrice, 'original_price' => $original_price, 'base_quote_rate' => $baseToQuoteRate); $this->_create($params, $optionalAttrib); } //#update c2q status to make visible c2q request try { $modelCustomer->load($c2qId); $modelCustomer->setIsQuote(1); $modelCustomer->setStatus(Ophirah_Qquoteadv_Model_Status::STATUS_PROPOSAL_SAVED); //#for new quote we need correct increment id if (!Mage::getSingleton('adminhtml/session')->getUpdateQuoteId()) { $modelCustomer->setIncrementId(Mage::getModel('qquoteadv/entity_increment_numeric')->getNextId()); } // Save data $modelCustomer->save(); Mage::helper('qquoteadv')->sentAnonymousData('request', 'b'); } catch (Exception $e) { Mage::log($e->getMessage()); } Mage::getSingleton('adminhtml/session_quote')->clear(); } //if Mage::getSingleton('adminhtml/session')->setUpdateQuoteId(null); if ($c2qId) { $this->_redirect('*/*/edit', array('id' => $c2qId)); } else { $this->_redirect('*/*'); } }
/** * Function used to start log */ function start_log() { $this->log = "Started on " . NOW() . " - " . date("Y M d") . "\r\n\n"; $this->log .= "Checking File ....\r\n"; $this->log('File', $this->input_file); }
/** * Function used to incream number of view * in object */ function increment_views($id, $type = NULL) { global $db; switch ($type) { case 'v': case 'video': default: $video = get_video_details($id); if (!$video) { return false; } if ($video['active'] != 'yes' || $video['status'] != 'Successful') { return false; } if (function_exists('vi_user_type')) { $_user = vi_user_type(); if ($_user['user_type'] == 4) { return false; } } if (!isset($_COOKIE['video_' . $id])) { $db->update(tbl("video"), array("views", "last_viewed"), array("|f|views+1", NOW()), " videoid='{$id}' OR videokey='{$id}'"); setcookie('video_' . $id, 'watched', time() + 3600); } break; case 'u': case 'user': case 'channel': if (!isset($_COOKIE['user_' . $id])) { $db->update(tbl("users"), array("profile_hits"), array("|f|profile_hits+1"), " userid='{$id}'"); setcookie('user_' . $id, 'watched', time() + 3600); } break; case 't': case 'topic': if (!isset($_COOKIE['topic_' . $id])) { $db->update(tbl("group_topics"), array("total_views"), array("|f|total_views+1"), " topic_id='{$id}'"); setcookie('topic_' . $id, 'watched', time() + 3600); } break; break; case 'g': case 'group': if (!isset($_COOKIE['group_' . $id])) { $db->update(tbl("groups"), array("total_views"), array("|f|total_views+1"), " group_id='{$id}'"); setcookie('group_' . $id, 'watched', time() + 3600); } break; case "c": case "collect": case "collection": if (!isset($_COOKIE['collection_' . $id])) { $db->update(tbl("collections"), array("views"), array("|f|views+1"), " collection_id = '{$id}'"); setcookie('collection_' . $id, 'viewed', time() + 3600); } break; case "photos": case "photo": case "p": if (!isset($_COOKIE['photo_' . $id])) { $db->update(tbl('photos'), array("views", "last_viewed"), array("|f|views+1", NOW()), " photo_id = '{$id}'"); setcookie('photo_' . $id, 'viewed', time() + 3600); } } }
function addFollow() { $data = array(); $enquiryActive = $this->input->post('deactive', TRUE); $enq_id = $_POST['enq_id']; $data['enquiry_id'] = $enq_id; //validation check $this->form_validation->set_rules('follow_way', 'How you follow', 'trim|required'); $this->form_validation->set_rules('next_follow_up', 'Fill Follow Date', 'trim|required'); $this->form_validation->set_rules('description', 'Comment Required', 'trim|required'); $data['follow_way'] = $this->input->post('follow_way', TRUE); $data['next_follow_up'] = $this->input->post('next_follow_up', TRUE); $data['description'] = $this->input->post('description', TRUE); $data['followup_dtime'] = date('Y-m-d', NOW()); $data['next_follow_up'] = date('Y-m-d', strtotime($data['next_follow_up'])); if ($enquiryActive) { $data['enq_status'] = 5; } if ($this->db->insert('dpd_enquiry_followup', $data)) { if ($enquiryActive) { $data = array('active' => 0, 'status' => 5, 'next_follow_up' => $data['next_follow_up'], 'enquiry_id' => $data['enquiry_id']); $this->db->where('id', $data['enquiry_id'])->update('enquiry', $data); } else { $data = array('next_follow_up' => $data['next_follow_up']); $this->db->where('id', $enq_id)->update('enquiry', $data); } } redirect('enquiry'); exit; }