/**
  * Change Method.
  *
  * Write your reversible migrations using this method.
  *
  * More information on writing migrations is available here:
  * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
  *
  * @return void
  */
 public function change()
 {
     $table = $this->table('queued_tasks');
     try {
         $adapter = new MysqlAdapter([]);
         if ($adapter->getSqlType('text', 'longtext')) {
             $table->changeColumn('data', 'text', ['limit' => MysqlAdapter::TEXT_LONG, 'null' => true, 'default' => null]);
         }
     } catch (Exception $e) {
         Debugger::dump($e->getMessage());
     }
 }
 public function import()
 {
     if ($this->request->is('post')) {
         if ($this->request->data['submissionFile'] == '') {
             $this->set('file_status', 'No file submitted, try again.');
         } elseif ($this->request->data['submissionFile']) {
             $this->set('file_status', 'File submitted.');
             Debugger::dump($this->request->data['submissionFile']);
             Debugger::dump($this->request->data['table']);
             if ($this->request->data['table'] == 0) {
                 Debugger::dump($this->request->data['submissionFile']);
             } elseif ($this->request->data['table'] == 1) {
             } elseif ($this->request->data['table'] == 2) {
             } else {
                 $this->Flash->error('Unexpected table value');
             }
             $this->Flash->success('File successfully uploaded, Importing...');
         } else {
             $this->set('file_status', 'Please submit a file.');
         }
     } else {
         $this->set('file_status', 'Please submit a file.');
     }
 }
 /**
  * @param $http
  * @param $Notifier
  */
 private function checkMinMaxValuesAndSendToastNotifications($Notifier, $tick_names_and_values)
 {
     $stocksAffectedMax = array();
     $stocksAffectedMin = array();
     $valueOfStocksAffectedMax = array();
     $valueOfStocksAffectedMin = array();
     for ($i = 0; $i < sizeof($tick_names_and_values); $i++) {
         $stockAffectedMax = $this->Stocks->find()->where(['maximum <=' => $tick_names_and_values[$i][1], 'tick_name =' => $tick_names_and_values[$i][0]])->toArray();
         $stockAffectedMin = $this->Stocks->find()->where(['minimum >=' => $tick_names_and_values[$i][1], 'tick_name =' => $tick_names_and_values[$i][0]])->toArray();
         for ($a = 0; $a < sizeof($stockAffectedMax); $a++) {
             $stocksAffectedMax[] = $stockAffectedMax[$a];
             $valueOfStocksAffectedMax[] = $tick_names_and_values[$i][1];
         }
         for ($a = 0; $a < sizeof($stockAffectedMin); $a++) {
             $stocksAffectedMin[] = $stockAffectedMin[$a];
             $valueOfStocksAffectedMin[] = $tick_names_and_values[$i][1];
         }
     }
     Debugger::dump('stocksAffectedMax: ');
     Debugger::dump($stocksAffectedMax);
     Debugger::dump('stocksAffectedMin: ');
     Debugger::dump($stocksAffectedMin);
     for ($i = 0; $i < sizeof($stocksAffectedMax); $i++) {
         Debugger::dump('$stocksAffectedMax[' . $i . ']');
         Debugger::dump($stocksAffectedMax[$i]);
         $id = $stocksAffectedMax[$i]['device_id'];
         $device = $this->Devices->get($id, ['contain' => []]);
         $channelURI = $device['name'];
         Debugger::dump($channelURI);
         //$MyToastXML = '<toast><visual><binding template="ToastText02"><text id="1">'.$stocksAffectedMax[$i]['tick_name'].' atingiu máximo'.'</text><text id="2">VALOR</text></binding></visual></toast>';
         //$responseToSendMsg = $Notifier->Send($channelURI, TemplateToast::ToastText01($stocksAffectedMax[$i]['tick_name'] . " atingiu máximo!"));
         $responseToSendMsg = $Notifier->Send($channelURI, TemplateToast::ToastText02($stocksAffectedMax[$i]['tick_name'] . " atingiu máximo!", $valueOfStocksAffectedMax[$i], TemplateToast::NotificationMail));
         //$responseToSendMsg = $Notifier->Send($channelURI,$MyToastXML);
         Debugger::dump($responseToSendMsg);
     }
     for ($i = 0; $i < sizeof($stocksAffectedMin); $i++) {
         Debugger::dump('$stocksAffectedMin[' . $i . ']');
         Debugger::dump($stocksAffectedMin[$i]);
         $id = $stocksAffectedMin[$i]['device_id'];
         $device = $this->Devices->get($id, ['contain' => []]);
         $channelURI = $device['name'];
         Debugger::dump($channelURI);
         //$MyToastXML = '<toast><visual><binding template="ToastText02"><text id="1">'.$stocksAffectedMin[$i]['tick_name'].' atingiu mínimo'.'</text><text id="2">VALOR</text></binding></visual></toast>';
         //$responseToSendMsg = $Notifier->Send($channelURI, TemplateToast::ToastText01($stocksAffectedMin[$i]['tick_name'] . " atingiu mínimo!"));
         $responseToSendMsg = $Notifier->Send($channelURI, TemplateToast::ToastText02($stocksAffectedMin[$i]['tick_name'] . " atingiu mínimo!", $valueOfStocksAffectedMin[$i], TemplateToast::NotificationMail));
         //$responseToSendMsg = $Notifier->Send($channelURI,$MyToastXML);
         Debugger::dump($responseToSendMsg);
     }
 }
    /**
     * testDump method
     *
     * @return void
     */
    public function testDump()
    {
        $var = ['People' => [['name' => 'joeseph', 'coat' => 'technicolor', 'hair_color' => 'brown'], ['name' => 'Shaft', 'coat' => 'black', 'hair' => 'black']]];
        ob_start();
        Debugger::dump($var);
        $result = ob_get_clean();
        $open = "\n";
        $close = "\n\n";
        $expected = <<<TEXT
{$open}[
\t'People' => [
\t\t(int) 0 => [
\t\t\t'name' => 'joeseph',
\t\t\t'coat' => 'technicolor',
\t\t\t'hair_color' => 'brown'
\t\t],
\t\t(int) 1 => [
\t\t\t'name' => 'Shaft',
\t\t\t'coat' => 'black',
\t\t\t'hair' => 'black'
\t\t]
\t]
]{$close}
TEXT;
        $this->assertTextEquals($expected, $result);
        ob_start();
        Debugger::dump($var, 1);
        $result = ob_get_clean();
        $expected = <<<TEXT
{$open}[
\t'People' => [
\t\t[maximum depth reached]
\t]
]{$close}
TEXT;
        $this->assertTextEquals($expected, $result);
    }
    /**
     * This function will confirm exam registration if the payment option is PAYCODE
     * @param string $iemail
     */
    public function confirmexamregistrationpc($iemail = null)
    {
        $this->set('email', $this->Auth->user('Email_Address'));
        $this->set('date', $this->Auth->session->read('date'));
        $this->set('level', $this->Auth->session->read('level'));
        $this->set('location', $this->Auth->session->read('selectedExamLocation'));
        $this->set('studentId', $this->Auth->user('Individual_ID'));
        $this->set('fee', $this->Auth->session->read('fee'));
        //if the fee is NOT 0 then check the paymentcode punched in...
        if ($this->Auth->session->read('fee') != 0) {
            $result = $this->PaymentCodeT->verifyPaymentCode($this->Auth->session->read('paymentCode'));
            //if the result comes back as empty that means that the paymentCode is not valid.
            if (empty($result)) {
                $this->Flash->error(__("Payment Code " . $this->Auth->session->read('paymentCode') . " is invalid. Please contact CEPI at (408) 554-2187 or email us at cepi@scu.edu"));
                return $this->redirect(['action' => 'dashboard']);
            }
        }
        $outcome = "Not Yet Taken";
        //If the deferexam flag is set to true in the session
        if (strcmp($this->Auth->session->read('deferexam'), "Yes") == 0) {
            $outcome = "Deferred";
        }
        //Now that the payment code has been validated...complete the registration
        $examPCConfirmation = ['Student_ID' => $this->Auth->user('Individual_ID'), 'Exam_ID' => $this->Auth->session->read('selectedExamId'), 'Payment_Type' => 'Payment Code - Unconfirmed', 'Payment_Code_ID' => $result->Payment_Code_ID, 'Amount_Charged' => $this->Auth->session->read('fee'), 'Retest' => $this->Auth->session->read('retest'), 'Disability_Accomodations' => $this->Auth->session->read('disabled'), 'Location' => $this->Auth->session->read('selectedExamLocation'), 'Required_Non_Saturday_Admission' => $this->Auth->session->read('satadmission'), 'Release_Contact_Info_To_Others' => $this->Auth->session->read('releaseInfo'), 'Registration_Complete_Flag' => 'Yes', 'Outcome' => $outcome];
        try {
            if ($this->Auth->session->check('prefAddress')) {
                $this->IndividualT->updateShippingPreference($this->Auth->user('Individual_ID'), $this->Auth->session->read('prefAddress'));
            } else {
                throw new \Exception();
            }
            $this->RegistrationT->persistExamRegistrationPC($examPCConfirmation);
            $this->Flash->success(__("Successfully registered for Exam Level " . $this->Auth->session->read('level') . "..\n\t\t\t\t\tGood Luck!! If you have any questions about your exam registration please contact CEPI at (408) 554-2187 or email us at cepi@scu.edu"));
            return $this->redirect(['action' => 'examconfirmletter']);
        } catch (\Exception $e) {
            Debugger::dump($e->getMessage());
            $this->Flash->error($e->getMessage() . '.If you continue to have problems
								 registering for this exam using your payment code, contact the CEPI at
								cepi@scu.edu or (408) 554-2187 ');
            return $this->redirect(['action' => 'dashboard']);
        }
    }