Example #1
0
 public function scrapeCrime($page = 0, $city)
 {
     $url = $this->source . '&page=' . $page;
     $response = json_encode(simplexml_load_string(file_get_contents($url)));
     $data = json_decode($response, true);
     $jsonArray = [];
     $json = ['title' => null, 'location' => ['lat' => null, 'lon' => null], 'link' => null, 'date_occured' => new \DateTime(), 'severity' => 0, 'city' => null];
     $items = $data['channel'];
     foreach ($items['item'] as $item) {
         $title;
         $dateOccured;
         if (isset($item['title'])) {
             $start = $end = 0;
             $start = strpos($item['title'], '(');
             $end = strpos($item['title'], ')');
             $title = trim(substr(' ' . $item['title'], 0, $start));
             $dateOccured = \DateTime::CreateFromFormat('M d, Y', trim(substr($item['title'], $start + 1, $end - 1)));
             $json['title'] = $title;
             $json['date_occured'] = $dateOccured;
             $json['severity'] = $this->calcSeverity($title);
         }
         if (isset($item['loc'])) {
             $json['location']['lon'] = $item['loc']['lon'];
             $json['location']['lat'] = $item['loc']['lat'];
         }
         if (isset($item['link'])) {
             $json['link'] = $item['link'];
         }
         $json['city'] = $city;
         //print_r($json['city']);
         array_push($jsonArray, $json);
     }
     print_r($jsonArray);
     return $jsonArray;
 }
 /**
  * The onNewVisit method is triggered when a new visitor is detected. This means here you can define an initial
  * value for this user. By returning boolean false no value will be saved. Once the user makes another action the
  * event "onExistingVisit" is executed. That means for each visitor this method is executed once. If you do not want
  * to perform any action on a new visit you can just remove this method.
  *
  * @param Request $request
  * @param Visitor $visitor
  * @param Action|null $action
  * @return mixed|false
  */
 public function onNewVisit(Request $request, Visitor $visitor, $action)
 {
     $localDate = \DateTime::CreateFromFormat("H:i:s", $request->getLocalTime());
     $isOddHour = HourParity\isOddHour($localDate);
     if ($isOddHour) {
         return 1;
     }
     return 0;
 }
 public static function isExtraHour($datetime)
 {
     $dt = DateTime::CreateFromFormat("Y-m-d H:i:s", $datetime);
     $hour = $dt->format('H');
     // '07'
     switch ((int) $hour) {
         case 6:
         case 7:
         case 20:
         case 21:
             return true;
             break;
         default:
             return false;
             break;
     }
 }
Example #4
0
/**
 * Tokenize a date
 * @param a date formatted as YYYY-MM-DD
 * @return an array containing the date components in a cashpot query format
 */
