public function process($template = null) { list($tpl_block, $tpl_item) = def_module::loadTemplates("emarket/payment/invoice/" . $template, 'legal_person_block', 'legal_person_item'); $collection = umiObjectsCollection::getInstance(); $types = umiObjectTypesCollection::getInstance(); $typeId = $types->getBaseType("emarket", "legal_person"); $customer = customer::get(); $order = $this->order; $mode = getRequest('param2'); if ($mode == 'do') { $personId = getRequest('legal-person'); $isNew = $personId == null || $personId == 'new'; if ($isNew) { $typeId = $types->getBaseType("emarket", "legal_person"); $personId = $collection->addObject("", $typeId); $controller = cmsController::getInstance(); $data = getRequest('data'); if ($data && ($dataModule = $controller->getModule("data"))) { $person = $collection->getObject($personId); $person->setName($data['new']['name']); $dataModule->saveEditedObject($personId, $isNew, true); } if ($collection->getObject($personId) instanceof umiObject) { $customer = customer::get(); $customer->legal_persons = array_merge($customer->legal_persons, array($personId)); } } $order->legal_person = $personId; $order->order(); $order->payment_document_num = $order->id; $result = $this->printInvoice($order); $buffer = outputBuffer::current(); $buffer->charset('utf-8'); $buffer->contentType('text/html'); $buffer->clear(); $buffer->push($result); $buffer->end(); return true; } else { if ($mode == 'delete') { $personId = (int) getRequest('person-id'); if ($collection->isExists($personId)) { $customer = customer::get(); $customer->legal_persons = array_diff($customer->legal_persons, array($personId)); $collection->delObject($personId); } } } $items = array(); $persons = $customer->legal_persons; if (is_array($persons)) { foreach ($persons as $personId) { $person = $collection->getObject($personId); $item_arr = array('attribute:id' => $personId, 'attribute:name' => $person->name); $items[] = def_module::parseTemplate($tpl_item, $item_arr, false, $personId); } } $block_arr = array('attribute:type-id' => $typeId, 'attribute:type_id' => $typeId, 'xlink:href' => 'udata://data/getCreateForm/' . $typeId, 'subnodes:items' => $items); return def_module::parseTemplate($tpl_block, $block_arr); }
public function validate() { $customer = customer::get(); if (is_array($this->user_groups) && is_array($customer->groups)) { return sizeof(array_intersect($customer->groups, $this->user_groups)); } else { return false; } }
public function validate() { if (is_array($this->users)) { $customer = customer::get(); return in_array($customer->id, $this->users); } else { return false; } }
public static function detail() { //get customers $detail['expense_account_all'] = expenseaccount::get_all(); //get customers $detail['customer'] = customer::get(); $detail['customer_all'] = customer::get_all(); //get billers $detail['biller_all'] = biller::get_all(); //get invoices $detail['invoice_all'] = invoice::get_all(); //get products $detail['product_all'] = product::get_all(); return $detail; }
/** * Создать новый пустой заказ * @return Integer $order id нового заказа */ public static function create($useDummyOrder = false) { $objectTypes = umiObjectTypesCollection::getInstance(); $objects = umiObjectsCollection::getInstance(); $permissions = permissionsCollection::getInstance(); $cmsController = cmsController::getInstance(); $domain = $cmsController->getCurrentDomain(); $domainId = $domain->getId(); $orderTypeId = $objectTypes->getBaseType('emarket', 'order'); if ($useDummyOrder) { $sel = new selector('objects'); $sel->types('object-type')->name('emarket', 'order'); $sel->where('name')->equals('dummy'); $sel->limit(0, 1); if ($sel->length()) { $orderId = $sel->first->id; } else { $orderTypeId = $objectTypes->getBaseType('emarket', 'order'); $orderId = $objects->addObject('dummy', $orderTypeId); $order = $objects->getObject($orderId); if ($order instanceof iUmiObject == false) { throw new publicException("Can't load dummy object for order #{$orderId}"); } else { $order->setValue('domain_id', $domainId); $order->commit(); } } return self::get($orderId); } $managerId = 0; $statusId = self::getStatusByCode('basket'); $customer = customer::get(); $createTime = time(); $orderId = $objects->addObject('', $orderTypeId); $order = $objects->getObject($orderId); if ($order instanceof iUmiObject == false) { throw new publicException("Can't load created object for order #{$orderId}"); } $order->domain_id = $domainId; $order->manager_id = $managerId; $order->status_id = $statusId; $order->customer_id = $customer->getId(); $order->order_create_date = $createTime; $order->commit(); $customer->setLastOrder($orderId, $domainId); return self::get($orderId); }
protected function getCustomerOrders() { static $customerOrders = null; if (!is_null($customerOrders)) { return $customerOrders; } $customer = customer::get(); $cmsController = cmsController::getInstance(); $domain = $cmsController->getCurrentDomain(); $domainId = $domain->getId(); $sel = new selector('objects'); $sel->types('object-type')->name('emarket', 'order'); $sel->where('customer_id')->equals($customer->id); $sel->where('domain_id')->equals($domainId); $sel->where('status_id')->equals(order::getStatusByCode('ready')); return $customerOrders = $sel->result; }
/** * Функция рисует список заказов пользователя * @param string $template Название шаблона * @return mixed Список заказов пользователя */ public function show_user_orders($template = 'default') { list($tpl_block, $tpl_block_empty, $tpl_item, $tpl_order_item) = def_module::loadTemplates("emarket/" . $template, 'orders_block', 'orders_block_empty', 'orders_item', 'orders_order_item'); $cmsController = cmsController::getInstance(); $domain = $cmsController->getCurrentDomain(); $domainId = $domain->getId(); $sel = new selector('objects'); $sel->types('object-type')->name('emarket', 'order'); $sel->where('customer_id')->equals(customer::get()->id); $sel->where('name')->isNull(false); $sel->where('domain_id')->equals($domainId); if ($sel->length == 0) { $tpl_block = $tpl_block_empty; } $items_arr = array(); foreach ($sel->result as $selOrder) { $order = order::get($selOrder->id); $item_arr['attribute:id'] = $order->id; $item_arr['attribute:name'] = $order->name; $item_arr['attribute:type-id'] = $order->typeId; $item_arr['attribute:guid'] = $order->GUID; $item_arr['attribute:type-guid'] = $order->typeGUID; $item_arr['attribute:ownerId'] = $order->ownerId; $item_arr['xlink:href'] = $order->xlink; $item_arr['attribute:delivery_allow_date'] = date('d.m.Y', $order->getValue('delivery_allow_date')->timestamp); //print_r($order->getValue('order_items')); //Получаем список товаров заказа $items = array(); foreach ($order->getItems() as $orderItem) { // print_r($order_item); die; $item_line = array(); // print_r(umiHierarchy::getInstance()->getObjectInstances($orderItem->id)); $item_line['attribute:element_id'] = $orderItem->id; $item_line['attribute:name'] = $orderItem->name; $item_line['attribute:item_amount'] = $orderItem->getAmount(); // $item_line['attribute:options'] = $orderItem->getOptions(); // print_r($order_item->options); $items[] = def_module::parseTemplate($tpl_order_item, $item_line, false, $iOrderItemId); umiObjectsCollection::getInstance()->unloadObject($iOrderItemId); } $item_arr['subnodes:order_items'] = $items; $items_arr[] = def_module::parseTemplate($tpl_item, $item_arr, false, $order->id); } return def_module::parseTemplate($tpl_block, array('subnodes:items' => $items_arr)); }
public function detail() { //get expenseaccount $expenseaccountobj = new expenseaccount(); $detail['expense_account_all'] = $expenseaccountobj->get_all(); //get customers with domain_id from session by constructor $customerobj = new customer(); $detail['customer'] = $customerobj->get(); $detail['customer_all'] = $customerobj->get_all(); //get billers with domain_id from session by constructor $billerobj = new biller(); $detail['biller_all'] = $billerobj->get_all(); //get invoices $invoiceobj = new invoice(); $detail['invoice_all'] = $invoiceobj->get_all(); //get products $productobj = new product(); $detail['product_all'] = $productobj->get_all(); return $detail; }
/** * Получить текущую валюту * @return iUmiObject текущая валюта */ public function getCurrentCurrency() { static $currency = null; if (!is_null($currency)) { return $currency; } if (permissionsCollection::getInstance()->isAuth()) { $customer = customer::get(); if ($customer->preffered_currency) { $currencyTypeId = umiObjectTypesCollection::getInstance()->getBaseType('emarket', 'currency'); $currency = selector::get('object')->id($customer->preffered_currency); if ($currency->typeId == $currencyTypeId) { return $currency; } } } else { if ($v = (int) getCookie('customer_currency')) { return $currency = selector::get('object')->id($v); } } $guest = umiObjectsCollection::getInstance()->getObjectByGUID('system-guest'); if ($v = $guest->getValue('preffered_currency')) { return $currency = selector::get('object')->id($v); } return $currency = $this->getDefaultCurrency(); }
* * showitem.customer.php * * showitem.customer dialog * */ // enable or disable logging error_reporting(E_ALL); ini_set('display_errors', '1'); // 0 - disabled; 1 - enabled // $o = new customer($data->data->id); $o->details(); ?> <div class="title"><?php echo ucwords($o->get("id") == -1 ? CUSTOMER_NEW_CUSTOMER : CUSTOMER_EDIT_NEW_CUSTOMER); ?> </div> <div class="form"> <div class="column"><input type="hidden" id="id" value="<?php echo $o->get('id'); ?> " /> <?php if ($_customer_name === true) { ?> <div class="row name"> <div class="caption"><?php echo ucwords(CUSTOMER_NAME); ?> </div>
public function payment() { global $config; global $logger; $SI_BILLER = new SimpleInvoices_Db_Table_Biller(); $SI_PREFERENCES = new SimpleInvoices_Db_Table_Preferences(); //set customer,biller and preference if not defined if(empty($this->customer)) { $this->customer = customer::get($this->invoice['customer_id']); } if(empty($this->biller)) { $this->biller = $SI_BILLER->getBiller($this->invoice['biller_id']); } if(empty($this->preference)) { $this->preference = $SI_PREFERENCES->getPreferenceById($this->invoice['preference_id']); } $eway = new ewaylib($this->biller['eway_customer_id'],'REAL_TIME', false); //Eway only accepts amount in cents - so times 100 $value = $this->invoice['total']*100; $eway_invoice_total = htmlsafe(trim($value)); $logger->log("eway totla: " . $eway_invoice_total, Zend_Log::INFO); $enc = new encryption(); $key = $config->encryption->default->key; $credit_card_number = $enc->decrypt($key, $this->customer['credit_card_number']); $eway->setTransactionData("TotalAmount", $eway_invoice_total); //mandatory field $eway->setTransactionData("CustomerFirstName", $this->customer['name']); $eway->setTransactionData("CustomerLastName", ""); $eway->setTransactionData("CustomerAddress", ""); $eway->setTransactionData("CustomerPostcode", ""); $eway->setTransactionData("CustomerInvoiceDescription", ""); $eway->setTransactionData("CustomerEmail", $this->customer['email']); $eway->setTransactionData("CustomerInvoiceRef", $this->invoice['index_name']); $eway->setTransactionData("CardHoldersName", $this->customer['credit_card_holder_name']); //mandatory field $eway->setTransactionData("CardNumber", $credit_card_number); //mandatory field $eway->setTransactionData("CardExpiryMonth", $this->customer['credit_card_expiry_month']); //mandatory field $eway->setTransactionData("CardExpiryYear", $this->customer['credit_card_expiry_year']); //mandatory field $eway->setTransactionData("Option1", ""); $eway->setTransactionData("Option2", ""); $eway->setTransactionData("Option3", ""); $eway->setTransactionData("TrxnNumber", $this->invoice['id']); //special preferences for php Curl $eway->setCurlPreferences(CURLOPT_SSL_VERIFYPEER, 0); //pass a long that is set to a zero value to stop curl from verifying the peer's certificate $ewayResponseFields = $eway->doPayment(); $this->message = $ewayResponseFields; $message =""; if($ewayResponseFields["EWAYTRXNSTATUS"]=="False"){ $logger->log("Transaction Error: " . $ewayResponseFields["EWAYTRXNERROR"] . "<br>\n", Zend_Log::INFO); foreach($ewayResponseFields as $key => $value) $message .= "\n<br>\$ewayResponseFields[\"$key\"] = $value"; $logger->log("Eway message: " . $message . "<br>\n", Zend_Log::INFO); //header("Location: trasnactionerrorpage.php"); //exit(); $return = 'false'; }else if($ewayResponseFields["EWAYTRXNSTATUS"]=="True"){ $logger->log("Transaction Success: " . $ewayResponseFields["EWAYTRXNERROR"] . "<br>\n", Zend_Log::INFO); foreach($ewayResponseFields as $key => $value) $message .= "\n<br>\$ewayResponseFields[\"$key\"] = $value"; $logger->log("Eway message: " . $message . "<br>\n", Zend_Log::INFO); //header("Location: trasnactionsuccess.php"); //exit(); $payment = new payment(); $payment->ac_inv_id = $this->invoice['id']; #$payment->ac_inv_id = $_POST['invoice']; $payment->ac_amount = $this->invoice['total']; #$payment->ac_amount = $ewayResponseFields['EWAYRETURNAMOUNT']/100; #$payment->ac_amount = $_POST['mc_gross']; $payment->ac_notes = $message; $payment->ac_date = date( 'Y-m-d' ); $payment->online_payment_id = $ewayResponseFields['EWAYTRXNNUMBER']; $payment->domain_id = domain_id::get($this->domain_id); $payment_type = new payment_type(); $payment_type->type = "Eway"; $payment_type->domain_id = $domain_id; $payment->ac_payment_type = $payment_type->select_or_insert_where(); $logger->log('Paypal - payment_type='.$payment->ac_payment_type, Zend_Log::INFO); $payment->insert(); #echo $db->lastInsertID(); $return = 'true'; } return $return ; }
public function run() { global $db; global $auth_session; $SI_BILLER = new SimpleInvoices_Db_Table_Biller(); $SI_PREFERENCES = new SimpleInvoices_Db_Table_Preferences(); $today = date('Y-m-d'); $domain_id = domain_id::get($this->domain_id); $cron_log = new cronlog(); $cron_log->run_date = empty($this->run_date) ? $today : $this->run_date; $check_cron_log = $cron_log->check(); //only proceed if cron has not been run for today $cron = new cron(); $data = $cron->select_all('no_limit'); $return['cron_message'] ="Cron started"; $number_of_crons_run = "0"; foreach ($data as $key=>$value) { $cron_log = new cronlog(); $cron_log->run_date = empty($this->run_date) ? $today : $this->run_date; $cron_log->cron_id = $data[$key]['cron_id']; $check_cron_log = $cron_log->check(); $i="0"; if ($check_cron_log == 0) { $run_cron ='false'; $start_date = date('Y-m-d', strtotime( $data[$key]['start_date'] ) ); $end_date = $data[$key]['end_date'] ; $diff = number_format((strtotime($today) - strtotime($start_date)) / (60 * 60 * 24),0); //only check if diff is positive if (($diff >= 0) AND ($end_date =="" OR $end_date >= $today)) { if($data[$key]['recurrence_type'] == 'day') { $modulus = $diff % $data[$key]['recurrence'] ; if($modulus == 0) { $run_cron ='true'; } else { #$return .= "cron does not runs TODAY-days"; } } if($data[$key]['recurrence_type'] == 'week') { $period = 7 * $data[$key]['recurrence']; $modulus = $diff % $period ; if($modulus == 0) { $run_cron ='true'; } else { #$return .= "cron is not runs TODAY-week"; } } if($data[$key]['recurrence_type'] == 'month') { $start_day = date('d', strtotime( $data[$key]['start_date'] ) ); $start_month = date('m', strtotime( $data[$key]['start_date'] ) ); $start_year = date('Y', strtotime( $data[$key]['start_date'] ) ); $today_day = date('d'); $today_month = date('m'); $today_year = date('Y'); $months = ($today_month-$start_month)+12*($today_year-$start_year); $modulus = $months % $data[$key]['recurrence'] ; if( ($modulus == 0) AND ( $start_day == $today_day ) ) { $run_cron ='true'; } else { #$return .= "cron is not runs TODAY-month"; } } if($data[$key]['recurrence_type'] == 'year') { $start_day = date('d', strtotime( $data[$key]['start_date'] ) ); $start_month = date('m', strtotime( $data[$key]['start_date'] ) ); $start_year = date('Y', strtotime( $data[$key]['start_date'] ) ); $today_day = date('d'); $today_month = date('m'); $today_year = date('Y'); $years = $today_year-$start_year; $modulus = $years % $data[$key]['recurrence'] ; if( ($modulus == 0) AND ( $start_day == $today_day ) AND ( $start_month == $today_month ) ) { $run_cron ='true'; } else { #$return .= "cron is not runs TODAY-year"; } } //run the recurrence for this invoice if ($run_cron == 'true') { $number_of_crons_run++; $return['cron_message_'.$data[$key]['cron_id']] = "Cron ID: ". $data[$key]['cron_id'] ." - Cron for ".$data[$key]['index_name']." with start date of ".$data[$key]['start_date'].", end date of ".$data[$key]['end_date']." where it runs each ".$data[$key]['recurrence']." ".$data[$key]['recurrence_type']." was run today :: Info diff=".$diff; $i++; $ni = new invoice(); $ni->id = $data[$key]['invoice_id']; $new_invoice_id = $ni->recur(); //insert into cron_log date of run $cron_log = new cronlog(); $cron_log->run_date = $today; $cron_log->domain_id = $domain_id; $cron_log->cron_id = $data[$key]['cron_id']; $cron_log->insert(); ## email the people $invoice= invoice::select($new_invoice_id); $preference = $SI_PREFERENCES->getPreferenceById($invoice['preference_id']); $biller = $_SI_BILLER->getBiller($invoice['biller_id']); $customer = customer::get($invoice['customer_id']); #print_r($customer); #create PDF nameVj $spc2us_pref = str_replace(" ", "_", $invoice['index_name']); $pdf_file_name_invoice = $spc2us_pref.".pdf"; // email invoice if( ($data[$key]['email_biller'] == "1") OR ($data[$key]['email_customer'] == "1") ) { $export = new export(); $export -> format = "pdf"; $export -> file_location = 'file'; $export -> module = 'invoice'; $export -> id = $invoice['id']; $export -> execute(); #$attachment = file_get_contents('./tmp/cache/' . $pdf_file_name); $email = new email(); $email -> format = 'cron_invoice'; $email_body = new email_body(); $email_body->email_type = 'cron_invoice'; $email_body->customer_name = $customer['name']; $email_body->invoice_name = $invoice['index_name']; $email_body->biller_name = $biller['name']; $email -> notes = $email_body->create(); $email -> from = $biller['email']; $email -> from_friendly = $biller['name']; if($data[$key]['email_customer'] == "1") { $email -> to = $customer['email']; } if($data[$key]['email_biller'] == "1" AND $data[$key]['email_customer'] == "1") { $email -> to = $customer['email'].";".$biller['email']; } if($data[$key]['email_biller'] == "1" AND $data[$key]['email_customer'] == "0") { $email -> to = $biller['email']; } $email -> invoice_name = $invoice['index_name']; $email -> subject = $email->set_subject(); $email -> attachment = $pdf_file_name_invoice; $return['email_message'] = $email -> send (); } //Check that all details are OK before doing the eway payment $eway_check = new eway(); $eway_check->invoice = $invoice; $eway_check->customer = $customer; $eway_check->biller = $biller; $eway_check->preference = $preference; $eway_pre_check = $eway_check->pre_check(); //do eway payment if ($eway_pre_check == 'true') { // input customerID, method (REAL_TIME, REAL_TIME_CVN, GEO_IP_ANTI_FRAUD) and liveGateway or not $eway = new eway(); $eway->invoice = $invoice; $eway->biller = $biller ; $eway->customer = $customer; $payment_done = $eway->payment(); $payment_id = $db->lastInsertID(); $pdf_file_name_receipt = 'payment'.$payment_id.'.pdf'; if ($payment_done =='true') { //do email of receipt to biller and customer if( ($data[$key]['email_biller'] == "1") OR ($data[$key]['email_customer'] == "1") ) { /* * If you want a new copy of the invoice being emailed to the customer * use this code */ $export_rec = new export(); $export_rec -> format = "pdf"; $export_rec -> file_location = 'file'; $export_rec -> module = 'invoice'; $export_rec -> id = $invoice['id']; $export_rec -> execute(); #$attachment = file_get_contents('./tmp/cache/' . $pdf_file_name); $email_rec = new email(); $email_rec -> format = 'cron_invoice'; $email_body_rec = new email_body(); $email_body_rec->email_type = 'cron_invoice_receipt'; $email_body_rec->customer_name = $customer['name']; $email_body_rec->invoice_name = $invoice['index_name']; $email_body_rec->biller_name = $biller['name']; $email_rec -> notes = $email_body_rec->create(); $email_rec -> from = $biller['email']; $email_rec -> from_friendly = $biller['name']; if($data[$key]['email_customer'] == "1") { $email_rec -> to = $customer['email']; } if($data[$key]['email_biller'] == "1" AND $data[$key]['email_customer'] == "1") { $email_rec -> to = $customer['email'].";".$biller['email']; } if($data[$key]['email_biller'] == "1" AND $data[$key]['email_customer'] == "0") { $email_rec -> to = $biller['email']; } $email_rec -> invoice_name = $invoice['index_name']; $email_rec -> attachment = $pdf_file_name_invoice; $email_rec -> subject = $email_rec->set_subject('invoice_eway_receipt'); $return['email_message'] = $email_rec -> send (); /* * If you want a receipt as PDF being emailed to the customer uncomment * the below code */ /* $export = new export(); $export -> format = "pdf"; $export -> file_location = 'file'; $export -> module = 'payment'; $export -> id = $payment_id; $export -> execute(); $email = new email(); $email -> format = 'cron_payment'; $email_body = new email_body(); $email_body->email_type = 'cron_payment'; $email_body->customer_name = $customer['name']; $email_body->invoice_name = 'payment'.$payment_id; $email_body->biller_name = $biller['name']; $email -> notes = $email_body->create(); $email -> from = $biller['email']; $email -> from_friendly = $biller['name']; if($data[$key]['email_customer'] == "1") { $email -> to = $customer['email']; } if($data[$key]['email_biller'] == "1" AND $data[$key]['email_customer'] == "1") { $email -> to = $customer['email'].";".$biller['email']; } if($data[$key]['email_biller'] == "1" AND $data[$key]['email_customer'] == "0") { $email -> to = $customer['email']; } $email -> subject = $pdf_file_name_receipt." from ".$biller['name']; $email -> attachment = $pdf_file_name_receipt; $return['email_message'] = $email->send(); */ } } else { //do email to biller/admin - say error $email = new email(); $email -> format = 'cron_payment'; $email -> from = $biller['email']; $email -> from_friendly = $biller['name']; $email -> to = $biller['email']; $email -> subject = "Payment failed for ".$invoice['index_name']; $error_message ="Invoice: ".$invoice['index_name']."<br /> Amount: ".$invoice['total']." <br />"; foreach($eway->get_message() as $key => $value) $error_message .= "\n<br>\$ewayResponseFields[\"$key\"] = $value"; $email -> notes = $error_message; $return['email_message'] = $email->send(); } } } else { //cron not run for this cron_id $return['cron_message_'.$data[$key]['cron_id']] = "Cron ID: ". $data[$key]['cron_id'] ." NOT RUN: Cron for ".$data[$key]['index_name']." with start date of ".$data[$key]['start_date'].", end date of ".$data[$key]['end_date']." where it runs each ".$data[$key]['recurrence']." ".$data[$key]['recurrence_type']." did not recur today :: Info diff=".$diff; } } else { //days diff is negaqtive - whats going on $return['cron_message_'.$data[$key]['cron_id']] = "Cron ID: ". $data[$key]['cron_id'] ." NOT RUN: - Not cheduled for today - Cron for ".$data[$key]['index_name']." with start date of ".$data[$key]['start_date'].", end date of ".$data[$key]['end_date']." where it runs each ".$data[$key]['recurrence']." ".$data[$key]['recurrence_type']." did not recur today :: Info diff=".$diff; } } else { // cron has already been run for that cron_id toda $return['cron_message_'.$data[$key]['cron_id']] = "Cron ID: ".$data[$key]['cron_id']." - Cron has already been run for domain: ".$domain_id." for the date: ".$today." for invoice ".$data[$key]['invoice_id']; $return['email_message'] = ""; } } // no crons scheduled for today if ($number_of_crons_run == '0') { $return['id'] = $i; $return['cron_message'] = "No invoices recurred for this cron run for domain: ".$domain_id." for the date: ".$today; $return['email_message'] = ""; } //insert into cron_log date of run /* $cron_log = new cronlog(); $cron_log->run_date = $today; $cron_log->domain_id = $domain_id; $cron_log->insert();*/ /* * If you want to get an email once cron has been run edit the below details * */ /* $email = new email(); $email -> format = 'cron'; #$email -> notes = $return; $email -> from = "simpleinvoices@localhost"; $email -> from_friendly = "Simple Invoices - Cron"; $email -> to = "simpleinvoices@localhost"; #$email -> bcc = $_POST['email_bcc']; $email -> subject = "Cron for Simple Invoices has been run for today:"; $email -> send (); */ return $return; }
/** * Узнать, является ли пользователь $user_id владельцем объекта (класс umiObject) $object_id * @param Integer $object_id id объекта (класс umiObject) * @param $user_id id пользователя * @return Boolean true, если пользователь является владельцем */ public function isOwnerOfObject($object_id, $user_id = false) { if ($user_id == false) { $user_id = $this->getUserId(); } if ($user_id == $object_id) { //Objects == User, that's ok return true; } else { $object = umiObjectsCollection::getInstance()->getObject($object_id); if ($object instanceof umiObject) { $owner_id = $object->getOwnerId(); } else { $owner_id = 0; } if ($owner_id == 0 || $owner_id == $user_id) { return true; } else { $guestId = umiObjectsCollection::getInstance()->getObjectIdByGUID('system-guest'); if ($owner_id == $guestId && class_exists('customer')) { $customer = customer::get(); if ($cusotmer && $customer->id == $owner_id) { return true; } } return false; } } }
<?php //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); #get the invoice id $expense_id = $_GET['id']; $expenseobj = new expense(); $customerobj = new customer(); $billerobj = new biller(); $invoiceobj = new invoice(); $productobj = new product(); $expenseaccountobj = new expenseaccount(); $expensetaxobj = new expensetax(); $expense = $expenseobj->get($expense_id); $detail = $expenseobj->detail(); $detail['customer'] = $customerobj->get($expense['customer_id']); $detail['biller'] = $billerobj->select($expense['biller_id']); $detail['invoice'] = $invoiceobj->select($expense['invoice_id']); $detail['product'] = $productobj->get($expense['product_id']); $detail['expense_account'] = $expenseaccountobj->select($expense['expense_account_id']); $detail['expense_tax'] = $expensetaxobj->get_all($expense_id); $detail['expense_tax_total'] = $expense['amount'] + $expensetaxobj->get_sum($expense_id); $detail['expense_tax_grouped'] = $expensetaxobj->grouped($expense_id); $detail['status_wording'] = $expense['status'] == 1 ? $LANG['paid'] : $LANG['not_paid']; $taxes = getActiveTaxes(); #$tax_selected = getTaxRate($product['default_tax_id']); $defaults = getSystemDefaults(); $smarty->assign('expense', $expense); $smarty->assign('detail', $detail); $smarty->assign('taxes', $taxes); $smarty->assign('defaults', $defaults);
public function chooseDeliveryAddress(order $order) { $addressId = getRequest('delivery-address'); $urlPrefix = cmsController::getInstance()->getUrlPrefix() ? cmsController::getInstance()->getUrlPrefix() . '/' : ''; if (!$addressId) { $this->redirect($this->pre_lang . '/' . $urlPrefix . 'emarket/purchase/delivery/address/'); } if (strpos($addressId, 'delivery_') === 0) { $order->delivery_address = false; $deliveryId = substr($addressId, 9); $_REQUEST['delivery-id'] = $deliveryId; $this->chooseDelivery($order); } if ($addressId == 'new') { $controller = cmsController::getInstance(); $collection = umiObjectsCollection::getInstance(); $types = umiObjectTypesCollection::getInstance(); $typeId = $types->getBaseType("emarket", "delivery_address"); $customer = customer::get(); $addressId = $collection->addObject("Address for customer #" . $customer->id, $typeId); $dataModule = $controller->getModule("data"); if ($dataModule) { $dataModule->saveEditedObject($addressId, true, true); } $customer->delivery_addresses = array_merge($customer->delivery_addresses, array($addressId)); } $order->delivery_address = $addressId; $order->commit(); $this->redirect($this->pre_lang . '/' . $urlPrefix . 'emarket/purchase/delivery/choose/'); }
function checkLogin() { if ($_SERVER['METHOD_REQUEST'] == 'POST') { $username = $this->input->post('email'); $password = $this->input->post('password'); $customer = new customer(); $customer->where('username', $username); $customer->where('password', md5($password)); $customer->get(); if ($customer->exists()) { $this->session->set_userdata("userLogin", $customer->username); $this->session->set_userdata('userToken', $customer->id); $this->session->set_userdata('userLoginFlag', "1"); redirect(base_url() . $this->lang->lang() . '/payment'); } } //$dis['customer'] = $customer; $this->column = 2; $dis['base_url'] = base_url(); $dis['view'] = 'front/user/checkLogin'; $this->viewfront($dis); }
function getData() { //echo "export - get data"; global $smarty; global $siUrl; global $include_dir; $SI_BILLER = new SimpleInvoices_Db_Table_Biller(); $SI_CUSTOM_FIELDS = new SimpleInvoices_Db_Table_CustomFields(); $SI_PREFERENCES = new SimpleInvoices_Db_Table_Preferences(); switch ($this->module) { case "database": { $data = SimpleInvoices_Db::performBackup(); break; } case "statement": { $invoice = new invoice(); $invoice->biller = $this->biller_id; $invoice->customer = $this->customer_id; if ( $this->filter_by_date =="yes" ) { if ( isset($this->start_date) ) { $invoice->start_date = $this->start_date; } if ( isset($this->end_date) ) { $invoice->end_date = $this->end_date; } if ( isset($this->start_date) AND isset($this->end_date) ) { $invoice->having = "date_between"; } $having_count = '1'; } if ( $this->show_only_unpaid == "yes") { if ($having_count == '1') { $invoice->having_and = "money_owed"; $having_count = '2'; } else { $invoice->having = "money_owed"; $having_count = '1'; } } if ( $this->show_only_real == "yes") { if ($having_count == '2') { $invoice->having_and2 = "real"; } elseif ($having_count == '1') { $invoice->having_and = "real"; } else { $invoice->having = "real"; } } $invoice_all = $invoice->select_all('count'); $invoices = $invoice_all->fetchAll(); foreach ($invoices as $i => $row) { $statement['total'] = $statement['total'] + $row['invoice_total']; $statement['owing'] = $statement['owing'] + $row['owing'] ; $statement['paid'] = $statement['paid'] + $row['INV_PAID']; } // ToDo: THIS FILE IS MISSING!! $templatePath = $include_dir . "sys/templates/default/statement/index.tpl"; $biller_details = $SI_BILLER->getBiller($this->biller_id); $customer_details = customer::get($this->customer_id); $this->file_name = "statement_".$this->biller_id."_".$this->customer_id."_".$invoice->start_date."_".$invoice->end_date; $smarty -> assign('biller_id', $biller_id); $smarty -> assign('biller_details', $biller_details); $smarty -> assign('customer_id', $customer_id); $smarty -> assign('customer_details', $customer_details); $smarty -> assign('show_only_unpaid', $show_only_unpaid); $smarty -> assign('show_only_real', $show_only_real); $smarty -> assign('filter_by_date', $this->filter_by_date); $smarty -> assign('invoices', $invoices); $smarty -> assign('start_date', $this->start_date); $smarty -> assign('end_date', $this->end_date); $smarty -> assign('invoices',$invoices); $smarty -> assign('statement',$statement); $data = $smarty -> fetch(".".$templatePath); break; } case "payment": { $customFieldLabels = $SI_CUSTOM_FIELDS->getLabels(); $payment = new SimpleInvoices_Payment($this->id); $invoice = $payment->getInvoice(); $biller = $invoice->getBiller(); $logo = $biller->getLogo(); $logo = str_replace(" ", "%20", $logo); $customer = $invoice->getCustomer(); $smarty -> assign("payment",$payment->toArray()); $smarty -> assign("invoice",$invoice->toArray()); $smarty -> assign("biller",$biller->toArray()); $smarty -> assign("logo",$logo); $smarty -> assign("customer",$customer->toArray()); $smarty -> assign("invoiceType",$invoice->getType()); $smarty -> assign("paymentType",$payment->getType()); $smarty -> assign("preference",$invoice->getPreference()); $smarty -> assign("customFieldLabels",$customFieldLabels); $smarty -> assign('pageActive', 'payment'); $smarty -> assign('active_tab', '#money'); $css = $siUrl."/sys/templates/invoices/default/style.css"; $smarty -> assign('css',$css); $templatePath = $include_dir . "sys/templates/default/modules/payments/print.tpl"; $data = $smarty -> fetch($templatePath); break; } case "invoice": { $SI_SYSTEM_DEFAULTS = new SimpleInvoices_Db_Table_SystemDefaults(); $invoice = invoice::select($this->id); $invoice_number_of_taxes = numberOfTaxesForInvoice($this->id); $customer = customer::get($invoice['customer_id']); $biller = biller::select($invoice['biller_id']); $preference = $SI_PREFERENCES->getPreferenceById($invoice['preference_id']); $defaults = $SI_SYSTEM_DEFAULTS->fetchAll(); $logo = getLogo($biller); $logo = str_replace(" ", "%20", $logo); $invoiceItems = invoice::getInvoiceItems($this->id); $spc2us_pref = str_replace(" ", "_", $invoice['index_name']); $this->file_name = $spc2us_pref; $customFieldLabels = $SI_CUSTOM_FIELDS->getLabels(); $customFieldDisplay = $SI_CUSTOM_FIELDS->getDisplay(); /*Set the template to the default*/ $template = $defaults['template']; // Instead of appending the CSS we are going to inject it allowing // a cleaner hierarchy tree while allowing public directories $css_file = $include_dir ."/sys/templates/invoices/${template}/style.css"; if (file_exists($css_file)) { $css = file_get_contents($css_file); if ($css) { // Create the tags $css = '<style type="text/css" media="all">' . $css . '</style>'; } } else { $css = ''; } $smarty->addTemplateDir($include_dir . "sys/templates/invoices/${template}/", 'Invoice_' . $template); $smarty->addPluginsDir($include_dir ."sys/templates/invoices/${template}/plugins/"); $pageActive = "invoices"; $smarty->assign('pageActive', $pageActive); if ($smarty->templateExists('file:[Invoice_' . $template . ']template.tpl')) { $smarty -> assign('biller',$biller); $smarty -> assign('customer',$customer); $smarty -> assign('invoice',$invoice); $smarty -> assign('invoice_number_of_taxes',$invoice_number_of_taxes); $smarty -> assign('preference',$preference); $smarty -> assign('logo',$logo); $smarty -> assign('template',$template); $smarty -> assign('invoiceItems',$invoiceItems); $smarty -> assign('css',$css); $smarty -> assign('customFieldLabels',$customFieldLabels); $smarty -> assign('customFieldDisplay',$customFieldDisplay); $data = $smarty->fetch('file:[Invoice_' . $template . ']template.tpl'); } break; } } return $data; }
public function receipt() { $orderId = (int) getRequest('param0'); if(!$orderId) $orderId = (int) getRequest('order-id'); $sign = (string) getRequest('param1'); if(!$sign) $sign = (string) getRequest('signature'); $order = order::get($orderId); if($order instanceof order) { $customer = customer::get($order->getCustomerId()); if($customer->isUser()) { $users = cmsController::getInstance()->getModule('users'); $userId = $users->user_id; if($userId != $customer->id) { throw new publicException("Access denied"); } $permissions = permissionsCollection::getInstance(); $object = umiObjectsCollection::getInstance()->getObject($orderId); if ($object->getOwnerId() != $userId && !$permissions->isSv($userId)) { throw new publicException("Access denied"); } } else { if (strcasecmp($sign, sha1("{$customer->id}:{$customer->email}:{$order->order_date}")) !== 0) { throw new publicException("Access denied"); } } $uri = "uobject://{$orderId}/?transform=sys-tpls/emarket-receipt.xsl"; $result = file_get_contents($uri); $buffer = outputBuffer::current(); $buffer->charset('utf-8'); $buffer->contentType('text/html'); $buffer->clear(); $buffer->push($result); $buffer->end(); } else { throw new publicException("Order #{$orderId} doesn't exists"); } }
<?php //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); $SI_SYSTEM_DEFAULTS = new SimpleInvoices_Db_Table_SystemDefaults(); $SI_TAX = new SimpleInvoices_Db_Table_Tax(); #get the invoice id $expense_id = $_GET['id']; $expense = expense::get($expense_id); $detail = expense::detail(); $detail['customer'] = customer::get($expense['customer_id']); $detail['biller'] = biller::select($expense['biller_id']); $detail['invoice'] = invoice::select($expense['invoice_id']); $detail['product'] = product::get($expense['product_id']); $detail['expense_account'] = expenseaccount::select($expense['expense_account_id']); $detail['expense_tax'] = expensetax::get_all($expense_id); $detail['expense_tax_total'] = $expense['amount'] + expensetax::get_sum($expense_id); $detail['expense_tax_grouped'] = expensetax::grouped($expense_id); $detail['status_wording'] = $expense['status']==1?$LANG['paid']:$LANG['not_paid']; $taxes = $SI_TAX->fetchAllActive(); #$tax_selected = getTaxRate($product['default_tax_id']); $defaults = $SI_SYSTEM_DEFAULTS->fetchAll(); $smarty -> assign('expense',$expense); $smarty -> assign('detail',$detail); $smarty -> assign('taxes',$taxes); $smarty -> assign('defaults',$defaults); $smarty -> assign('tax_selected',$tax_selected);
/** * Получить валидный этап покупки * @param String $stage этап покупки * @return String валидизированный этап покупки */ private static function getStage($stage) { $regedit = regedit::getInstance(); $hasDelivery = $regedit->getVal('//modules/emarket/enable-delivery'); $hasPayment = $regedit->getVal('//modules/emarket/enable-payment'); if ($stage == 'delivery' && !$hasDelivery) { $stage = 'payment'; } if ($stage == 'payment' && !$hasPayment) { return null; } if (!$stage || !in_array($stage, self::$purchaseSteps)) { $customer = customer::get(); if (!$customer->isUser() && !$customer->isFilled()) { return "required"; } return getArrayKey(self::$purchaseSteps, 1); } else { return $stage; } }
$biller_id = $_GET['biller_id']; $customer_id = $_GET['customer_id']; $filter_by_date = $_GET['filter_by_date']; if ( $filter_by_date =="yes" ) { $start_date = $_GET['start_date']; $end_date = $_GET['end_date']; } $show_only_unpaid = $_GET['show_only_unpaid']; $show_only_real = $_GET['show_only_real']; $get_format = $_GET['format']; $get_file_type = $_GET['filetype']; $biller = $SI_BILLER->getBiller($_GET['biller_id']); $customer = customer::get($_GET['customer_id']); #create PDF name if ($_GET['stage'] == 2 ) { #echo $block_stage2; #get the invoice id $export = new export(); $export -> format = 'pdf'; $export -> file_type = $get_file_type; $export -> file_location = 'file'; $export -> module = 'statement'; $export -> biller_id = $biller_id;
* http://www.simpleinvoices.org */ //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); $SI_BILLER = new SimpleInvoices_Db_Table_Biller(); $SI_PREFERENCES = new SimpleInvoices_Db_Table_Preferences(); #get the invoice id $invoice_id = $_GET['id']; $invoice = invoice::select($invoice_id); $preference = $SI_PREFERENCES->getPreferenceById($invoice['preference_id']); $biller = $SI_BILLER->getBiller($invoice['biller_id']); $customer = customer::get($invoice['customer_id']); $sql = "SELECT inv_ty_description AS type FROM ".TB_PREFIX."invoice_type WHERE inv_ty_id = :type"; $sth = dbQuery($sql, ':type', $invoice['type_id']); $invoiceType = $sth->fetch(); #create PDF name $spc2us_pref = str_replace(" ", "_", $invoice['index_name']); $pdf_file_name = $spc2us_pref . '.pdf'; if ($_GET['stage'] == 2 ) { #echo $block_stage2; // Create invoice