예제 #1
0
 public function start($auth = NULL)
 {
     $args = func_get_args();
     if ($auth == Transaction::SIGNATURE) {
         if ($this->lock) {
             return FALSE;
         }
         $this->txn = TRUE;
         return (bool) $this->__call(__FUNCTION__, array());
     }
     Transaction::start();
     if (!Transaction::add($this)) {
         return FALSE;
     }
     return TRUE;
 }
예제 #2
0
}
echo "test";
//echo date_format(date_add(DateTime::createFromFormat('d/m/Y', date("d/m/Y")),date_interval_create_from_date_string("5 years")),"d/m/Y");
echo date("d/m/Y");
$a = Item::search(["item_id" => 2]);
print_r($a);
$sql = "UPDATE item_copy SET item_copy_status=1;";
DB::getInstance()->directUpdate($sql);
$data = array("id" => null, "purpose" => "sdasd", "comment" => "asdsdf", "member_id" => 16);
$salt = '5&JDDlwz%Rwh!t2Yg-Igae@QxPzFTSId';
$enc_pass = md5($salt . 'admin');
echo "paswowkjhkfjw";
DB::getInstance()->directUpdate("UPDATE member SET member_password='******' WHERE member_nic='000000000';");
$t = new Transaction();
$t->create($data);
$t->add();
print_r(DB::getInstance()->search("schedule", ["semester_no" => 2]));
print_r(Schedule::search(["semester_no" => 2]));
echo isset($_SESSION["basket"]);
?>
<html>
<script type="text/javascript">

function display(msg){

	alert(msg);
}
</script>
</html>

