/** * Return parent invoice * * @param void * @return Invoice */ function getInvoice() { if ($this->invoice === false) { $this->invoice = Invoices::findById($this->getInvoiceId()); } // if return $this->invoice; }
/** * Handle on_dashboard_important_section event * * @param NamedList $items * @param User $user * @return null */ function invoicing_handle_on_dashboard_important_section(&$items, &$user) { $company = $user->getCompany(); // if user can manage invoices, list overdue invoices for all companies if ($user->getSystemPermission('can_manage_invoices')) { // if it's administrator list only overdue invoices if (($admin_overdue_invoices = Invoices::countOverdue()) > 0) { $items->add('admin_overdue_invoices', array('label' => $admin_overdue_invoices > 1 ? lang('<strong>:count</strong> overdue invoices for all companies', array('count' => $admin_overdue_invoices)) : lang('<strong>:count</strong> overdue invoice for all companies', array('count' => $admin_overdue_invoices)), 'class' => 'adminoverdue_invoices', 'icon' => get_image_url('important.gif'), 'url' => assemble_url('invoices'))); } // if } // if // if user is company manager or can manage invoices show outstanding and overdue invoices for his company if ($user->isCompanyManager($company) || $user->getSystemPermission('can_manage_invoices')) { // // Outstanding Invoices // $issued_invoices_count = Invoices::countOutstanding($company); if ($issued_invoices_count > 0) { if ($issued_invoices_count == 1) { // if there is only one outstanding invoice, then link should open that very same invoice $issued_invoices = Invoices::findOutstanding($company, array(INVOICE_STATUS_ISSUED)); $link_url = $issued_invoices[0]->getCompanyViewUrl(); $label = lang('<strong>1</strong> outstanding invoice for your company'); } else { // if there is multuple outstanding invoices, then link should open company invoices pages $link_url = assemble_url('people_company_invoices', array('company_id' => $company->getId())); $label = lang('<strong>:count</strong> outstanding invoices for your company', array('count' => $issued_invoices_count)); } // if $items->add('issued_invoices', array('label' => $label, 'class' => 'issued_invoices', 'icon' => get_image_url('icon_small.gif', INVOICING_MODULE), 'url' => $link_url)); } // if // // Overdue Invoices // $overdue_invoices_count = Invoices::countOverdue($company); if ($overdue_invoices_count > 0) { if ($overdue_invoices_count == 1) { // if there is only one overdue invoice, then link should open that very same invoice $overdue_invoices = Invoices::findOverdue($company, array(INVOICE_STATUS_ISSUED)); $link_url = $overdue_invoices[0]->getCompanyViewUrl(); $label = lang('<strong>1</strong> overdue invoice for your company'); } else { // if there is multuple overdue invoices, then link should open company invoices pages $link_url = assemble_url('people_company_invoices', array('company_id' => $company->getId())); $label = lang('<strong>:count</strong> overdue invoices for your company', array('count' => $overdue_invoices)); } // if $items->add('overdue_invoices', array('label' => $label, 'class' => 'overdue_invoices', 'icon' => get_image_url('important.gif'), 'url' => $link_url)); } // if } // if }
/** * Add options to main menu * * @param Menu $menu * @param User $user * @return null */ function invoicing_handle_on_build_menu(&$menu, &$user) { $company = $user->getCompany(); if ($user->getSystemPermission('can_manage_invoices')) { $menu->addToGroup(array(new MenuItem('invoicing', lang('Invoices'), assemble_url('invoices'), get_image_url('menu-icon.gif', INVOICING_MODULE), Invoices::countOverdue())), 'main'); } else { if ($user->isCompanyManager($company)) { $menu->addToGroup(array(new MenuItem('invoicing', lang('Invoices'), assemble_url('people_company_invoices', array('company_id' => $user->getCompanyId())), get_image_url('menu-icon.gif', INVOICING_MODULE), Invoices::countByCompany($user->getCompany(), array(INVOICE_STATUS_ISSUED)))), 'main'); } } // if }
/** * Get all task waiting to solve * By default project_id is selected * @return model list of invoices statistics amounts */ public function getStatistics() { if (Yii::app()->user->getState('project_selected') != null) { return Invoices::model()->getInvoicesStatistics(Yii::app()->user->getState('project_selected')); } else { $Projects = Projects::model()->findMyProjects(Yii::app()->user->id); $projectList = array(0); foreach ($Projects as $project) { array_push($projectList, $project->project_id); } return Invoices::model()->getInvoicesStatistics(implode(",", $projectList)); } }
public function createInvoice() { try { $_invoice = new Invoices(); $_invoice->firstName = Session::get('checkout.address')[0]['firstName']; $_invoice->lastName = Session::get('checkout.address')[0]['lastName']; $_invoice->companyname = Session::get('checkout.address')[0]['companyname']; $_invoice->email = Session::get('checkout.address')[0]['email']; $_invoice->country = Session::get('checkout.address')[0]['country']; $_invoice->state = Session::get('checkout.address')[0]['state']; $_invoice->street = Session::get('checkout.address')[0]['street']; $_invoice->zipcode = Session::get('checkout.address')[0]['zipcode']; $_invoice->telephone = Session::get('checkout.address')[0]['telephone']; $_invoice->comment = Session::get('checkout.address')[0]['comment']; $_invoice->invoiceCreater = Session::get('checkout.payment')[0]['payment']; $_invoice->invoiceCreatedDate = date("Y-m-d"); $_itemsCount = Cart::instance('shopping')->count(); $_contentCart = Cart::instance('shopping')->content(); $_contentTotal = Cart::instance('shopping')->total() + Cart::instance('shopping')->total() * 10 / 100; $_calculateinvoice = $this->getinvoicenumber(); $_invoice->invoice = $_calculateinvoice; $_invoice->save(); foreach ($_contentCart as $row) { $_resultData = DB::table('qlm_printerdetails')->where('detailId', $row->id)->get(); $_invoicedetails = new InvoiceDetails(); $_invoicedetails->product = $row->name; $_invoicedetails->quantity = $row->qty; $_invoicedetails->unitprice = $row->price; $_invoicedetails->gst = $row->price * 10 / 100; $_invoicedetails->total = $row->price * $row->qty + $row->price * $row->qty * 10 / 100; $_invoicedetails->invoice = $_calculateinvoice; $_invoicedetails->save(); } } catch (Exception $_ex) { Log::info("\$\$\$ --- Error: " . $_ex . " --- \$\$\$"); } }
/** * setLastInvoice * Set the last invoice number * @param $current_invoice_number * @return Doctrine Record */ public static function setLastInvoice($current_invoice_number) { $isp_id = Shineisp_Registry::get('ISP')->isp_id; $isp_id = intval($isp_id); $increment = Invoices::sequentialIncrement(); // Try to get last invoice number $record = Doctrine_Query::create()->select('setting_id')->from('InvoicesSettings is')->where('is.year = ?', date('Y'))->andWhere('is.isp_id = ?', $isp_id)->limit(1)->execute(array(), Doctrine_Core::HYDRATE_ARRAY); $record = array_shift($record); if ($record['setting_id'] > 0) { return Doctrine_Query::create()->update('InvoicesSettings')->set('next_number', $current_invoice_number + $increment)->where('year = ?', date('Y'))->andWhere('isp_id = ?', $isp_id)->execute(); } $InvoicesSettings = new self(); $InvoicesSettings->next_number = $current_invoice_number + $increment; $InvoicesSettings->year = date('Y'); $InvoicesSettings->isp_id = $isp_id; $InvoicesSettings->save(); }
/** * Index page * * @param void * @return null */ function index() { js_assign('invoicing_precision', INVOICE_PRECISION); $this->wireframe->addBreadCrumb(lang('Invoicing'), assemble_url('admin')); $this->wireframe->addBreadCrumb(lang('Number Generator'), assemble_url('admin_invoicing_number')); // prepare javascript variables and counters for preview $pattern = Invoices::getInvoiceNumberGeneratorPattern(); list($total_counter, $year_counter, $month_counter) = Invoices::getDateInvoiceCounters(); $total_counter++; $year_counter++; $month_counter++; $variable_year = date('Y'); $variable_month = date('n'); $variable_month_short = date('M'); $variable_month_long = date('F'); js_assign('pattern_variables', array(INVOICE_VARIABLE_CURRENT_YEAR => $variable_year, INVOICE_VARIABLE_CURRENT_MONTH => $variable_month, INVOICE_VARIABLE_CURRENT_MONTH_SHORT => $variable_month_short, INVOICE_VARIABLE_CURRENT_MONTH_LONG => $variable_month_long, INVOICE_NUMBER_COUNTER_TOTAL => $total_counter, INVOICE_NUMBER_COUNTER_YEAR => $year_counter, INVOICE_NUMBER_COUNTER_MONTH => $month_counter)); $generator_data = $this->request->post('generator'); if (!is_foreachable($generator_data)) { $generator_data = array('pattern' => Invoices::getinvoiceNumberGeneratorPattern()); } // if $this->smarty->assign(array('generator_data' => $generator_data)); if ($this->request->isSubmitted()) { $errors = new ValidationErrors(); $posted_pattern = array_var($generator_data, 'pattern', null); if (!trim($posted_pattern)) { $errors->addError(lang('Pattern is required'), 'pattern'); } // if if (strpos($posted_pattern, INVOICE_NUMBER_COUNTER_TOTAL) === false && strpos($posted_pattern, INVOICE_NUMBER_COUNTER_YEAR) === false && strpos($posted_pattern, INVOICE_NUMBER_COUNTER_MONTH) === false) { $errors->addError(lang('One of invoice counters is required (:total, :year, :month)', array('total' => INVOICE_NUMBER_COUNTER_TOTAL, 'year' => INVOICE_NUMBER_COUNTER_YEAR, 'month' => INVOICE_NUMBER_COUNTER_MONTH)), 'pattern'); } // if if ($errors->hasErrors()) { $this->smarty->assign(array('errors' => $errors)); } else { Invoices::setInvoiceNumberGeneratorPattern($posted_pattern); flash_success('Pattern for invoice number generator is saved'); $this->redirectTo('admin'); } // if } // if }
public function init() { // Set the custom decorator $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); $translate = Shineisp_Registry::get('Zend_Translate'); $this->addElement('text', 'creationdate', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Date'), 'title' => $translate->_('eg: 01/11/2010'), 'decorators' => array('Bootstrap'), 'class' => 'form-control date', 'dateformat' => Settings::getJsDateFormat())); $this->addElement('select', 'invoice_id', array('label' => $translate->_('Invoice'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('invoice_id')->setAllowEmpty(false)->setMultiOptions(Invoices::getList()); $this->addElement('text', 'number', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Number'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'total_net', array('filters' => array('StringTrim', 'LocalizedToNormalized'), 'label' => $translate->_('Total Net'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'total_vat', array('filters' => array('StringTrim', 'LocalizedToNormalized'), 'label' => $translate->_('Total VAT'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'total', array('filters' => array('StringTrim', 'LocalizedToNormalized'), 'label' => $translate->_('Total'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('textarea', 'note', array('filters' => array('StringTrim'), 'label' => $translate->_('Note'), 'decorators' => array('Bootstrap'), 'class' => 'col-lg-12 form-control')); ############################### DETAILS ############################# $this->addElement('text', 'quantity', array('filters' => array('StringTrim', 'LocalizedToNormalized'), 'label' => $translate->_('Quantity'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'description', array('filters' => array('StringTrim'), 'label' => $translate->_('Description'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'vat', array('filters' => array('StringTrim', 'LocalizedToNormalized'), 'label' => $translate->_('VAT'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'price', array('filters' => array('StringTrim', 'LocalizedToNormalized'), 'label' => $translate->_('Price'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('submit', 'save', array('required' => false, 'label' => $translate->_('Save'), 'decorators' => array('Bootstrap'), 'class' => 'btn')); $this->addElement('hidden', 'creditnote_id'); }
/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete($id) { if (Yii::app()->request->isPostRequest) { // we only allow deletion via POST request $model = $this->loadModel($id); if (null == Invoices::model()->findByAttributes(array('template_id' => (int) $id))) { if ($model->delete()) { $msg = 'Шаблон счета #' . $model->id . ' - ' . $model->name . ' удалён'; Yii::app()->user->setFlash('success', $msg); Yii::app()->logger->write($msg); } } else { Yii::app()->user->setFlash('notice', 'Удаление невозможно. Шаблон счета #' . $model->id . ' - ' . $model->name . ' используется!'); } // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if (!isset($_GET['ajax'])) { $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); } } else { throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); } }
/** * Show billed / canceled company invoices * * @param void * @return null */ function company() { $status = $this->request->get('status') ? $this->request->get('status') : 'billed'; $company = null; $company_id = $this->request->getId('company_id'); if ($company_id) { $company = Companies::findById($company_id); } // if if (instance_of($company, 'Company')) { $this->wireframe->addBreadCrumb($company->getName(), assemble_url('company_invoices', array('company_id' => $company->getId()))); } else { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if ($status == 'canceled') { $invoices = group_invoices_by_currency(Invoices::findByCompany($company, array(INVOICE_STATUS_CANCELED), 'closed_on DESC')); } else { $invoices = group_invoices_by_currency(Invoices::findByCompany($company, array(INVOICE_STATUS_BILLED), 'closed_on DESC')); } // if $this->smarty->assign(array('company' => $company, 'invoices' => $invoices, 'status' => $status)); }
if (isset($_GET['id']) && is_numeric($_GET['id']) && $_GET['id']) { $logContent = 'Invoice Paid for InvoiceID:' . $_GET['id']; # Update DB $invoicesUpdate = new Invoices(); $invoicesUpdate->setInvoicesid($_GET['id']); $invoicesUpdate->setPaid(time()); $invoicesUpdate->updateDB(); $logresult = logEvent(26, $logContent); $done = 1; } } if (isset($_GET['go']) && $_GET['go'] == "undopaid") { if (isset($_GET['id']) && is_numeric($_GET['id']) && $_GET['id']) { $logContent = 'Invoice marked UNPaid for InvoiceID:' . $_GET['id']; # Update DB $invoicesUpdate = new Invoices(); $invoicesUpdate->setInvoicesid($_GET['id']); $invoicesUpdate->setPaid(0); $invoicesUpdate->updateDB(); $logresult = logEvent(26, $logContent); $done = 1; } } // Define elements for the HTML Header include $pagetitle = "Home"; $pagescript = array(); $pagestyle = array(); $query = isset($_GET['q']) && $_GET['q'] != '' ? $_GET['q'] : ''; $custid = isset($_GET['custid']) && is_numeric($_GET['custid']) && $_GET['custid'] > 0 ? $_GET['custid'] : ''; include "../tmpl/header.php"; ?>
/** * Issue invoice * * @param void * @return null */ function issue() { $this->wireframe->print_button = false; if ($this->active_invoice->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if (!$this->active_invoice->canIssue($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $company = $this->active_invoice->getCompany(); if (!instance_of($company, 'Company')) { $this->httpError(HTTP_ERR_CONFLICT); } // if $issue_data = $this->request->post('issue'); if (!is_array($issue_data)) { $issue_data = array('issued_on' => new DateValue(), 'due_on' => new DateValue('+7 days')); } // if $company_managers = Users::findCompanyManagers($company); if (empty($company_managers)) { $this->wireframe->addPageMessage(lang('Sorry, there\'s nobody in :company_name to whom we can email the invoice', array('company_name' => $company->getName())), 'warning'); } // if $this->smarty->assign(array('company_managers' => $company_managers, 'users' => $company->getUsers(), 'company' => $company, 'issue_data' => $issue_data)); if ($this->request->isSubmitted()) { db_begin_work(); $issued_on = isset($issue_data['issued_on']) ? new DateValue($issue_data['issued_on']) : new DateValue(); $due_on = isset($issue_data['due_on']) ? new DateValue($issue_data['due_on']) : null; $this->active_invoice->setStatus(INVOICE_STATUS_ISSUED, $this->logged_user, $issued_on); if ($due_on) { $this->active_invoice->setDueOn($due_on); } // if $issue_to = null; $user_id = array_var($issue_data, 'user_id'); if ($user_id) { $user = Users::findById($user_id); if (instance_of($user, 'User')) { $this->active_invoice->setIssuedToId($user->getId()); $issue_to = array($user); if ($user->getId() != $this->logged_user->getId()) { $issue_to[] = $this->logged_user; } // if } // if } // if $autogenerated = false; if (!$this->active_invoice->getNumber()) { $autogenerated = true; $this->active_invoice->setNumber($this->active_invoice->generateInvoiceId()); } // if $save = $this->active_invoice->save(); if ($save && !is_error($save)) { if ($autogenerated) { Invoices::incrementDateInvoiceCounters(); } // if if (isset($issue_data['send_emails']) && $issue_data['send_emails']) { if ($issue_to) { $filename_name = 'invoice_' . $this->active_invoice->getId() . '.pdf'; $filename = WORK_PATH . '/' . $filename_name; require_once INVOICING_MODULE_PATH . '/models/InvoicePdf.class.php'; InvoicePDF::save($this->active_invoice, $filename); ApplicationMailer::send($issue_to, 'invoicing/issue', array('issued_by_name' => $this->logged_user->getDisplayName(), 'issued_by_url' => $this->logged_user->getViewUrl(), 'invoice_number' => $this->active_invoice->getNumber(), 'invoice_url' => $this->active_invoice->getCompanyViewUrl(), 'pdf_url' => $this->active_invoice->getCompanyPdfUrl()), null, array(array('path' => $filename))); @unlink($filename); } // if } // if db_commit(); flash_success('Invoice has been issued'); $this->redirectToUrl($this->active_invoice->getViewUrl()); } else { db_rollback(); $this->smarty->assign('errors', $issue); } // if } // if }
/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete($id) { if (Yii::app()->request->isPostRequest) { // we only allow deletion via POST request $model = $this->loadModel($id); if (Payments::model()->count('order_id=' . $id) !== 0) { $transaction = Yii::app()->db->beginTransaction(); try { Contracts::model()->deleteAll('order_id=' . $id); Acts::model()->deleteAll('order_id=' . $id); Invoices::model()->deleteAll('order_id=' . $id); InvoicesFkt::model()->deleteAll('order_id=' . $id); Works::model()->deleteAll('order_id=' . $id); $msg = 'Заказ #' . $model->id . ' - ' . $model->name . ' для ' . $model->client->name . ' и документы по нему удалёны'; $model->delete(); $transaction->commit(); Yii::app()->user->setFlash('success', $msg); Yii::app()->logger->write($msg); } catch (Exception $e) { $transaction->rollBack(); $msg = 'Заказ #' . $model->id . ' - ' . $model->name . ' для ' . $model->client->name . ' - удаление не удалось'; Yii::app()->user->setFlash('error', $msg); Yii::app()->logger->write($msg); } } else { $msg = 'Заказ #' . $model->id . ' - ' . $model->name . ' для ' . $model->client->name . ' - удаление невозможно. По этому заказу уже были проведены платежи'; Yii::app()->user->setFlash('notice', $msg); Yii::app()->logger->write($msg); } // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if (!isset($_GET['ajax'])) { $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); } } else { throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); } }
public function actionChangeOrder() { $return_msg = ''; // Dumper::d($_POST['order_id']);die; if (Yii::app()->request->isAjaxRequest) { if (is_numeric($_POST['order_id'])) { $q = Invoices::model()->listData((int) $_POST['order_id']); if (count($q) > 0) { foreach ($q as $key => $value) { $haOptions[] = array('value' => $key, 'text' => $value); } $return_msg = json_encode($haOptions); } else { $return_msg = json_encode('no'); } } else { $return_msg = '[{"value":"","text":"Некорректный формат запроса"}]'; } } else { $return_msg = '[{"value":"",text:"Некорректный формат запроса"}]'; } echo $return_msg; }
<?php require_once './classes/Invoice.php'; $invoice = new Invoices(); $list = $invoice->get_send_invoice_page(); echo $list;
/** * Show company invoices * * @param void * @return null */ function index() { $per_page = 30; $page = (int) $this->request->get('page'); if ($page < 1) { $page = 1; } // if $status = $this->request->get('status') ? $this->request->get('status') : 'active'; if ($status == 'active') { $invoice_status = INVOICE_STATUS_ISSUED; } else { if ($status == 'paid') { $invoice_status = INVOICE_STATUS_BILLED; } else { if ($status == 'canceled') { $invoice_status = INVOICE_STATUS_CANCELED; } } } // if list($invoices, $pagination) = Invoices::paginateByCompany($this->active_company, array($invoice_status), $page, $per_page, 'due_on ASC, created_on DESC'); $this->smarty->assign(array('invoices' => $invoices, 'pagination' => $pagination, 'status' => $status)); }
public function actionpayredirect() { if (!isset($_POST['id_bank'])) { Yii::app()->user->setFlash('error', Yii::t('translation', 'Please select a bank')); $this->redirect(Yii::app()->request->baseUrl . "/deposit/"); } if (isset($_POST['amount']) && ($_POST['amount'] <= 0 or $_POST['amount'] > 10000)) { Yii::app()->user->setFlash('error', Yii::t('translation', 'The amount cant be zero or more than 10000')); $this->redirect(Yii::app()->request->baseUrl . "/deposit/"); } if (isset($_POST['id_bank']) && isset($_POST['amount'])) { if ($_POST['amount'] <= 0 or $_POST['amount'] > 10000 or $_POST['id_bank'] == "") { Yii::app()->user->setFlash('error', Yii::t('translation', 'Invalid amount or bank')); $this->redirect(Yii::app()->request->baseUrl . "/deposit/"); } $user = Yii::app()->user->data(); $tran = new Transaction(); $tran->id_user = $user->id; $tran->status = 0; $tran->type = 1; $tran->amount = $_POST['amount']; $tran->currency = "MXN"; $tran->descr = "Deposito de pesos en tu cuenta usando astropay"; $tran->save(); $invo = new Invoices(); $invo->id_user = $user->id; $invo->invoice_number = dechex(time()); $invo->amount = $_POST['amount']; $invo->status = 0; $invo->id_bank = $_POST['id_bank']; $invo->name_bank = "Bank Test"; $invo->id_country = "MX"; $invo->id_currency = "MXN"; $invo->descr = "Deposit via Astropay"; $invo->id_cpf = ""; $invo->id_sub_code = ""; $invo->id_trans = $tran->id_trans; $invo->save(); $return_url = "http://mercadobtx.com/deposit/return"; $confirmation_url = "http://mercadobtx.com/deposit/confirm"; $apd = new AstroPayDirect(); $jdata = $apd->create($invo->invoice_number, $invo->amount, $user->id, $invo->id_bank, $invo->id_country, $invo->id_currency, $invo->descr, $invo->id_cpf, $invo->id_sub_code, $return_url, $confirmation_url, $response_type = 'json'); $dat = json_decode($jdata); if ($dat->{"status"} == "OK") { $this->redirect($dat->{"link"}); } else { Yii::app()->user->setFlash('error', Yii::t('translation', 'Returned error from Astropay') . " " . $dat->{"desc"}); $this->redirect(Yii::app()->request->baseUrl . "/deposit/"); } } $this->redirect(Yii::app()->request->baseUrl . "/deposit/"); }
<?php require_once './classes/Invoice.php'; $invoice = new Invoices(); $item = $_POST['item']; $list = $invoice->search_invoice($item, true); echo $list;
<?php require_once './classes/Invoice.php'; $invoice = new Invoices(); $page = $_POST['id']; $list = $invoice->get_paid_invoice_item($page); echo $list;
<?php require_once './classes/Invoice.php'; $invoice = new Invoices(); $id = $_POST['id']; $list = $invoice->get_any_invoice_courses_by_category($id); echo $list;
<?php require_once './classes/Invoice.php'; $invoice = new Invoices(); $list = $invoice->get_invoice_crednetials(); echo $list;
<?php require_once './classes/Invoice.php'; $invoice = new Invoices(); $id = $_POST['id']; $list = $invoice->get_any_invoice_users($id); echo $list;
<?php require_once './classes/Invoice.php'; $id = $_POST['id']; $invoice = new Invoices(); $list = $invoice->get_invoice_course_by_category($id); echo $list;
<?php //Get a set of invoices // SELECT * FROM invoices foreach (Invoices::find() as $invoice) { //Get the customer related to the invoice // SELECT * FROM customers WHERE id = ? $customer = $invoice->customer; //Print his/her name echo $customer->name, "\n"; }
<?php require_once './classes/Invoice.php'; $invoice = new Invoices(); $phone = $_POST['phone']; $fax = $_POST['fax']; $email = $_POST['email']; $site = $_POST['site']; $list = $invoice->update_invoice_crednetials($phone, $fax, $email, $site); echo $list;
<?php require_once './classes/Invoice.php'; $invoice = new Invoices(); $total = $invoice->get_open_invoices_total(); $list = $invoice->get_open_invoices(); echo $list; ?> <script type="text/javascript"> $(document).ready(function () { $(function () { $('#pagination').pagination({ items: <?php echo $total; ?> , itemsOnPage: <?php echo $invoice->limit; ?> , cssStyle: 'light-theme' }); }); $("#pagination").click(function () { var page = $('#pagination').pagination('getCurrentPage'); console.log('Page: ' + page); var url = "/lms/custom/invoices/get_open_invoice_item.php";
<?php //Get some invoice $invoice = Invoices::findFirst(); //Get the customer related to the invoice $customer = $invoice->customer; // Invoices::findFirst('...'); //Same as above $customer = $invoice->getCustomer(); // Invoices::findFirst('...');
<?php require_once './classes/Invoice.php'; $invoice = new Invoices(); $invoice_id = $_POST['invoice_id']; $type = $_POST['type']; $users_list = $_POST['users_list']; $list = $invoice->attach_any_invoice_payment($invoice_id, $type, $users_list);
/** * Creates a new model. */ public function actionCreate() { // create Comments Object $model = new Comments(); // if Comments form exist if (isset($_POST['Comments'])) { // set form elements to Comments model attributes $model->attributes = $_POST['Comments']; $module = Modules::model()->find(array('condition' => 't.module_name = :module_name', 'params' => array(':module_name' => $model->module_id))); // set module_id finded to model $model->module_id = $module->module_id; $project = Yii::app()->user->getState('project_selected'); $model->project_id = $project; // validate and save if ($model->save()) { // create an instance of file uploaded $image = CUploadedFile::getInstancesByName('Comment'); // if file upload exist if (count($image > 0)) { // for each file uploaded for ($i = 0; $i < count($image); $i++) { // create an Document object $modeldocs = new Documents(); $modeldocs->image = $image[$i]; if (!$modeldocs->image->getError()) { // name is formed by date(day+month+year+hour+minutes+seconds+dayofyear+microtime()) $this->tmpFileName = str_replace(" ", "", date('dmYHis-z-') . microtime()); // set the extension file uploaded $extension = $modeldocs->image->getExtensionName(); // if no error saving file if ($modeldocs->image->saveAs(self::FOLDERIMAGES . $this->tmpFileName . '.' . $extension)) { $modeldocs->project_id = $project; $modeldocs->document_name = substr($modeldocs->image->getName(), 0, 30); $modeldocs->document_description = $model->comment_text; $modeldocs->document_path = self::FOLDERIMAGES . $this->tmpFileName . '.' . $extension; $modeldocs->document_revision = '1'; $modeldocs->document_uploadDate = date("Y-m-d"); $modeldocs->document_type = $modeldocs->image->getType(); $modeldocs->document_baseRevision = date('dmYHis'); $modeldocs->user_id = Yii::app()->user->id; $modeldocs->comment_id = $model->primaryKey; // save file uploaded as document if ($modeldocs->save()) { Yii::app()->user->setFlash('CommentMessageSuccess', $modeldocs->image->getName() . " " . Yii::t('comments', 'UploadOk')); } else { Yii::app()->user->setFlash('CommentMessage', $modeldocs->getErrors()); } } else { Yii::app()->user->setFlash('CommentMessage', $modeldocs->image->getName() . " " . Yii::t('comments', 'UploadError')); } } else { Yii::app()->user->setFlash('CommentMessage', $modeldocs->image->error . " " . Yii::t('comments', 'UploadCheckErrors')); } } } // save log $attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'CommentPosted', 'log_resourceid' => $model->comment_resourceid, 'log_type' => Logs::LOG_COMMENTED, 'log_commentid' => $model->primaryKey, 'user_id' => Yii::app()->user->id, 'module_id' => $module->module_name, 'project_id' => $project); Logs::model()->saveLog($attributes); // find project managers to sent comment via mail $recipientsList = array(); $ProjectManagers = Projects::model()->findManagersByProject($project); $managersArray = array(); foreach ($ProjectManagers as $manager) { $managersArray['email'] = $manager->user_email; $managersArray['name'] = $manager->CompleteName; array_push($recipientsList, $managersArray); } // find task owners to send comment via mail if ($module->module_name == 'tasks') { $collaborators = Projects::model()->findAllUsersByProject($project); $ColaboratorsArray = array(); foreach ($collaborators as $colaborator) { $ColaboratorsArray['email'] = $colaborator->user_email; $ColaboratorsArray['name'] = $colaborator->CompleteName; // avoid to repeat email address if (!in_array($ColaboratorsArray, $recipientsList)) { array_push($recipientsList, $ColaboratorsArray); } } } // finding resource title switch ($module->module_name) { case "budgets": $resourceModelTitle = Budgets::model()->findByPk($model->comment_resourceid)->budget_title; break; case "invoices": $resourceModelTitle = Invoices::model()->findByPk($model->comment_resourceid)->invoice_number; break; case "expenses": $resourceModelTitle = Expenses::model()->findByPk($model->comment_resourceid)->expense_name; break; case "documents": $resourceModelTitle = Documents::model()->findByPk($model->comment_resourceid)->document_name; break; case "milestones": $resourceModelTitle = Milestones::model()->findByPk($model->comment_resourceid)->milestone_title; break; case "cases": $resourceModelTitle = Cases::model()->findByPk($model->comment_resourceid)->case_name; break; case "tasks": $resourceModelTitle = Tasks::model()->findByPk($model->comment_resourceid)->task_name; break; default: $resourceModelTitle = "{empty}"; break; } // get project information $project = Projects::model()->findByPk($project); // prepare template to send via email $str = $this->renderPartial('//templates/comments/created', array('model' => $model, 'projectName' => $project->project_name, 'userposted' => Yii::app()->user->CompleteName, 'resourceTitle' => $resourceModelTitle, 'moduleName' => Yii::t('modules', $module->module_name), 'applicationName' => Yii::app()->name, 'applicationUrl' => Yii::app()->createAbsoluteUrl($module->module_name . '/view', array('id' => $model->comment_resourceid))), true); Yii::import('application.extensions.phpMailer.yiiPhpMailer'); $mailer = new yiiPhpMailer(); $subject = Yii::t('email', 'CommentPosted') . " - " . $project->project_name . " - " . Yii::t('modules', $module->module_name); $mailer->pushMail($subject, $str, $recipientsList, Emails::PRIORITY_NORMAL); } else { Yii::app()->user->setFlash('CommentMessage', Yii::t('comments', 'RequiredComment')); } } $this->redirect(Yii::app()->createUrl($_GET['module'] . '/' . $_GET['action'], array('id' => $_GET['id'], '#' => 'comment-' . $model->primaryKey))); }
/** * Generates invoice id by invoice pattern * * @param null * @return string */ function generateInvoiceId() { // retrieve pattern $pattern = Invoices::getInvoiceNumberGeneratorPattern(); // retrieve counters list($total_counter, $year_counter, $month_counter) = Invoices::getDateInvoiceCounters(); $total_counter++; $year_counter++; $month_counter++; // retrieve variables $variable_year = date('Y'); $variable_month = date('n'); $variable_month_short = date('M'); $variable_month_long = date('F'); $generated_invoice_id = str_ireplace(array(INVOICE_NUMBER_COUNTER_TOTAL, INVOICE_NUMBER_COUNTER_YEAR, INVOICE_NUMBER_COUNTER_MONTH, INVOICE_VARIABLE_CURRENT_YEAR, INVOICE_VARIABLE_CURRENT_MONTH, INVOICE_VARIABLE_CURRENT_MONTH_SHORT, INVOICE_VARIABLE_CURRENT_MONTH_LONG), array($total_counter, $year_counter, $month_counter, $variable_year, $variable_month, $variable_month_short, $variable_month_long), $pattern); return $generated_invoice_id; }