function tokenize_date($date_string)
{
    /*
    Note that CreateFromFormat will calculate an input (invalid) date of 2011-07-33 
    to 2011-08-02 so a further checkdate() is performed. CreateFromFormat is run
    first to ensure the format is correct.
    */
    if (!($date = DateTime::CreateFromFormat('Y-m-d', $date_string))) {
        throw new Exception("Error: Invalid date. Use a valid date with the format yyyy-mm-dd");
    }
    $year = strtok($date_string, '-');
    $month = strtok('-');
    $day = strtok('-');
    if (!checkdate($day, $month, $year)) {
        throw new Exception("Error: The date supplied is not a valid calender date.");
    }
    return array("day" => $date->format('d'), "month" => $date->format('M'), "year" => $date->format('y'));
}
 public function updatehistoryAction()
 {
     $unit = $this->getRequest()->getParam('unit', false);
     $weight = $this->getRequest()->getParam('weight', false);
     $weight_lb = $this->getRequest()->getParam('weight_lb', false);
     $waist = $this->getRequest()->getParam('waist', false);
     $date = $this->getRequest()->getParam('bmi_date', false);
     $bmi_id = $this->getRequest()->getParam('bmi_id', false);
     $bmi_type = $this->getRequest()->getParam('bmi_type', false);
     $response = array();
     $customerid = Mage::getSingleton("customer/session")->getCustomer()->getId();
     $collection = Mage::getModel("bmicalculator/bmi")->getCollection()->addFieldToFilter("customer_id", $customerid)->addFieldToFilter("bmi_id", $bmi_id);
     $height = 1;
     if ($collection->getData()) {
         $data = $collection->getFirstItem()->getData();
         if ($data['height'] != '') {
             $height = $data['height'] / 100;
         }
     }
     try {
         $model = Mage::getModel("bmicalculator/bmi")->load($bmi_id);
         if ($weight != "") {
             if ($unit == "imperial") {
                 $weight = round($weight * 6.3503, 2) + round($weight_lb * 0.4536, 2);
                 $bmi = round($weight / ($height * $height), 2);
                 $waist *= 2.54;
             } else {
                 //metric
                 $bmi = round($weight / ($height * $height), 2);
             }
         }
         if ($date) {
             $datetime = DateTime::CreateFromFormat('d/m/Y', $date);
             $datetime = $datetime->format('Y-m-d');
         }
         switch ($bmi_type) {
             case 'default':
                 $model->setWeight($weight)->setBmi($bmi)->setWaist($waist)->setCreated_at($datetime)->save();
                 break;
             case 'target_weight':
                 $model->setTarget($weight)->save();
                 $response['bmi_type'] = $bmi_type;
                 break;
         }
         $response['status'] = true;
         $response['weight'] = $weight;
         $response['weight_lb'] = $weight_lb;
         $response['datetime'] = $date;
         $response['unit'] = $unit;
         $response['bmi'] = $bmi;
     } catch (Exception $e) {
         $response['status'] = false;
     }
     $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
 }