<!DOCTYPE HTML>
예제 #3
0
 /**
  * Generate the form and show hints if necessary.
  * If user input validation is successful a new transaction will be added.
  * In this case the form will be hidden and only a status message will be shown.
  *
  * @access      private
  */
 private function renderForm()
 {
     global $objDatabase, $_ARRAYLANG, $_CORELANG;
     //check the payment service provider configuration
     $objSettingsGeneral = new SettingsGeneral($objDatabase);
     if (!$objSettingsGeneral->getEpaymentStatus()) {
         $this->arrStatusMessages['error'][] = $_ARRAYLANG['TXT_CHECKOUT_EPAYMENT_DEACTIVATED'];
         $this->objTemplate->hideblock('form');
         $this->objTemplate->hideblock('redirect');
         return;
     }
     //initialize variables
     $arrFieldValues = array();
     $arrFieldsToHighlight = array();
     $arrCssClasses = array();
     $cssHighlightingClass = 'highlight';
     $cssLabelClass = 'label';
     $htmlRequiredField = ' *';
     $arrSelectOptions[] = array();
     //validate submitted user data
     if (isset($_REQUEST['submit'])) {
         $arrFieldValues['invoice_number'] = !empty($_REQUEST['invoice_number']) && $_REQUEST['invoice_number'] !== $_ARRAYLANG['TXT_CHECKOUT_INVOICE_NUMBER'] . $htmlRequiredField ? $_REQUEST['invoice_number'] : '';
         $arrFieldValues['invoice_currency'] = !empty($_REQUEST['invoice_currency']) ? $_REQUEST['invoice_currency'] : '';
         $arrFieldValues['invoice_amount'] = !empty($_REQUEST['invoice_amount']) && $_REQUEST['invoice_amount'] !== $_ARRAYLANG['TXT_CHECKOUT_INVOICE_AMOUNT'] . $htmlRequiredField ? $_REQUEST['invoice_amount'] : '';
         $arrFieldValues['contact_title'] = !empty($_REQUEST['contact_title']) ? $_REQUEST['contact_title'] : '';
         $arrFieldValues['contact_forename'] = !empty($_REQUEST['contact_forename']) && $_REQUEST['contact_forename'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_FORENAME'] . $htmlRequiredField ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_forename'])) : '';
         $arrFieldValues['contact_surname'] = !empty($_REQUEST['contact_surname']) && $_REQUEST['contact_surname'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_SURNAME'] . $htmlRequiredField ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_surname'])) : '';
         $arrFieldValues['contact_company'] = !empty($_REQUEST['contact_company']) && $_REQUEST['contact_company'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_COMPANY'] ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_company'])) : '';
         $arrFieldValues['contact_street'] = !empty($_REQUEST['contact_street']) && $_REQUEST['contact_street'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_STREET'] . $htmlRequiredField ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_street'])) : '';
         $arrFieldValues['contact_postcode'] = !empty($_REQUEST['contact_postcode']) && $_REQUEST['contact_postcode'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_POSTCODE'] . $htmlRequiredField ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_postcode'])) : '';
         $arrFieldValues['contact_place'] = !empty($_REQUEST['contact_place']) && $_REQUEST['contact_place'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_PLACE'] . $htmlRequiredField ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_place'])) : '';
         $arrFieldValues['contact_country'] = !empty($_REQUEST['contact_country']) ? $_REQUEST['contact_country'] : '';
         $arrFieldValues['contact_phone'] = !empty($_REQUEST['contact_phone']) && $_REQUEST['contact_phone'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_PHONE'] . $htmlRequiredField ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_phone'])) : '';
         $arrFieldValues['contact_email'] = !empty($_REQUEST['contact_email']) && $_REQUEST['contact_email'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_EMAIL'] . $htmlRequiredField ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_email'])) : '';
         //get keys of passed data
         if (!isset($this->arrCurrencies[$invoiceCurrency]) && ($key = array_search(strtoupper($invoiceCurrency), $this->arrCurrencies))) {
             $invoiceCurrency = $key;
         }
         if (strtolower($contactTitle) !== self::MISTER && strtolower($contactTitle) !== self::MISS) {
             if (ucfirst(strtolower($contactTitle)) == $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE_MISTER']) {
                 $contactTitle = self::MISTER;
             } elseif (ucfirst(strtolower($contactTitle)) == $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE_MISS']) {
                 $contactTitle = self::MISS;
             }
         } else {
             $contactTitle = strtolower($contactTitle);
         }
         if (!isset($this->arrCountries[$contactCountry]) && ($key = array_search(ucfirst(strtolower($contactCountry)), $this->arrCountries))) {
             $contactCountry = $key;
         }
         $arrUserData['text']['invoice_number']['name'] = $_ARRAYLANG['TXT_CHECKOUT_INVOICE_NUMBER'];
         $arrUserData['text']['invoice_number']['value'] = $arrFieldValues['invoice_number'];
         $arrUserData['text']['invoice_number']['length'] = 255;
         $arrUserData['text']['invoice_number']['mandatory'] = 1;
         $arrUserData['selection']['invoice_currency']['name'] = $_ARRAYLANG['TXT_CHECKOUT_INVOICE_CURRENCY'];
         $arrUserData['selection']['invoice_currency']['value'] = $arrFieldValues['invoice_currency'];
         $arrUserData['selection']['invoice_currency']['options'] = $this->arrCurrencies;
         $arrUserData['selection']['invoice_currency']['mandatory'] = 1;
         $arrUserData['numeric']['invoice_amount']['name'] = $_ARRAYLANG['TXT_CHECKOUT_INVOICE_AMOUNT'];
         $arrUserData['numeric']['invoice_amount']['value'] = $arrFieldValues['invoice_amount'];
         $arrUserData['numeric']['invoice_amount']['length'] = 15;
         $arrUserData['numeric']['invoice_amount']['mandatory'] = 1;
         $arrUserData['selection']['contact_title']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE'];
         $arrUserData['selection']['contact_title']['value'] = $arrFieldValues['contact_title'];
         $arrUserData['selection']['contact_title']['options'] = array(self::MISTER => '', self::MISS => '');
         $arrUserData['selection']['contact_title']['mandatory'] = 1;
         $arrUserData['text']['contact_forename']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_FORENAME'];
         $arrUserData['text']['contact_forename']['value'] = $arrFieldValues['contact_forename'];
         $arrUserData['text']['contact_forename']['length'] = 255;
         $arrUserData['text']['contact_forename']['mandatory'] = 1;
         $arrUserData['text']['contact_surname']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_SURNAME'];
         $arrUserData['text']['contact_surname']['value'] = $arrFieldValues['contact_surname'];
         $arrUserData['text']['contact_surname']['length'] = 255;
         $arrUserData['text']['contact_surname']['mandatory'] = 1;
         $arrUserData['text']['contact_company']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_COMPANY'];
         $arrUserData['text']['contact_company']['value'] = $arrFieldValues['contact_company'];
         $arrUserData['text']['contact_company']['length'] = 255;
         $arrUserData['text']['contact_company']['mandatory'] = 0;
         $arrUserData['text']['contact_street']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_STREET'];
         $arrUserData['text']['contact_street']['value'] = $arrFieldValues['contact_street'];
         $arrUserData['text']['contact_street']['length'] = 255;
         $arrUserData['text']['contact_street']['mandatory'] = 1;
         $arrUserData['text']['contact_postcode']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_POSTCODE'];
         $arrUserData['text']['contact_postcode']['value'] = $arrFieldValues['contact_postcode'];
         $arrUserData['text']['contact_postcode']['length'] = 255;
         $arrUserData['text']['contact_postcode']['mandatory'] = 1;
         $arrUserData['text']['contact_place']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_PLACE'];
         $arrUserData['text']['contact_place']['value'] = $arrFieldValues['contact_place'];
         $arrUserData['text']['contact_place']['length'] = 255;
         $arrUserData['text']['contact_place']['mandatory'] = 1;
         $arrUserData['selection']['contact_country']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_COUNTRY'];
         $arrUserData['selection']['contact_country']['value'] = $arrFieldValues['contact_country'];
         $arrUserData['selection']['contact_country']['options'] = $this->arrCountries;
         $arrUserData['selection']['contact_country']['mandatory'] = 1;
         $arrUserData['text']['contact_phone']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_PHONE'];
         $arrUserData['text']['contact_phone']['value'] = $arrFieldValues['contact_phone'];
         $arrUserData['text']['contact_phone']['length'] = 255;
         $arrUserData['text']['contact_phone']['mandatory'] = 1;
         $arrUserData['email']['contact_email']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_EMAIL'];
         $arrUserData['email']['contact_email']['value'] = $arrFieldValues['contact_email'];
         $arrUserData['email']['contact_email']['length'] = 255;
         $arrUserData['email']['contact_email']['mandatory'] = 1;
         $arrFieldsToHighlight = $this->validateUserData($arrUserData);
         if (empty($arrFieldsToHighlight)) {
             //validation was successful. now add a new transaction.
             $id = $this->objTransaction->add(self::WAITING, $arrUserData['text']['invoice_number']['value'], $arrUserData['selection']['invoice_currency']['value'], $arrUserData['numeric']['invoice_amount']['value'], $arrUserData['selection']['contact_title']['value'], $arrUserData['text']['contact_forename']['value'], $arrUserData['text']['contact_surname']['value'], $arrUserData['text']['contact_company']['value'], $arrUserData['text']['contact_street']['value'], $arrUserData['text']['contact_postcode']['value'], $arrUserData['text']['contact_place']['value'], $arrUserData['selection']['contact_country']['value'], $arrUserData['text']['contact_phone']['value'], $arrUserData['email']['contact_email']['value']);
             if ($id) {
                 $objSettingsYellowpay = new SettingsYellowpay($objDatabase);
                 $arrYellowpay = $objSettingsYellowpay->get();
                 $arrOrder = array('ORDERID' => $id, 'AMOUNT' => intval($arrFieldValues['invoice_amount'] * 100), 'CURRENCY' => $this->arrCurrencies[$arrFieldValues['invoice_currency']], 'PARAMPLUS' => 'section=Checkout');
                 $arrSettings['postfinance_shop_id']['value'] = $arrYellowpay['pspid'];
                 $arrSettings['postfinance_hash_signature_in']['value'] = $arrYellowpay['sha_in'];
                 $arrSettings['postfinance_authorization_type']['value'] = $arrYellowpay['operation'];
                 $arrSettings['postfinance_use_testserver']['value'] = $arrYellowpay['testserver'];
                 $landingPage = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page')->findOneByModuleCmdLang('Checkout', '', FRONTEND_LANG_ID);
                 $this->objTemplate->setVariable('CHECKOUT_YELLOWPAY_FORM', \Yellowpay::getForm($arrOrder, $_ARRAYLANG['TXT_CHECKOUT_START_PAYMENT'], false, $arrSettings, $landingPage));
                 if (\Yellowpay::$arrError) {
                     $this->arrStatusMessages['error'][] = $_ARRAYLANG['TXT_CHECKOUT_FAILED_TO_INITIALISE_YELLOWPAY'];
                 } else {
                     $this->arrStatusMessages['ok'][] = $_ARRAYLANG['TXT_CHECKOUT_ENTRY_SAVED_SUCCESSFULLY'];
                 }
                 $this->objTemplate->hideBlock('form');
                 $this->objTemplate->touchBlock('redirect');
                 return;
             } else {
                 $this->arrStatusMessages['error'][] = $_ARRAYLANG['TXT_CHECKOUT_ENTRY_SAVED_ERROR'];
             }
         }
     } else {
         //get passed data
         $arrFieldValues['invoice_number'] = !empty($_REQUEST['invoice_number']) ? $_REQUEST['invoice_number'] : '';
         $arrFieldValues['invoice_currency'] = !empty($_REQUEST['invoice_currency']) ? $_REQUEST['invoice_currency'] : '';
         $arrFieldValues['invoice_amount'] = !empty($_REQUEST['invoice_amount']) ? $_REQUEST['invoice_amount'] : '';
         $arrFieldValues['contact_title'] = !empty($_REQUEST['contact_title']) ? $_REQUEST['contact_title'] : '';
         $arrFieldValues['contact_forename'] = !empty($_REQUEST['contact_forename']) ? $_REQUEST['contact_forename'] : '';
         $arrFieldValues['contact_surname'] = !empty($_REQUEST['contact_surname']) ? $_REQUEST['contact_surname'] : '';
         $arrFieldValues['contact_company'] = !empty($_REQUEST['contact_company']) ? $_REQUEST['contact_company'] : '';
         $arrFieldValues['contact_street'] = !empty($_REQUEST['contact_street']) ? $_REQUEST['contact_street'] : '';
         $arrFieldValues['contact_postcode'] = !empty($_REQUEST['contact_postcode']) ? $_REQUEST['contact_postcode'] : '';
         $arrFieldValues['contact_place'] = !empty($_REQUEST['contact_place']) ? $_REQUEST['contact_place'] : '';
         $arrFieldValues['contact_country'] = !empty($_REQUEST['contact_country']) ? $_REQUEST['contact_country'] : '';
         $arrFieldValues['contact_phone'] = !empty($_REQUEST['contact_phone']) ? $_REQUEST['contact_phone'] : '';
         $arrFieldValues['contact_email'] = !empty($_REQUEST['contact_email']) ? $_REQUEST['contact_email'] : '';
         //get keys of passed options selection
         if (!isset($this->arrCurrencies[$arrFieldValues['invoice_currency']]) && ($key = array_search(strtoupper($arrFieldValues['invoice_currency']), $this->arrCurrencies))) {
             $arrFieldValues['invoice_currency'] = $key;
         }
         if (strtolower($arrFieldValues['contact_title']) !== self::MISTER && strtolower($arrFieldValues['contact_title']) !== self::MISS) {
             if (ucfirst(strtolower($arrFieldValues['contact_title'])) == $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE_MISTER']) {
                 $arrFieldValues['contact_title'] = self::MISTER;
             } elseif (ucfirst(strtolower($arrFieldValues['contact_title'])) == $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE_MISS']) {
                 $arrFieldValues['contact_title'] = self::MISS;
             }
         } else {
             $arrFieldValues['contact_title'] = strtolower($arrFieldValues['contact_title']);
         }
         if (!isset($this->arrCountries[$arrFieldValues['contact_country']]) && ($key = array_search(ucfirst(strtolower($arrFieldValues['contact_country'])), $this->arrCountries))) {
             $arrFieldValues['contact_country'] = $key;
         }
     }
     //get currency options
     $arrSelectOptions['currencies'][] = '<option value="0">' . $_ARRAYLANG['TXT_CHECKOUT_INVOICE_CURRENCY'] . $htmlRequiredField . '</option>';
     foreach ($this->arrCurrencies as $id => $currency) {
         $selected = $id == $arrFieldValues['invoice_currency'] ? ' selected="selected"' : '';
         $arrSelectOptions['currencies'][] = '<option value="' . $id . '"' . $selected . '>' . contrexx_raw2xhtml($currency) . '</option>';
     }
     //get title options
     $selectedMister = self::MISTER == $arrFieldValues['contact_title'] ? ' selected="selected"' : '';
     $selectedMiss = self::MISS == $arrFieldValues['contact_title'] ? ' selected="selected"' : '';
     $arrSelectOptions['titles'][] = '<option value="0">' . $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE'] . $htmlRequiredField . '</option>';
     $arrSelectOptions['titles'][] = '<option value="' . self::MISTER . '"' . $selectedMister . '>' . $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE_MISTER'] . '</option>';
     $arrSelectOptions['titles'][] = '<option value="' . self::MISS . '"' . $selectedMiss . '>' . $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE_MISS'] . '</option>';
     //get country options
     if (!empty($this->arrCountries)) {
         //$arrSelectOptions['countries'][] = '<option value="0">'.$_ARRAYLANG['TXT_CHECKOUT_CONTACT_COUNTRY'].$htmlRequiredField.'</option>';
         foreach ($this->arrCountries as $id => $name) {
             if (\Cx\Core\Country\Controller\Country::getAlpha2ById($id) != 'CH') {
                 continue;
             }
             $selected = $id == $arrFieldValues['contact_country'] ? ' selected="selected"' : '';
             $arrSelectOptions['countries'][] = '<option value="' . $id . '"' . $selected . '>' . contrexx_raw2xhtml($name) . '</option>';
         }
     }
     // check wihch css classes have to be set
     foreach ($arrFieldValues as $name => $value) {
         if (isset($arrFieldsToHighlight[$name])) {
             $arrCssClasses[$name][] = $cssHighlightingClass;
         }
         if (empty($value)) {
             $arrCssClasses[$name][] = $cssLabelClass;
         }
         $arrCssClasses[$name] = implode(' ', $arrCssClasses[$name]);
     }
     \JS::activate('jquery');
     \JS::registerCode($this->getJavascript($htmlRequiredField));
     $this->objTemplate->setVariable(array('TXT_CHECKOUT_DESCRIPTION' => $_ARRAYLANG['TXT_CHECKOUT_DESCRIPTION'], 'TXT_CHECKOUT_BILL_DATA' => $_ARRAYLANG['TXT_CHECKOUT_BILL_DATA'], 'TXT_CHECKOUT_CONTACT_DATA' => $_ARRAYLANG['TXT_CHECKOUT_CONTACT_DATA'], 'CHECKOUT_INVOICE_NUMBER' => !empty($arrFieldValues['invoice_number']) ? $arrFieldValues['invoice_number'] : $_ARRAYLANG['TXT_CHECKOUT_INVOICE_NUMBER'] . $htmlRequiredField, 'CHECKOUT_INVOICE_CURRENCY_OPTIONS' => !empty($arrSelectOptions['currencies']) ? implode($arrSelectOptions['currencies']) : '', 'CHECKOUT_INVOICE_AMOUNT' => !empty($arrFieldValues['invoice_amount']) ? $arrFieldValues['invoice_amount'] : $_ARRAYLANG['TXT_CHECKOUT_INVOICE_AMOUNT'] . $htmlRequiredField, 'CHECKOUT_CONTACT_TITLE_OPTIONS' => !empty($arrSelectOptions['titles']) ? implode($arrSelectOptions['titles']) : '', 'CHECKOUT_CONTACT_FORENAME' => !empty($arrFieldValues['contact_forename']) ? $arrFieldValues['contact_forename'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_FORENAME'] . $htmlRequiredField, 'CHECKOUT_CONTACT_SURNAME' => !empty($arrFieldValues['contact_surname']) ? $arrFieldValues['contact_surname'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_SURNAME'] . $htmlRequiredField, 'CHECKOUT_CONTACT_COMPANY' => !empty($arrFieldValues['contact_company']) ? $arrFieldValues['contact_company'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_COMPANY'], 'CHECKOUT_CONTACT_STREET' => !empty($arrFieldValues['contact_street']) ? $arrFieldValues['contact_street'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_STREET'] . $htmlRequiredField, 'CHECKOUT_CONTACT_POSTCODE' => !empty($arrFieldValues['contact_postcode']) ? $arrFieldValues['contact_postcode'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_POSTCODE'] . $htmlRequiredField, 'CHECKOUT_CONTACT_PLACE' => !empty($arrFieldValues['contact_place']) ? $arrFieldValues['contact_place'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_PLACE'] . $htmlRequiredField, 'CHECKOUT_CONTACT_COUNTRY_OPTIONS' => !empty($arrSelectOptions['countries']) ? implode($arrSelectOptions['countries']) : '', 'CHECKOUT_CONTACT_PHONE' => !empty($arrFieldValues['contact_phone']) ? $arrFieldValues['contact_phone'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_PHONE'] . $htmlRequiredField, 'CHECKOUT_CONTACT_EMAIL' => !empty($arrFieldValues['contact_email']) ? $arrFieldValues['contact_email'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_EMAIL'] . $htmlRequiredField, 'CHECKOUT_INVOICE_NUMBER_CLASS' => $arrCssClasses['invoice_number'], 'CHECKOUT_INVOICE_CURRENCY_CLASS' => $arrCssClasses['invoice_currency'], 'CHECKOUT_INVOICE_AMOUNT_CLASS' => $arrCssClasses['invoice_amount'], 'CHECKOUT_CONTACT_TITLE_CLASS' => $arrCssClasses['contact_title'], 'CHECKOUT_CONTACT_FORENAME_CLASS' => $arrCssClasses['contact_forename'], 'CHECKOUT_CONTACT_SURNAME_CLASS' => $arrCssClasses['contact_surname'], 'CHECKOUT_CONTACT_COMPANY_CLASS' => $arrCssClasses['contact_company'], 'CHECKOUT_CONTACT_STREET_CLASS' => $arrCssClasses['contact_street'], 'CHECKOUT_CONTACT_POSTCODE_CLASS' => $arrCssClasses['contact_postcode'], 'CHECKOUT_CONTACT_PLACE_CLASS' => $arrCssClasses['contact_place'], 'CHECKOUT_CONTACT_COUNTRY_CLASS' => $arrCssClasses['contact_country'], 'CHECKOUT_CONTACT_PHONE_CLASS' => $arrCssClasses['contact_phone'], 'CHECKOUT_CONTACT_EMAIL_CLASS' => $arrCssClasses['contact_email'], 'TXT_CORE_SUBMIT' => $_CORELANG['TXT_CORE_SUBMIT'], 'TXT_CORE_RESET' => $_CORELANG['TXT_CORE_RESET']));
     $this->objTemplate->hideBlock('redirect');
     $this->objTemplate->parse('form');
 }
