public function process() { // check if session is active $session = new Session($this->sessionId); if ($session->sessionId > 0) { // update session $session->update(); // process restricted functions switch ($this->f) { case 'checkLogin': return Login::checkLogin($session->sessionId); case 'getSession': return $session; case 'getWarehouse': if (isset($this->data->update)) { $warehouse = new Warehouse($session->warehouseId, $this->data->update); } else { $warehouse = new Warehouse($session->warehouseId); } $warehouse->dMail = $warehouse->getMail(); $warehouse->dDisableLocationLess = $warehouse->isLocationLessDisabled(); $warehouse->dDisablePaletteLess = $warehouse->isPaletteLessDisabled(); return $warehouse; case 'editWarehouse': if (!$session->restricted) { $data = $this->data; $warehouse = new Warehouse($session->warehouseId); // update warehouse data if (isset($data->name)) { $warehouse->name = $data->name; } if (isset($data->description)) { $warehouse->description = $data->description; } if (isset($data->country)) { $warehouse->country = $data->country; } if (isset($data->city)) { $warehouse->city = $data->city; } if (isset($data->password)) { $warehouse->setPassword($data->password); } if (isset($data->passwordRestricted)) { $warehouse->setPasswordRestricted($data->passwordRestricted); } if (isset($data->mail)) { $warehouse->setMail($data->mail); } if (isset($data->disableLocationLess)) { $warehouse->setDisableLocationLess($data->disableLocationLess); } if (isset($data->disablePaletteLess)) { $warehouse->setDisablePaletteLess($data->disablePaletteLess); } // update database entry return $warehouse->edit(); } break; case 'deleteWarehouse': if (!$session->restricted) { $warehouse = new Warehouse($session->warehouseId); if ($warehouse->id > 0 && $warehouse->delete()) { return $session->destroy(); } } break; case 'addCategory': if (!$session->restricted && isset($this->data->name)) { $category = new Category(null, $session->warehouseId); $category->name = $this->data->name; if (isset($this->data->parent)) { $category->parent = $this->data->parent; } if ($category->edit()) { return $category->id; } } break; case 'getCategory': if (isset($this->data->id) && isset($this->data->update)) { return new Category($this->data->id, $session->warehouseId, $this->data->update); } elseif (isset($this->data->id)) { return new Category($this->data->id, $session->warehouseId); } break; case 'deleteCategory': if (!$session->restricted && isset($this->data->id)) { $category = new Category($this->data->id, $session->warehouseId); return $category->delete(); } break; case 'editCategory': if (isset($this->data->id)) { $data = $this->data; $category = new Category($this->data->id, $session->warehouseId); if (!$session->restricted) { if (isset($data->name)) { $category->name = $data->name; } if (isset($data->parent)) { $category->parent = $data->parent; } if (isset($data->male)) { $category->male = $data->male; } if (isset($data->female)) { $category->female = $data->female; } if (isset($data->children)) { $category->children = $data->children; } if (isset($data->baby)) { $category->baby = $data->baby; } if (isset($data->summer)) { $category->summer = $data->summer; } if (isset($data->winter)) { $category->winter = $data->winter; } } if (isset($data->demand)) { $category->demand = $data->demand; } if (isset($data->weight)) { $category->weight = $data->weight; } return $category->edit(); } break; case 'getCategories': if (isset($this->data->parent)) { return Category::getCategories($session->warehouseId, $this->data->parent); } else { return Category::getCategories($session->warehouseId); } case 'addLocation': if (!$session->restricted && isset($this->data->name)) { $location = new Location(null, $session->warehouseId); $location->name = $this->data->name; if ($location->edit()) { return $location->id; } return true; } break; case 'getLocation': if (isset($this->data->id) && isset($this->data->update)) { return new Location($this->data->id, $session->warehouseId, $this->data->update); } elseif (isset($this->data->id)) { return new Location($this->data->id, $session->warehouseId); } break; case 'deleteLocation': if (!$session->restricted && isset($this->data->id)) { $location = new Location($this->data->id, $session->warehouseId); return $location->delete(); } break; case 'editLocation': if (!$session->restricted && isset($this->data->id) && isset($this->data->name)) { $location = new Location($this->data->id, $session->warehouseId); $location->name = $this->data->name; return $location->edit(); } break; case 'getLocations': return Location::getLocations($session->warehouseId); case 'addPalette': $palette = new Palette(null, $session->warehouseId); if (isset($this->data->locationId)) { $palette->locationId = $this->data->locationId; } if ($palette->edit()) { return $palette->id; } break; case 'getPalette': if (isset($this->data->id) && isset($this->data->update)) { return new Palette($this->data->id, $session->warehouseId, $this->data->update); } elseif (isset($this->data->id)) { return new Palette($this->data->id, $session->warehouseId); } break; case 'deletePalette': if (isset($this->data->id)) { $palette = new Palette($this->data->id, $session->warehouseId); return $palette->delete(); } break; case 'editPalette': if (isset($this->data->id)) { $palette = new Palette($this->data->id, $session->warehouseId); if (isset($this->data->locationId)) { $palette->locationId = $this->data->locationId; } return $palette->edit(); } break; case 'getPalettes': return Palette::getPalettes($session->warehouseId); case 'getCarton': if (isset($this->data->id) && isset($this->data->update)) { return new Carton($this->data->id, $session->warehouseId, null, null, $this->data->update); } elseif (isset($this->data->id)) { return new Carton($this->data->id, $session->warehouseId); } break; case 'addCarton': $locationId = null; $paletteId = null; if (isset($this->data->location)) { $locationId = $this->data->location; } if (isset($this->data->palette)) { $paletteId = $this->data->palette; } $carton = new Carton(null, $session->warehouseId, $locationId, $paletteId); return $carton->id; case 'deleteCarton': if (isset($this->data->id)) { $carton = new Carton($this->data->id, $session->warehouseId); return $carton->delete(); } break; case 'editCarton': if (isset($this->data->id)) { $carton = new Carton($this->data->id, $session->warehouseId); if (isset($this->data->location)) { $carton->locationId = $this->data->location; } else { $carton->locationId = null; } if (isset($this->data->palette)) { $carton->paletteId = $this->data->palette; } else { $carton->paletteId = null; } return $carton->edit(); } break; case 'addArticle': if (isset($this->data->carton) && isset($this->data->category) && isset($this->data->amount)) { return Stock::addArticle($this->data->carton, $this->data->category, isset($this->data->male) ? $this->data->male : false, isset($this->data->female) ? $this->data->female : false, isset($this->data->children) ? $this->data->children : false, isset($this->data->baby) ? $this->data->baby : false, isset($this->data->winter) ? $this->data->winter : false, isset($this->data->summer) ? $this->data->summer : false, $this->data->amount >= 0 ? $this->data->amount : 0, $this->data->amount < 0 ? $this->data->amount : 0); } break; case 'getStock': return Stock::getStock($session->warehouseId, isset($this->data->carton) ? $this->data->carton : null, isset($this->data->category) ? $this->data->category : null, isset($this->data->palette) ? $this->data->palette : null, isset($this->data->location) ? $this->data->location : null, isset($this->data->male) ? $this->data->male : false, isset($this->data->female) ? $this->data->female : false, isset($this->data->children) ? $this->data->children : false, isset($this->data->baby) ? $this->data->male : false, isset($this->data->summer) ? $this->data->male : false, isset($this->data->winter) ? $this->data->male : false, isset($this->data->details) ? $this->data->details : false); case 'getBarcodeUri': if (isset($this->data->text)) { // create barcode object $bc = new Barcode39($this->data->text); if (isset($this->data->textSize)) { $bc->barcode_text_size = $this->data->textSize; } if (isset($this->data->barThin)) { $bc->barcode_bar_thin = $this->data->barThin; } if (isset($this->data->barThick)) { $bc->barcode_bar_thick = $this->data->barThick; } // generate barcode image $img = "barcode_" . mt_rand(0, 100) . ".png"; $bc->draw($img); // get data uri $uri = Barcode39::getDataURI($img); unlink($img); return $uri; } break; } } else { // process unrestricted function switch ($this->f) { case 'getActiveSessions': return Session::getActiveSessionsNumber(); case 'getWarehouses': return Warehouse::getWarehouses(); case 'addWarehouse': $data = $this->data; if (isset($data->name) && isset($data->description) && isset($data->country) && isset($data->city) && isset($data->password) && isset($data->mail)) { $warehouse = new Warehouse(); Log::debug('new warehouse' . $warehouse->id); $warehouse->name = $data->name; $warehouse->description = $data->description; $warehouse->country = $data->country; $warehouse->city = $data->city; $warehouse->setPassword($data->password); $warehouse->setMail($data->mail); return $warehouse->edit(); } break; case 'getCountries': return getCountries(); break; case 'getCountryCode': $data = $this->data; if (isset($data->name)) { return getCountryCode(null, $data->name); } return false; } } return false; }
function getFullPhone($phone) { if (isEmptyString($phone)) { return ''; } return str_pad(ltrim($phone, '0'), 12, getCountryCode(), STR_PAD_LEFT); }
</td> </tr> <tr> <td><?php echo $lang['text_country']; ?> </td> <td> <select name="country" id="country" onchange="updatecountry(this)" autofocus="autofocus" autocorrect="off" autocomplete="off" > <option value="" selected="selected"><?php echo $lang['text_select'] . " " . $lang['text_country']; ?> </option> <?php $status = getCountryCode(); foreach ($status as $value) { if ($country == $value['country_id']) { echo '<option value="' . $value['country_id'] . '" data-alternative-spellings="' . $value['iso_code_2'] . '" selected="selected">' . $value['name'] . '</option>'; } else { echo '<option value="' . $value['country_id'] . '" data-alternative-spellings="' . $value['iso_code_2'] . '">' . $value['name'] . '</option>'; } } ?> </select> <?php if (isset($error_country)) { ?> <span class="error"><?php echo $error_country; ?>
//if(isset($_POST['id'])) $user_id = $_POST['id']; if (isset($_POST['person_id'])) { $user_id = $_POST['person_id']; } if (isset($_POST['street'])) { $street = $_POST['street']; } if (isset($_POST['zip'])) { $zip = $_POST['zip']; } if (isset($_POST['city'])) { $city = $_POST['city']; } if (isset($_POST['country'])) { $country_name = $_POST['country']; $country = getCountryCode($country_name); } // Default Virtuemart users parameters $timestamp = time(); $hash_secret = "VirtueMartIsCool"; $user_info_id = md5(uniqid($hash_secret)); $address_type = 'ST'; $address_type_name = '-default-'; $cdate = $timestamp; // creation date $mdate = $timestamp; // modification date if ($user_id != "" && $street != "" && $zip != "" && $city != "" && $country != "") { //XXX How to idenify the default address //$default_address_set = isDefaultAddressSet($user_id); if (!isDefaultAddressSet($user_id)) {
<?php header('Content-Type: text/html'); ?> <?php require 'iic.php'; $answer = isItChristmas(); $countryCode = getCountryCode(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Is it Christmas?</title> <link rel="alternate" title="Is It Christmas?" href="rss.xml" type="application/rss+xml" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="iic.js"></script> </head> <body style="text-align: center; padding-top: 200px;"> <a href="http://github.com/isit/christmas" style="font-weight: bold; font-size: 120pt; font-family: Arial, sans-serif; text-decoration: none; color: black;" title="CODE" id="answer"> <noscript><?php
public function setTableDefinition() { #add the table definitions from the parent table parent::setTableDefinition(); $this->setTableName('useraccount'); $this->hasColumn('type', 'integer', null); $this->hasColumn('companyid', 'integer', null); $this->hasColumn('empstatus', 'integer', null); $this->hasColumn('firstname', 'string', 255, array('notblank' => true)); $this->hasColumn('lastname', 'string', 255, array('notblank' => true)); $this->hasColumn('othername', 'string', 255); $this->hasColumn('displayname', 'string', 255); $this->hasColumn('country', 'string', 2, array('default' => getCountryCode())); $this->hasColumn('town', 'string', 255); $this->hasColumn('address1', 'string', 255); $this->hasColumn('address2', 'string', 255); $this->hasColumn('postalcode', 'string', 255); $this->hasColumn('email', 'string', 50); // only required during activation $this->hasColumn('email2', 'string', 50); $this->hasColumn('phone', 'string', 15); $this->hasColumn('phone2', 'string', 15); $this->hasColumn('ext', 'string', 15); $this->hasColumn('phone_isactivated', 'integer', null, array('default' => '0')); $this->hasColumn('phone_actkey', 'string', 15); $this->hasColumn('username', 'string', 15); // only required during activation $this->hasColumn('password', 'string', 255); // only required during activation $this->hasColumn('trx', 'string', 255); $this->hasColumn('status', 'integer', null, array('default' => '0')); # 0=Pending, 1=Active, 2=Deactivated $this->hasColumn('activationkey', 'string', 15); $this->hasColumn('activationdate', 'date'); $this->hasColumn('agreedtoterms', 'integer', null, array('default' => '0')); # 0=NO, 1=YES $this->hasColumn('securityquestion', 'integer', null); $this->hasColumn('securityanswer', 'integer', null); $this->hasColumn('isinvited', 'integer', null, array('default' => NULL)); $this->hasColumn('invitedbyid', 'integer', null); $this->hasColumn('hasacceptedinvite', 'integer', null, array('default' => 0)); $this->hasColumn('dateinvited', 'date'); $this->hasColumn('bio', 'string', 65535); $this->hasColumn('gender', 'integer', null, array('default' => 1)); # 1=Male, 2=Female, 3=Unknown $this->hasColumn('dateofbirth', 'date'); $this->hasColumn('profilephoto', 'string', 50); $this->hasColumn('contactname', 'string', 255); $this->hasColumn('contactphone', 'string', 15); $this->hasColumn('contactrshp', 'string', 15); $this->hasColumn('contactemail', 'string', 255); $this->hasColumn('contactaddress', 'string', 255); $this->hasColumn('notes', 'string', 1000); $this->hasColumn('startdate', 'date', null, array('default' => NULL)); $this->hasColumn('enddate', 'date', null, array('default' => NULL)); $this->hasColumn('probationend', 'date', null, array('default' => NULL)); $this->hasColumn('idno', 'string', 50); $this->hasColumn('nationalid', 'string', 50); $this->hasColumn('nssfid', 'string', 15); $this->hasColumn('uratin', 'string', 15); $this->hasColumn('contributiontype', 'string', 25); $this->hasColumn('linkedin', 'string', 255); $this->hasColumn('skype', 'string', 255); $this->hasColumn('maritalstatus', 'string', 255); $this->hasColumn('salutation', 'string', 15); $this->hasColumn('position', 'string', 50); $this->hasColumn('qualifications', 'string', 1000); $this->hasColumn('education', 'string', 1000); $this->hasColumn('skills', 'string', 1000); $this->hasColumn('experience', 'string', 1000); $this->hasColumn('jobdescription', 'string', 1000); $this->hasColumn('empstatus', 'string', 15); $this->hasColumn('departmentid', 'integer', null, array('default' => NULL)); $this->hasColumn('managerid', 'integer', null, array('default' => NULL)); $this->hasColumn('workingdays', 'string', 50); $this->hasColumn('maxhoursperday', 'string', 50); $this->hasColumn('maxhoursperweek', 'string', 50); $this->hasColumn('shift', 'string', 50); $this->hasColumn('rate', 'string', 10); $this->hasColumn('ratetype', 'string', 15, array('default' => 4)); $this->hasColumn('ratecurrency', 'string', 15); $this->hasColumn('bankname', 'string', 255); $this->hasColumn('accname', 'string', 255); $this->hasColumn('accno', 'string', 255); $this->hasColumn('swiftcode', 'string', 255); $this->hasColumn('branchname', 'string', 255); $this->hasColumn('istimesheetuser', 'integer', null, array('default' => 0)); $this->hasColumn('payrolltype', 'integer', null, array('default' => 4)); $this->hasColumn('employmentstatus', 'string', 15, array('default' => 1)); $this->hasColumn('selfregistered', 'integer', null, array('default' => 0)); $this->hasColumn('emailon_tsheet_approvalcompleted', 'integer', null, array('default' => 1)); $this->hasColumn('emailon_tsheeton_approvalrequired', 'integer', null, array('default' => 0)); $this->hasColumn('emailon_benefit_approvalcompleted', 'integer', null, array('default' => 1)); $this->hasColumn('emailon_benefit_approvalrequired', 'integer', null, array('default' => 0)); $this->hasColumn('emailon_leave_approvalcompleted', 'integer', null, array('default' => 1)); $this->hasColumn('emailon_leave_approvalrequired', 'integer', null, array('default' => 0)); $this->hasColumn('emailon_payslip_completed', 'integer', null, array('default' => 1)); $this->hasColumn('emailon_directmessage_recieved', 'integer', null, array('default' => 1)); # override the not null and not blank properties for the createdby column in the BaseEntity $this->hasColumn('createdby', 'integer', 11); }
/** @param $s 3-letter country code (SWE, NOR) */ function getCountryName($s) { if (is_numeric($s)) { $s = getCountryCode($s); } else { $s = strtoupper($s); if (strlen($s) == 2) { $s = country_2_to_3_letters($s); } } $c3 = array('SWE' => 'Sweden', 'NOR' => 'Norway', 'DNK' => 'Denmark', 'FIN' => 'Finland', 'USA' => 'United States of America', 'GBR' => 'United Kingdom', 'DEU' => 'Germany', 'JPN' => 'Japan', 'EUR' => 'European Union'); if (!isset($c3[$s])) { throw new \Exception('Unknown country name ' . $s); } return $c3[$s]; }
function process() { global $lr_session; global $CONFIG; $this->title = $this->event->name; $this->template_name = 'pages/event/view.tpl'; $this->smarty->assign('event', $this->event); // Make sure the user is allowed to register for anything! if (!$lr_session->user->is_active()) { $this->smarty->assign('message', 'You may not register for an event until your account is activated'); return; } if (!$lr_session->user->is_player()) { $this->smarty->assign('message', 'Your account is marked as a non-player account. Only players are allowed to register.'); return; } list($event_register_cap, $event_register_count) = $this->event->get_applicable_cap($lr_session->user); // 0 means that nobody of this gender is allowed if ($event_register_cap == 0) { $this->smarty->assign('message', 'This event is for the opposite gender only.'); return; } if ($event_register_count >= $event_register_cap && $event_register_cap > 0) { $this->smarty->assign('message', 'The gender cap for this event has been reached.'); return; } $r = $this->event->get_registration_for($lr_session->user->user_id); if ($r) { $this->smarty->assign('registration', $r); if (!$r->payments_on_file()) { // If anything is paid (including deposit) don't allow player to unregister $this->smarty->assign('allow_unregister', true); } // An unpaid registration might have been pre-empted by someone // who paid. if ($r->payment == 'Unpaid' && $event_register_cap > 0 && $event_register_count >= $event_register_cap) { $this->smarty->assign('message', 'Your payment was not received in time, so your registration has been moved to a waiting list. If you have any questions about this, please contact the head office.'); return; } // If there's an unpaid registration, we may want to allow the // option to pay it. However, the option may be displayed after // other text, so we'll build it here and save it for later. if ($r->payment != 'Paid') { $this->smarty->assign('message', 'You have already registered for this event, but not yet paid. See below for payment information.'); // include paypal as payment option if configured if (variable_get('paypal', '')) { $paypal = new PaypalHandler(); $this->smarty->assign('paypal', 'pages/event/register/paypal_payment.tpl'); $this->smarty->assign('shopping_url', $paypal->shopping_url); $this->smarty->assign('return_url', $paypal->return_url . $r->order_id); $this->smarty->assign('paypal_url', $paypal->submit_url); $this->smarty->assign('paypal_email', $paypal->account_email); // Paypal wants country codes, not names, so rewrite country value in user $lr_session->user->addr_country = getCountryCode($lr_session->user->addr_country); // include user details for auto fill forms $this->smarty->assign('user', $lr_session->user); } $this->smarty->assign('offline_payment_text', strtr(variable_get('offline_payment_text', ''), array('%order_num' => $r->formatted_order_id()))); $this->smarty->assign('refund_policy_text', variable_get('refund_policy_text', '')); } if ($this->event->multiple) { // If we allow multiple registrations, show that. $this->smarty->assign('message', 'You have already registered for this event. However, this event allows multiple registrations (e.g. the same person can register teams to play on different nights).'); } else { if ($r->payment == 'Paid') { // Multiples are not allowed. If the // registration is actually paid for (not // pending payment), just exit now, with no // extra description required. $this->smarty->assign('message', 'You have already registered and paid for this event.'); return; } else { // Only way to get here is if multiple registrations are not // allowed, and a registration exists with a pending payment. Let // the user make the payment, and nothing else. return; } } } /* The time checks come _after_ the check for an existing * registration so that payment can be dealt with after reg * close. */ $time_now = time(); // Admins can test registration before it opens... if (!$lr_session->is_admin() && $this->event->open_timestamp > $time_now) { $this->smarty->assign('message', 'This event is not yet open for registration.'); return; } if ($this->event->close_timestamp <= $time_now) { // There may be a payment-pending registration already done, // so we allow for payment to be made. $this->smarty->assign('message', 'Registration for this event has closed.'); return; } // -1 means there is no cap, so don't even check the database if ($event_register_cap > 0) { // Check if this event is already full if ($event_register_count >= $event_register_cap) { $admin_name = variable_get('app_admin_name', 'Leaguerunner Admin'); $admin_addr = variable_get('app_admin_email', 'webmaster@localhost'); $this->smarty->assign('message', "This event is already full. You may email the <a href=\"mailto:{$admin_addr}\">{$admin_name}</a> or phone the head office to be put on a waiting list in case others drop out."); // There may be a payment-pending registration already done, // if multiples are allowed, so we allow for payment to be made. return; } } $this->smarty->assign('allow_register', true); // There may be a payment-pending registration already done, // if multiples are allowed, so we allow for payment to be made. return; }
/** * Activates the reservation when the order or a part of it is send. * Saves the invoice on the webserver. * * @param Object $k Configured Klarna object. * @param String $ordernumber The ordernumber from the order the items are send from. * @param String $action The transaction id from the changed order. * @param Array $articles Array of articles that are send. * * @throws KlarnaException * * @return Array $myerror Configured Klarna object with error message. */ function piKlarnaActivateReservation($k, $ordernumber, $action, $articles) { $piKlarnaConfig = array(); $sql = "SELECT id FROM s_order WHERE ordernumber = ?"; $orderId = Shopware()->Db()->fetchOne($sql, array($ordernumber)); $sql = "SELECT * FROM s_order_billingaddress WHERE orderID = ?"; $myuser = Shopware()->Db()->fetchRow($sql, array((int)$orderId)); $sql = "SELECT countryiso FROM s_core_countries WHERE id = ?"; $piKlarnaCountryIso = Shopware()->Db()->fetchOne($sql, array((int)$myuser["countryID"])); $piKlarnaConfig = Shopware()->Plugins()->Frontend()->PigmbhKlarnaPayment()->Config(); $sql = "SELECT * FROM Pi_klarna_payment_user_data WHERE ordernumber = ?"; $myKlarnaUser = Shopware()->Db()->fetchRow($sql, array($ordernumber)); if ($piKlarnaCountryIso == 'DE' || $piKlarnaCountryIso == 'NL') { $piKlarnaStreet = $myuser["street"]; } else { $piKlarnaStreet = $myuser["street"] . ' ' . $myuser["streetnumber"]; } $myerror = array(); $myerror['error'] = false; $myerror['errormessage'] = " "; $addr = new KlarnaAddr( $myKlarnaUser["mail"], '', $myKlarnaUser["cellphone"], utf8_decode($myKlarnaUser["firstname"]), utf8_decode($myKlarnaUser["lastname"]), '', utf8_decode($piKlarnaStreet), $myKlarnaUser["zip"], utf8_decode($myKlarnaUser["city"]), getCountryCode($piKlarnaCountryIso), $myKlarnaUser["housenr"], utf8_decode($myuser["text4"]) ); if($piKlarnaCountryIso=='DE' || $piKlarnaCountryIso=='NL'){ $addr->setHouseNumber($myuser["streetnumber"]); if($piKlarnaCountryIso=='NL' && $myuser["text4"]){ $addr->setHouseExt(utf8_decode($myuser["text4"])); } } elseif($myuser["company"]){ $addr->setCompanyName(utf8_decode($myuser["company"])); $addr->isCompany=true; } $k->setAddress(KlarnaFlags::IS_BILLING, $addr); $k->setAddress(KlarnaFlags::IS_SHIPPING, $addr); $k->setEstoreInfo($ordernumber); $sql = "SELECT transactionid FROM Pi_klarna_payment_order_data WHERE order_number = ?"; $rno = Shopware()->Db()->fetchOne($sql, array($ordernumber)); $sql = "SELECT payment_name FROM Pi_klarna_payment_order_data WHERE order_number = ?"; $PigmbhKlarnaPaymentName = Shopware()->Db()->fetchOne($sql, array($ordernumber)); if ($PigmbhKlarnaPaymentName == 'KlarnaInvoice') $PigmbhKlarnaPaymentFlag = KlarnaPClass::INVOICE; else { try { $pclasses = $k->getPClasses(null); $PigmbhKlarnaPaymentFlag = $pclasses[0]->getId(); } catch (Exception $e) { $myerror['error'] = true; $myerror['errormessage'] = $e->getMessage() . " (#" . $e->getCode() . ")"; return $myerror; } } if ($piKlarnaConfig->pi_klarna_Testmode == true) $piKlarnaTestmode = KlarnaFlags::TEST_MODE; else $piKlarnaTestmode = 0; if ($myuser["salutation"] == "mr") $mygender = KlarnaFlags::MALE; else $mygender = KlarnaFlags::FEMALE; $sql = "SELECT birthday FROM Pi_klarna_payment_user_data WHERE ordernumber = ?"; $myBirthday = Shopware()->Db()->fetchOne($sql, array($ordernumber)); try { $result = $k->activateReservation( $myBirthday , $rno, $mygender, '', $piKlarnaTestmode, $PigmbhKlarnaPaymentFlag ); $invno = $result[1]; $invNo = $invno; $k2 = piKlarnaCreateKlarnaInstance($ordernumber); if ($piKlarnaConfig->pi_klarna_liveserver == true) $testvar = 'true'; else $testvar = 'false'; try { $result = $k2->invoiceAmount($invNo); if ($action == 'last') $method = 'Letzte Rechnung'; elseif ($action == 'complete') $method = 'Komplette Rechnung'; else $method = 'Teilrechnung'; $sql = "INSERT INTO `Pi_klarna_payment_bills`(`method`, `order_number`, `invoice_amount`, `invoice_number`, `liveserver`) VALUES(?, ?, ?, ?, ?)"; Shopware()->Db()->query($sql, array($method, $ordernumber, $result, $invno, $testvar)); for ($i = 0; $i < sizeof($articles); $i++) { $myarticlename = $articles[$i]['name']; // $myarticlename = str_replace("'", "\'", $articles[$i]['name']); $sql = "INSERT INTO `Pi_klarna_payment_bills_articles` (`order_number`, `invoice_number`, `name`, `bestell_nr`, `anzahl`, `einzelpreis`) VALUES(?, ?, ?, ?, ? ,?)"; Shopware()->Db()->query($sql, array( $ordernumber, $invno, $myarticlename, $articles[$i]['bestell_nr'], (int)$articles[$i]['anzahl'], $articles[$i]['einzelpreis'] )); } $ch = ""; if ($piKlarnaConfig->pi_klarna_liveserver == true) { $ch = curl_init('https://online.klarna.com/invoices/' . $invno . '.pdf'); } else { $ch = curl_init('https://beta-test.klarna.com/invoices/' . $invno . '.pdf'); } $fp = fopen('files/documents/' . $invno . '.pdf', 'wb'); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); fclose($fp); return $myerror; } catch (Exception $e) { $myerror['error'] = true; $myerror['errormessage'] = $e->getMessage() . " (#" . $e->getCode() . ")"; return $myerror; } } catch (Exception $e) { $myerror['error'] = true; $myerror['errormessage'] = $e->getMessage() . " (#" . $e->getCode() . ")"; return $myerror; } }
public function setTableDefinition() { parent::setTableDefinition(); $this->setTableName('company'); # override the not null and not blank properties for the createdby column in the BaseEntity $this->hasColumn('createdby', 'integer', 11, array('default' => NULL)); $this->hasColumn('refno', 'string', 15); $this->hasColumn('name', 'string', 255, array('notblank' => true)); $this->hasColumn('appname', 'string', 255); $this->hasColumn('headertype', 'integer', null, array('default' => 0)); $this->hasColumn('slogan', 'string', 255); $this->hasColumn('username', 'string', 255); $this->hasColumn('abbrv', 'string', 255); $this->hasColumn('status', 'integer', null, array('default' => NULL)); $this->hasColumn('contactperson', 'string', 255); $this->hasColumn('email', 'string', 255); $this->hasColumn('phone', 'string', 15); $this->hasColumn('country', 'string', 2, array('default' => 'UG')); $this->hasColumn('addressline1', 'string', 255); $this->hasColumn('addressline2', 'string', 255); $this->hasColumn('city', 'string', 255); $this->hasColumn('postalcode', 'string', 10); $this->hasColumn('industrycode', 'string', 15); $this->hasColumn('description', 'string', 1000); $this->hasColumn('remarks', 'string', 255); $this->hasColumn('yearstart', 'date', null, array('default' => getFirstDayOfMonth(1, date('Y')))); $this->hasColumn('yearend', 'date', null, array('default' => getLastDayOfMonth(12, date('Y')))); $this->hasColumn('ipsubnets', 'string', 255); $this->hasColumn('hoursinday', 'string', 50, array('default' => HOURS_IN_DAY)); $this->hasColumn('openinghour', 'string', 50, array('default' => '08:00 AM')); $this->hasColumn('closinghour', 'string', 50, array('default' => '05:00 PM')); $this->hasColumn('lunchduration', 'string', 50, array('default' => DEFAULT_LUNCH_DURATION)); $this->hasColumn('payspaye', 'string', 50, array('default' => 1)); $this->hasColumn('paysnssf', 'string', 50, array('default' => 1)); $this->hasColumn('nssfemployeerate', 'string', 50, array('default' => DEFAULT_NSSF_EMP)); $this->hasColumn('nssfcompanyrate', 'string', 50, array('default' => DEFAULT_NSSF_COM)); $this->hasColumn('workingdays', 'string', 50); $this->hasColumn('maxhoursperday', 'string', 50, array('default' => HOURS_IN_DAY)); $this->hasColumn('maxhoursperweek', 'string', 50, array('default' => HOURS_IN_WEEK)); $this->hasColumn('defaultuserid', 'integer', null, array('default' => NULL)); $this->hasColumn('dateapproved', 'date', null, array('default' => NULL)); $this->hasColumn('approvedbyid', 'integer', null, array('default' => NULL)); $this->hasColumn('isinvited', 'integer', null, array('default' => NULL)); $this->hasColumn('invitedbyid', 'integer', null); $this->hasColumn('hasacceptedinvite', 'integer', null, array('default' => 0)); $this->hasColumn('dateinvited', 'date'); $this->hasColumn('startdate', 'date', null, array('default' => NULL)); $this->hasColumn('enddate', 'date', null, array('default' => NULL)); $this->hasColumn('layout', 'string', 25, array('default' => getDefaultLayout())); $this->hasColumn('topbar', 'string', 25, array('default' => getDefaultTopBar())); $this->hasColumn('sidebar', 'string', 25, array('default' => getDefaultSideBar())); $this->hasColumn('colortheme', 'string', 25, array('default' => getDefaultTheme())); $this->hasColumn('showsidebar', 'string', 25, array('default' => getDefaultShowSideBar())); $this->hasColumn('logo', 'string', 255); $this->hasColumn('defaultadminname', 'string', 255, array('default' => getDefaultAdminName())); $this->hasColumn('defaultadminemail', 'string', 255, array('default' => getDefaultAdminEmail())); $this->hasColumn('currencysymbol', 'string', 15, array('default' => getCountryCurrencySymbol())); $this->hasColumn('currencycode', 'string', 15, array('default' => getCountryCurrencyCode())); $this->hasColumn('currencydecimalplaces', 'string', 15, array('default' => getCurrencyDecimalPlaces())); $this->hasColumn('numberdecimalplaces', 'string', 15, array('default' => getNumberDecimalPlaces())); $this->hasColumn('countryisocode', 'string', 15, array('default' => getCountryCode())); $this->hasColumn('phonemaxlength', 'string', 15, array('default' => getMaxPhoneLength())); $this->hasColumn('phoneminlength', 'string', 15, array('default' => getMinPhoneLength())); $this->hasColumn('nationalidminlength', 'string', 15, array('default' => getNationalIDMaxLength())); $this->hasColumn('nationalidmaxlength', 'string', 15, array('default' => getNationalIDMinLength())); $this->hasColumn('countryphonecode', 'string', 15, array('default' => getDefaultPhoneCode())); $this->hasColumn('timezone', 'string', 255, array('default' => getTimeZine())); }
function countryFlag($s) { if (is_numeric($s)) { $s = getCountryCode($s); } else { if (!is_alphanumeric($s)) { throw new \Exception('hey'); } if (strlen($s) == 2) { $s = country_2_to_3_letters($s); } $s = strtoupper($s); } $locale = \cd\LocaleHandler::getInstance(); $title = getCountryName($s); if (!$title) { throw new \Exception('unhandled country flag code ' . $s); } return '<img src="' . relurl('core_dev/gfx/flags/' . $s . '.png') . '" alt="' . $title . '" title="' . $title . '"/>'; }
/** * Generate the page about payment information. */ function generatePay() { global $lr_session; global $CONFIG; $this->smarty->assign('order_number', $this->registration->formatted_order_id()); if ($this->event->cost == 0) { $this->template_name = 'pages/event/register/done_no_cost.tpl'; return true; } if (variable_get('paypal', '')) { $paypal = new PaypalHandler(); $this->smarty->assign('paypal', 'pages/event/register/paypal_payment.tpl'); $this->smarty->assign('shopping_url', $paypal->shopping_url); $this->smarty->assign('return_url', $paypal->return_url . $this->registration->order_id); $this->smarty->assign('paypal_url', $paypal->submit_url); $this->smarty->assign('paypal_email', $paypal->account_email); $this->smarty->assign('registration', $this->registration); $this->smarty->assign('event', $this->event); // include user details for auto fill forms // Paypal wants country codes, not names, so rewrite country value in user $lr_session->user->addr_country = getCountryCode($lr_session->user->addr_country); $this->smarty->assign('user', $lr_session->user); } $this->template_name = 'pages/event/register/offline_payment.tpl'; // TODO: should probably just be a sub-template $this->smarty->assign('offline_payment_text', strtr(variable_get('offline_payment_text', ''), array('%order_num' => $this->registration->formatted_order_id()))); $this->smarty->assign('refund_policy_text', variable_get('refund_policy_text', '')); $this->smarty->assign('partner_info_text', variable_get('partner_info_text', '')); return true; }
/** * Adds address to Klarna object * * @param Object $k Klarna object * */ public function addKlarnaAddress($k) { $myuser = $this->getUser(); $piKlarnaCountryIso = getBillingCountry($myuser); if ($piKlarnaCountryIso == 'DE' || $piKlarnaCountryIso == 'NL') { $piKlarnaStreet = $myuser["billingaddress"]["street"]; } else { $piKlarnaStreet = $myuser["billingaddress"]["street"] . ' ' . $myuser["billingaddress"]["streetnumber"]; } $addr = new KlarnaAddr($myuser["additional"]["user"]["email"], '', $myuser["billingaddress"]["phone"], $this->_convertEncoding($myuser["billingaddress"]["firstname"]), $this->_convertEncoding($myuser["billingaddress"]["lastname"]), '', $this->_convertEncoding($piKlarnaStreet), $myuser["billingaddress"]["zipcode"], $this->_convertEncoding($myuser["billingaddress"]["city"]), getCountryCode($piKlarnaCountryIso) ); if ($piKlarnaCountryIso == 'DE' || $piKlarnaCountryIso == 'NL') { $addr->setHouseNumber($myuser["billingaddress"]["streetnumber"]); if ($piKlarnaCountryIso == 'NL') { $addr->setHouseExt($this->_convertEncoding($myuser["billingaddress"]["text4"])); } } elseif ($myuser["billingaddress"]["company"]) { $addr->setCompanyName($this->_convertEncoding($myuser["billingaddress"]["company"])); $addr->isCompany = true; } $k->setCountry($piKlarnaCountryIso); $k->setAddress(KlarnaFlags::IS_BILLING, $addr); $k->setAddress(KlarnaFlags::IS_SHIPPING, $addr); }