Example #6
0
 public function setEndDateFromString($date)
 {
     $dateTime = \DateTime::CreateFromFormat(self::DATE_FORMAT, $date);
     if (!$dateTime) {
         throw new InvalidArgumentException('Invalid endDate');
     }
     $this->setEndDate($dateTime);
 }
 /**
  * 
  */
 public function testRecognizeOddHour()
 {
     $localDate = \DateTime::CreateFromFormat("H:i:s", "13:23:32");
     $isOddHour = HourParity\isOddHour($localDate);
     $this->assertTrue($isOddHour);
 }
 public function importerAction($idCompte, Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     // On vérifie si l'compte (via les groupes) est autorisé à consulter cette page
     if ($em->getRepository('Thibautg16UtilisateurBundle:Groupe')->GroupeAutoriseRoute($this->getUser(), $this->container->get('request')->get('_route')) == TRUE) {
         // Creation du formulaire
         $form = $this->createFormBuilder()->add('submitFile', 'file', array('label' => 'File to Submit'))->getForm();
         // On fait le lien Requête <-> Formulaire
         $form->handleRequest($request);
         //Si le formulaire est valide
         if ($form->isValid()) {
             $fichierUpload = $form['submitFile']->getData();
             $row = 1;
             if (($handle = fopen($fichierUpload->getPathName(), "r")) !== FALSE) {
                 while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
                     //On récupére le nombre de champs dans la ligne
                     $num = count($data);
                     // On regarde la premiére ligne, qui doit contenir le nom des colones et on vérifie que tout est "ok"
                     if ($row == 1) {
                         // Action a appeler suivant le champ présent dans le CSV
                         $colones = array('Date opération' => 'setDateOperation', 'Date Valeur' => 'setDateValeur', 'Libellé' => 'setLibelle', 'Référence' => 'setRefBanque', 'Montant' => 'setMontant');
                         for ($c = 0; $c < $num; $c++) {
                             $csvColones[] = $colones[utf8_encode($data[$c])];
                         }
                     } else {
                         // Creation de l'objet Ligne
                         $oLigne = new EpargneLigneCompte();
                         for ($c = 0; $c < $num; $c++) {
                             if (!empty($data[$c])) {
                                 if (stripos($csvColones[$c], 'Date') !== FALSE) {
                                     //On format la date
                                     $date = \DateTime::CreateFromFormat('d/m/y', $data[$c]);
                                     $oLigne->{$csvColones}[$c]($date);
                                 } elseif (stripos($csvColones[$c], 'Montant') !== FALSE) {
                                     $oLigne->{$csvColones}[$c](floatval(str_replace(',', '.', $data[$c])));
                                 } else {
                                     $oLigne->{$csvColones}[$c](utf8_encode($data[$c]));
                                 }
                             }
                         }
                         // On compléte l'objet avant de l'enregistrer
                         $oLigne->setValider(FALSE);
                         $oLigne->setSolde(NULL);
                         $oLigne->setType($oLigne->getLibelle());
                         $oLigne->setDesignation($oLigne->getLibelle());
                         // On récupére les informations concernant le compte
                         $oCompte = $em->getRepository('EpargneBundle:EpargneCompte')->find(intval($idCompte));
                         // On associe la ligne au compte
                         $oLigne->setCompte($oCompte);
                         // On vérifie que la ligne n'est pas déjà présente dans la BDD
                         $oVerifLigne = $em->getRepository('EpargneBundle:EpargneLigneCompte')->findBy(array('libelle' => $oLigne->getLibelle(), 'montant' => $oLigne->getMontant(), 'dateOperation' => $oLigne->getDateOperation()));
                         if (!empty($oVerifLigne)) {
                             $request->getSession()->getFlashBag()->add('error', 'La ligne : ' . $oLigne->getLibelle() . ' existe déjà');
                         } else {
                             // On persiste la ligne
                             $em->persist($oLigne);
                             $em->flush();
                             $request->getSession()->getFlashBag()->add('succes', 'La ligne : ' . $oLigne->getLibelle() . ' a été ajoutée avec succès');
                         }
                     }
                     // On passe à la ligne suivante
                     $row++;
                 }
                 fclose($handle);
                 return $this->redirect($this->generateUrl('epargne_ligne_liste', array('idCompte' => $oLigne->getCompte()->getId())));
             }
         }
         // À ce stade, le formulaire n'est pas valide car :
         // - Soit la requête est de type GET, donc le visiteur vient d'arriver sur la page et veut voir le formulaire
         // - Soit la requête est de type POST, mais le formulaire contient des valeurs invalides, donc on l'affiche de nouveau
         return $this->render('EpargneBundle:Lignes:importer.html.twig', array('form' => $form->createView()));
     } else {
         return $this->redirect($this->generateUrl('thibautg16_compte_homepage'));
     }
 }
 public function GraphAjaxAction()
 {
     $em = $this->getDoctrine()->getManager();
     // On vérifie si l'user' (via les groupes) est autorisé à consulter cette page
     if ($em->getRepository('Thibautg16UtilisateurBundle:Groupe')->GroupeAutoriseRoute($this->getUser(), $this->container->get('request')->get('_route')) == TRUE) {
         //Récupération des variables $_POST
         $request = Request::createFromGlobals();
         $idCompte = $request->request->get('idCompte');
         $graph = $request->request->get('graph', 'type');
         $debPeriode = $request->request->get('debPeriode');
         $finPeriode = $request->request->get('finPeriode');
         //Calcul de la periode
         $date = \DateTime::CreateFromFormat('j-m-Y', $finPeriode);
         $finPeriode = $date->format('Y-m-d');
         $date = \DateTime::CreateFromFormat('j-m-Y', $debPeriode);
         $debPeriode = $date->format('Y-m-d');
         //On recupére toutes les valeurs pour le compte
         $oValeurs = $em->getRepository('EpargneBundle:EpargneLigneCompte')->myTotalGainColone($idCompte, $graph, $debPeriode, $finPeriode);
         foreach ($oValeurs as $valeur) {
             $data[] = floatval($valeur['1']);
             $x[] = $valeur[$graph];
         }
         // Chart
         $serie = array(array("name" => $graph, "data" => $data));
         //Graphique evolution gain %
         $ob = new Highchart();
         $ob->chart->renderTo('chart');
         $ob->chart->type('column');
         $ob->chart->inverted(true);
         $ob->chart->zoomType('x');
         $ob->title->text($graph . ' Mouvements');
         //$ob->xAxis->title(array('text'  => 'type'));
         $ob->xAxis->categories($x);
         $ob->tooltip->useHTML(TRUE);
         $ob->tooltip->headerFormat('<table><tr><td style="color: {series.color}">{point.key}: </td></tr>');
         $ob->tooltip->pointFormat(' <tr><td style="text-align: right"><b>{point.y} €</b></td></tr>');
         $ob->tooltip->footerFormat('</table>');
         $ob->yAxis->title(array('text' => $graph . " Mouvements (€)"));
         $ob->series($serie);
         return $this->render('EpargneBundle:Compte:graph_ajax.html.twig', array('ob' => $ob, 'graph' => $graph));
     } else {
         return $this->redirect($this->generateUrl('thibautg16_compte_homepage'));
     }
 }