require_once 'core/init.php';
$member_role = $_SESSION['roles'];
if (in_array("Laboratory Assistant", $member_role)) {
} else {
    header('location:restricted_page.php');
}
if (isset($_SESSION["basket"]) && isset($_SESSION["items"])) {
    $state = true;
    DB::getInstance()->startTr();
    $newTransaction = new Transaction();
    $rdate = $_POST["expected_return_date"];
    $member = $_SESSION["member_details"]["id"];
    $data = array("id" => null, "purpose" => $_POST["purpose"], "borrow_comment" => $_POST["comments"], "return_comment" => null, "member_id" => $_SESSION["member_details"]["id"], "borrowed_date" => date("Y-m-d"), "expected_return_date" => $_POST["expected_return_date"]);
    $newTransaction->create($data);
    if ($newTransaction->add()) {
        $transaction_id = DB::getInstance()->getLastId();
        foreach ($_SESSION["basket"] as $key => $value) {
            $newItemTransaction = new ItemTransaction();
            $data = array("item_copy_id" => $value["item_copy_id"], "transaction_id" => $transaction_id, "borrowed_quantity" => $value["quantity"], "returned_date" => null, "returned_quantity" => null, "status" => 0);
            $newItemTransaction->create($data);
            if ($newItemTransaction->add()) {
                $sql = "UPDATE item_copy SET item_copy_status=0 WHERE item_copy_id='" . $value["item_copy_id"] . "';";
                if (!DB::getInstance()->directUpdate($sql)) {
                    $state = false;
                    break;
                }
            } else {
                $state = false;
                break;
            }