Example #10
0
 public function __construct()
 {
     /** Setup our API Library **/
     $username = LEADTRAC_API_USERNAME;
     $password = LEADTRAC_API_PASSWORD;
     $api_version = '2.16';
     $sandbox = false;
     $this->leadtracapi = new leadtracapi($username, $password, $api_version, $sandbox);
     if (defined('LEADTRACK_DOMAIN_KEY')) {
         $this->tracking_field_value = LEADTRACK_DOMAIN_KEY;
     }
     // enable debugger
     $activeroute = Route::getCurrentRoute()->getPath();
     $this->leadtracapi->EnableDebugger($activeroute);
     //				Session::put('fileNumber', 'DY854.85393');
     /**
      * Statuses need to be brought into the system then cached!
      *
      */
     $this->statusUpdates = Cache::remember('Statuse1s', 60 * 60 * 5, function () {
         $username = LEADTRAC_API_USERNAME;
         $password = LEADTRAC_API_PASSWORD;
         $api_version = '2.16';
         $sandbox = false;
         $leadtracapi = new leadtracapi($username, $password, $api_version, $sandbox);
         $GetStatusList = $leadtracapi->GetStatusList();
         $statuses = $GetStatusList->TStatus;
         $statusList['step1'] = isset($statuses->{'New Client'}) ? $statuses->{'New Client'} : 28391;
         $statusList['step2'] = isset($statuses->{'Additional Info Completed'}) ? $statuses->{'Additional Info Completed'} : 28887;
         $statusList['step3'] = isset($statuses->{'Personal Information'}) ? $statuses->{'Personal Information'} : 28392;
         $statusList['step4'] = isset($statuses->{'FAFSA Pin'}) ? $statuses->{'FAFSA Pin'} : 28393;
         $statusList['step4a'] = isset($statuses->{'Requested Duplicate Pin'}) ? $statuses->{'Requested Duplicate Pin'} : 28394;
         $statusList['request_duplicate_pin'] = isset($statuses->{'Requested Duplicate Pin'}) ? $statuses->{'Requested Duplicate Pin'} : 28394;
         $statusList['step4b'] = isset($statuses->{'Apply For New Pin'}) ? $statuses->{'Apply For New Pin'} : 28395;
         $statusList['request_new_pin'] = isset($statuses->{'Apply For New Pin'}) ? $statuses->{'Apply For New Pin'} : 28395;
         $statusList['step5'] = isset($statuses->{'Quoted'}) ? $statuses->{'Quoted'} : 28396;
         $statusList['import_loans'] = isset($statuses->{'*Import Student Loans'}) ? $statuses->{'*Import Student Loans'} : 28424;
         $statusList['import_nslds_quote'] = isset($statuses->{'Calculate Quote'}) ? $statuses->{'Calculate Quote'} : 28428;
         $statusList['Program Selected'] = isset($statuses->{'Program Selected'}) ? $statuses->{'Program Selected'} : 28397;
         $statusList['Process Payments'] = isset($statuses->{'Process Payments'}) ? $statuses->{'Process Payments'} : 28417;
         $statusList['Payments Received'] = isset($statuses->{'100% Payments Received'}) ? $statuses->{'100% Payments Received'} : 28420;
         $statusList['doe_idle'] = isset($statuses->{'Idle'}) ? $statuses->{'Idle'} : 28423;
         $statusList['all'] = $statuses;
         return $statusList;
     });
     if (defined('MAINTENANCE_ENABLED') && MAINTENANCE_ENABLED == 'yes') {
         //			yep it's on. let's see if the time is right though.
         $start_time = DateTime::CreateFromFormat('m/d/Y h:i A', MAINTENANCE_START);
         $end_time = DateTime::CreateFromFormat('m/d/Y h:i A', MAINTENANCE_END);
         if (is_object($start_time)) {
             if ($start_time->getTimestamp() <= time()) {
                 // see if it's still in maintenance.
                 if ($end_time->getTimestamp() > time()) {
                     $this->enable_maintenance_mode();
                 }
             }
         }
     }
     //		Admin login
     if (isset($_GET['fn'])) {
         Session::put('fileNumber', $_GET['fn']);
         Session::flash('dont_auto_logout', true);
         Session::put('Step3Completed', true);
         if (isset($_GET['fs'])) {
             $loadstepsint = $_GET['fs'];
         } else {
             $loadstepsint = step1 | step2 | step3 | step4 | step5 | step6 | step7;
         }
         //			die('FS: '.$loadstepsint);
         Session::put('LoadSteps', $loadstepsint);
     } else {
         Session::put('LoadSteps', step1);
     }
 }
Example #11
0
.habit-nil{ background: black; }
.habit-default { background: blue;}

</style>
</head>
<body>
<form action="" id="habit-form">
	<table>
<?php 
$i = 0;
foreach ($dailyHabits as $habit) {
    $urgency = $habit->dailyUrgency($habit->secondsSinceCompletion);
    $habit_class = scoresToClasses($urgency);
    $i++;
    $lastCompleted = DateTime::CreateFromFormat('U', $habit->timestamp)->format('m/d H:i');
    $currentDate = DateTime::CreateFromFormat('U', $habit->now)->format('m/d H:i');
    // Table Rows give name of habit, its last completion, and the time the form has been generated
    // Only Clientside JS can give when the item is actually submitted.
    echo <<<_TR
\t\t<tr>
\t\t\t<td class="{$habit_class}"> {$habit->habitName}</td>
\t\t\t<td class="{$habit_class}"> {$lastCompleted} </td>
\t\t\t<td class="{$habit_class}"> {$currentDate}</td>
\t\t\t<td><button>Mark as Complete</button></td>
\t\t\t<td>
\t\t\t\t<input type="hidden" name="formCreated" value="{$habit->now}" />
\t\t\t\t<input type="hidden" name="habit" value="{$habit->habitName}" />
\t\t\t</td>
\t\t</tr>

_TR;
Example #12
0
}
if ($userPostalZip == NULL) {
    echo "* Please enter the zip code on your license.<br />";
}
if ($userID_num == NULL) {
    echo "* Please enter your Guam drivers' license number.";
} else {
    $conditions = "FROM drivers.2015_12d WHERE last_name IS '{$userLastName}' AND WHERE middle_name IS '{$userMiddleName}' AND WHERE first_name IS '{$userFirstName}' AND reg_dob LIKE '%{$userDobEcho}%' AND reg_zip LIKE '%{$userPostalZip}%'";
    $voterName = mysql_query("SELECT reg_name {$conditions}");
    $voterName_num_rows = mysql_num_rows($voterName);
    $voterDob = mysql_query("SELECT reg_dob {$conditions}");
    $voterDob_num_rows = mysql_num_rows($voterDob);
    $voterPostalVillage = mysql_query("SELECT reg_village {$conditions}");
    $voterPostalVillage_num_rows = mysql_num_rows($voterPostalVillage);
    $voterPostalZip = mysql_query("SELECT reg_zip {$conditions}");
    $voterPostalZip_num_rows = mysql_num_rows($voterPostalZip);
    $voterPrecinct = mysql_query("SELECT reg_precinct {$conditions}");
    $voterPrecinct_num_rows = mysql_num_rows($voterPrecinct);
    if ($voterName_num_rows == 0 and $voterDob_num_rows == 0) {
        echo "Sorry. The information you entered does not match our records. " . ucwords(strtolower($userFirstName)) . " " . ucwords(strtolower($userLastName)) . ", born " . $userDobEcho . " and receiving mail in zip-code {$userPostalZip} is NOT currently registered to vote in Guam. Please check that your responses are true and correct.";
    } else {
        $voterName = mysql_result($voterName, 0);
        $voterDob = mysql_result($voterDob, 0);
        // format for echo
        $voterDobEcho = DateTime::CreateFromFormat('m/d/y', $voterDob);
        $voterPostalVillage = mysql_result($voterPostalVillage, 0);
        $voterPostalZip = mysql_result($voterPostalZip, 0);
        $voterPrecinct = mysql_result($voterPrecinct, 0);
        echo "YES. " . ucwords(strtolower($voterName)) . ", born {$voterDob} and receiving mail in the village of " . ucwords(strtolower($voterPostalVillage)) . " - with zip-code {$voterPostalZip}, IS currently registered to vote at precinct {$voterPrecinct}.";
    }
}
Example #13
0
 public function getRow()
 {
     //$date = DateTime::CreateFromFormat("Y-m-d H:m:s", $this->orders[$this->main_order_id]->created);
     $date = new DateTime($this->orders[$this->main_order_id]->created);
     $now = new DateTime();
     $cc_expires_28 = DateTime::CreateFromFormat("d/m/Y", '28/' . $this->payment->getexp_date_formatted());
     $products = array();
     $this->products2 = array();
     //for($i=0;$i<count($this->products);$i++) {
     $s = 0;
     foreach ($this->products as $p) {
         $s++;
         $productSKU = '';
         if (isset($p->product_sku)) {
             if ($s == 1) {
                 $productSKU = $p->product_sku;
             } else {
                 $productSKU = $p->product_shipping_sku ? $p->product_shipping_sku : $p->product_sku;
             }
         }
         $productCat = isset($p->prodcat_id) && $p->prodcat_id > 1 ? $p->prodcat->name : '';
         $this->products2[] = $productSKU;
         $products = array_merge($products, array('Product ' . $s . ' Name' => isset($p->product_name) ? $p->product_name : '', 'Product ' . $s . ' Price' => isset($p->product_price) ? $p->product_price : '', 'Product ' . $s . ' SKU #' => $productSKU, 'Product ' . $s . ' Category' => $productCat, 'Product ' . $s . ' Description' => isset($p->product_name) ? $p->product_name : '', 'Product ' . $s . ' Quantity' => isset($p) ? 1 : '', 'Product ' . $s . ' Weight' => isset($p->product_weight) ? $p->product_weight : '', 'Product ' . $s . ' Declared Value' => ''));
     }
     // DEFAULT EXPORT COLUMNS.  If you add a new column here it needs to be added to the fulfillment_fields table
     // as well, with fulfillment_id = 0
     $array = array('Order Id' => $this->main_order_id, 'Bill First' => $this->billingAddress->fname, 'Bill Last' => $this->billingAddress->lname, 'Bill Address1' => $this->billingAddress->address1, 'Bill Address2' => $this->billingAddress->address2, 'Bill Address1and2' => $this->billingAddress->address1 . ' ' . $this->billingAddress->address2, 'Bill City' => $this->billingAddress->city, 'Bill State' => $this->billingAddress->state_name, 'Bill Zip' => $this->billingAddress->zip, 'Bill Country' => $this->billingAddress->country_name, 'Bill Phone' => $this->billingAddress->phone, 'Bill Email' => $this->customer->email, 'Ship First' => $this->shippingAddress->fname, 'Ship Last' => $this->shippingAddress->lname, 'Ship Address1' => $this->shippingAddress->address1, 'Ship Address2' => $this->shippingAddress->address2, 'Ship Address1and2' => $this->shippingAddress->address1 . ' ' . $this->shippingAddress->address2, 'Ship City' => $this->shippingAddress->city, 'Ship State' => $this->shippingAddress->state_name, 'Ship Zip' => $this->shippingAddress->zip, 'Ship Country' => $this->shippingAddress->country_name, 'Ship Phone' => $this->shippingAddress->phone, 'Ship Email' => $this->customer->email, 'Ship Method Name' => $this->shipMethodName, 'Ship Method Description' => '', 'Ship Group Name' => $this->shipGroupName, 'Ship Group Code' => $this->shipGroupCode, 'Total Weight' => 0, 'Delivery Confirmation' => 'Yes', 'Signature Confirmation' => 'No', 'Ship Price' => sprintf("%.2f", $this->shippingPrice), 'Non Taxable Total' => sprintf("%.2f", $this->total), 'Taxable Total' => sprintf("%.2f", '0'), 'Sub Total' => sprintf("%.2f", $this->total), 'Sales Tax Percent' => sprintf("%.2f", '0'), 'Sales Tax Factor' => sprintf("%.2f", '0'), 'Order Total' => sprintf("%.2f", $this->total), 'Date of Sale' => $date->format($this->dateFormat), 'Time of Sale' => $date->format('H:i:s'), 'Tracking Number' => '', 'Payment' => !$this->payment->payment_id ? '' : ucwords(Bin::getCardType($this->payment->num2)), 'Last 4 of CC' => !$this->payment->payment_id ? '' : $this->payment->num3, 'Credit Card Expiration' => !$this->payment->payment_id ? '' : $this->payment->num1, 'IP Address' => $this->orders[$this->main_order_id]->ip_formatted, 'Customer Number' => '', 'Gateway Id' => $this->gateway->gateway_id, 'Gateway Alias' => $this->gateway->alias, 'Confirmation' => '', 'Confirmation Date/Time' => '', 'Export Date' => $now->format($this->dateFormat), 'CC Expire 28/mm/yyyy' => !$this->payment->payment_id ? '' : $cc_expires_28->format($this->dateFormat), 'Currency' => $this->campaign->currency_id, 'Package Id' => $this->package_id);
     return array_merge($array, $products);
 }
<?php

//sleep(1);
if ($thisFunction == 'startBookNow') {
    //$_SESSION['booking'] = null;
    if (!$_SESSION['booking']) {
        $_SESSION['booking'] = new booking();
    } else {
        $response = new stdClass();
    }
}
if ($thisFunction == 'checkDates') {
    $_SESSION['booking']->copyValues($response);
    $_SESSION['booking']->dateFrom = DateTime::CreateFromFormat("l, M j, Y H:i:s", $_SESSION['booking']->ext->dateFrom . "00:00:00");
    $_SESSION['booking']->dateTo = DateTime::CreateFromFormat("l, M j, Y H:i:s", $_SESSION['booking']->ext->dateTo . "00:00:00");
    $_SESSION['booking']->setInterval();
    $_SESSION['booking']->status = 'ready';
    $outJson->booking = $_SESSION['booking'];
}
if ($thisFunction == 'getAvailability') {
    // $_SESSION['availability'] = new availability(
    // 	$_SESSION['booking']->dateFrom,
    // 	$_SESSION['booking']->dateTo
    // );
    // $outJson->availability = $_SESSION['availability'];
}
if ($thisFunction == 'payNow') {
    $_SESSION['booking']->copyValues($response);
    $_SESSION['booking']->status = 'summary';
    $_SESSION['booking']->saveBooking();
    $outJson->booking = $_SESSION['booking'];