function assign_jobs() { global $smarty; global $db; $db->run('get_jobs_customer(' . $_SESSION['customer_id'] . ')'); if ($db->error_result) { display_error(1); return true; } $jobs = $db->get_result_array(); if (empty($jobs)) { $smarty->assign('job_message', 'Im Moment sind keine Aufträge vorhanden.'); return true; } $db->run('get_job_status_customer(' . $_SESSION['customer_id'] . ')'); if ($db->error_result) { display_errors(1); return true; } $job_status = $db->get_result_array(); foreach ($jobs as $j_key => $job) { foreach ($job_status as $js_key => $status) { if ($job['job_id'] == $status['job_id']) { $jobs[$j_key]['status'][] = $status; } } } $smarty->assign('jobs', $jobs); return true; }
public function insert($values) { $keys = array(); $vals = array(); foreach ($values as $key => $value) { if (in_array($key, $this->columns_name)) { $keys[] = $key; $key_type = $this->columns[$key]; switch ($key_type) { case 'text': $value = str_replace('\\r\\n', '<br>', $value); $vals[] = mysql_real_escape_string(htmlentities($value), $this->database->getConnection()); break; case 'int': $vals[] = is_numeric($value) ? $value : 0; break; default: // Check for varchar_64 $varchar_split = explode('_', $key_type); if ($varchar_split[0] == 'varchar') { $vals[] = substr($value, 0, $varchar_split[1]); break; } display_error("The key type '{$key_type}' is not defined in the loop"); break; } } else { display_error("The key '{$key}' does not exist in table '{$this->name}'"); return false; } } $sql = 'INSERT INTO ' . $this->name . ' (`' . implode('`, `', $keys) . '`) VALUES("' . implode('", "', $vals) . '");'; return $this->database->query($sql); }
function check_data() { global $check_price_charged_vs_order_price, $check_qty_charged_vs_del_qty; if (!check_num('this_quantity_inv', 0) || input_num('this_quantity_inv') == 0) { display_error(tr("The quantity to invoice must be numeric and greater than zero.")); set_focus('this_quantity_inv'); return false; } if (!check_num('ChgPrice')) { display_error(tr("The price is not numeric.")); set_focus('ChgPrice'); return false; } if ($check_price_charged_vs_order_price == True) { if ($_POST['order_price'] != input_num('ChgPrice')) { if ($_POST['order_price'] == 0 || input_num('ChgPrice') / $_POST['order_price'] > 1 + sys_prefs::over_charge_allowance() / 100) { display_error(tr("The price being invoiced is more than the purchase order price by more than the allowed over-charge percentage. The system is set up to prohibit this. See the system administrator to modify the set up parameters if necessary.") . tr("The over-charge percentage allowance is :") . sys_prefs::over_charge_allowance() . "%"); set_focus('ChgPrice'); return false; } } } if ($check_qty_charged_vs_del_qty == True) { if (input_num('this_quantity_inv') / ($_POST['qty_recd'] - $_POST['prev_quantity_inv']) > 1 + sys_prefs::over_charge_allowance() / 100) { display_error(tr("The quantity being invoiced is more than the outstanding quantity by more than the allowed over-charge percentage. The system is set up to prohibit this. See the system administrator to modify the set up parameters if necessary.") . tr("The over-charge percentage allowance is :") . sys_prefs::over_charge_allowance() . "%"); set_focus('this_quantity_inv'); return false; } } return true; }
function can_delete($selected_id) { $sql = "SELECT COUNT(*) FROM stock_moves WHERE loc_code='{$selected_id}'"; $result = db_query($sql, "could not query stock moves"); $myrow = db_fetch_row($result); if ($myrow[0] > 0) { display_error(tr("Cannot delete this location because item movements have been created using this location.")); return false; } $sql = "SELECT COUNT(*) FROM workorders WHERE loc_code='{$selected_id}'"; $result = db_query($sql, "could not query work orders"); $myrow = db_fetch_row($result); if ($myrow[0] > 0) { display_error(tr("Cannot delete this location because it is used by some work orders records.")); return false; } $sql = "SELECT COUNT(*) FROM cust_branch WHERE default_location='{$selected_id}'"; $result = db_query($sql, "could not query customer branches"); $myrow = db_fetch_row($result); if ($myrow[0] > 0) { display_error(tr("Cannot delete this location because it is used by some branch records as the default location to deliver from.")); return false; } return true; }
public function sendmail($to_name, $to_email, $from_name = '', $from_email = '', $subject, $body, $altbody = '') { if ($from_name == '') { $from_name = APPLICATION_NAME; } if ($from_email == '') { $from_email = APPLICATION_EMAIL; } if (!$subject) { display_system("The subject has not been set"); } else { if (!$body) { display_system("The body has not been set"); } else { $this->mailer->From = $from_email; $this->mailer->FromName = $from_name; $this->mailer->AddAddress($to_email, $to_name); $this->mailer->AddBCC($from_email, $from_name); $this->mailer->IsHTML(true); if ($body == '') { $this->mailer->IsHTML(false); } $this->mailer->Subject = $subject; $this->mailer->Body = $body; $this->mailer->AltBody = $altbody; if (!$this->mailer->Send()) { display_error("The email from " . $from_name . " (" . $from_email . ") to " . $to_name . " (" . $to_email . ") could not be sent. The mailer replied with the following error :: " . $this->mailer->ErrorInfo . ".<br />The contents of the email were as follows :<br /><b>" . $subject . "</b><br />" . $body . ""); return false; } // Need to do this, otherwise recipients will keep adding up $this->mailer->ClearAllRecipients(); return true; } } }
function can_process() { global $selected_id; if ($selected_id == -1) { if (!references::is_valid($_POST['ref'])) { display_error(tr("The dimension reference must be entered.")); set_focus('ref'); return false; } if (!is_new_reference($_POST['ref'], systypes::dimension())) { display_error(tr("The entered reference is already in use.")); set_focus('ref'); return false; } } if (strlen($_POST['name']) == 0) { display_error(tr("The dimension name must be entered.")); set_focus('name'); return false; } if (!is_date($_POST['date_'])) { display_error(tr("The date entered is in an invalid format.")); set_focus('date_'); return false; } if (!is_date($_POST['due_date'])) { display_error(tr("The required by date entered is in an invalid format.")); set_focus('due_date'); return false; } return true; }
function try_add_user($login, $pass, $pass2, $realname, $session, $is_admin, $antispam) { $return_val = false; // Help prevent robot registrations if (!check_antispam($antispam)) { display_error("Invalid security code"); } else { if ($session != md5(session_id() . $_SERVER['REMOTE_ADDR'])) { display_error("Invalid session."); } else { if ($pass != $pass2) { display_warning("Password mismatch"); } else { if ($realname == '' || $pass == '' || $pass2 == '' || $login == '') { display_warning("Please fill out all fields"); } else { if (get_user_id($login) > 0) { display_error("The user <strong>{$login}</strong> already exists."); } else { add_user($login, $realname, $pass, $is_admin); $return_val = display_success("<strong>{$login}</strong> has been successfully created"); } } } } } return $return_val; }
function check_data() { $total_allocated = 0; for ($counter = 0; $counter < $_POST["TotalNumberOfAllocs"]; $counter++) { if (!check_num('amount' . $counter)) { display_error(tr("The entry for one or more amounts is invalid.")); set_focus('amount' . $counter); return false; } if (!check_num('amount' . $counter, 0)) { display_error(tr("The entry for an amount to allocate was negative. A positive allocation amount is expected.")); set_focus('amount' . $counter); return false; } /*Now check to see that the AllocAmt is no greater than the amount left to be allocated against the transaction under review */ if (input_num('amount' . $counter) > $_POST['un_allocated' . $counter]) { //$_POST['amount' . $counter] = $_POST['un_allocated' . $counter]; } $_SESSION['alloc']->allocs[$counter]->current_allocated = input_num('amount' . $counter); $total_allocated += input_num('amount' . $counter); } if ($total_allocated - $_SESSION['alloc']->amount > sys_prefs::allocation_settled_allowance()) { display_error(tr("These allocations cannot be processed because the amount allocated is more than the total amount left to allocate.")); //echo tr("Total allocated:") . " " . $total_allocated ; //echo " " . tr("Total amount that can be allocated:") . " " . -$_SESSION['alloc']->TransAmt . "<BR>"; return false; } return true; }
function can_process() { if (!check_num('po_over_receive', 0, 100)) { display_error(_("The delivery over-receive allowance must be between 0 and 100.")); set_focus('po_over_receive'); return false; } if (!check_num('po_over_charge', 0, 100)) { display_error(_("The invoice over-charge allowance must be between 0 and 100.")); set_focus('po_over_charge'); return false; } if (!check_num('past_due_days', 0, 100)) { display_error(_("The past due days interval allowance must be between 0 and 100.")); set_focus('past_due_days'); return false; } $grn_act = get_company_pref('grn_clearing_act'); if (get_post('grn_clearing_act') != $grn_act && db_num_rows(get_grn_items(0, '', true))) { display_error(_("Before GRN Clearing Account can be changed all GRNs have to be invoiced")); $_POST['grn_clearing_act'] = $grn_act; set_focus('grn_clearing_account'); return false; } if (!is_account_balancesheet(get_post('retained_earnings_act')) || is_account_balancesheet(get_post('profit_loss_year_act'))) { display_error(_("The Retained Earnings Account should be a Balance Account or the Profit and Loss Year Account should be an Expense Account (preferred the last one in the Expense Class)")); return false; } return true; }
function check_can_delete($curr) { if ($curr == "") { return false; } // PREVENT DELETES IF DEPENDENT RECORDS IN debtors_master if (key_in_foreign_table($curr, 'debtors_master', 'curr_code')) { display_error(_("Cannot delete this currency, because customer accounts have been created referring to this currency.")); return false; } if (key_in_foreign_table($curr, 'suppliers', 'curr_code')) { display_error(_("Cannot delete this currency, because supplier accounts have been created referring to this currency.")); return false; } if ($curr == get_company_pref('curr_default')) { display_error(_("Cannot delete this currency, because the company preferences uses this currency.")); return false; } // see if there are any bank accounts that use this currency if (key_in_foreign_table($curr, 'bank_accounts', 'bank_curr_code')) { display_error(_("Cannot delete this currency, because thre are bank accounts that use this currency.")); return false; } return true; }
function on_submit($selected_parent, $selected_id = -1) { if (!check_num('quantity', 0)) { display_error(_("The quantity entered must be numeric and greater than zero.")); set_focus('quantity'); return; } if ($selected_id != -1) { update_bom($selected_parent, $selected_id, $_POST['workcentre_added'], $_POST['loc_code'], input_num('quantity')); display_notification(_('Selected component has been updated')); $Mode = 'RESET'; } else { /*Selected component is null cos no item selected on first time round so must be adding a record must be Submitting new entries in the new component form */ //need to check not recursive bom component of itself! if (!check_for_recursive_bom($selected_parent, $_POST['component'])) { /*Now check to see that the component is not already on the bom */ if (!is_component_already_on_bom($_POST['component'], $_POST['workcentre_added'], $_POST['loc_code'], $selected_parent)) { add_bom($selected_parent, $_POST['component'], $_POST['workcentre_added'], $_POST['loc_code'], input_num('quantity')); display_notification(_("A new component part has been added to the bill of material for this item.")); $Mode = 'RESET'; } else { /*The component must already be on the bom */ display_error(_("The selected component is already on this bom. You can modify it's quantity but it cannot appear more than once on the same bom.")); } } else { display_error(_("The selected component is a parent of the current item. Recursive BOMs are not allowed.")); } } }
public function debit() { $this->fondos_model->extract(CFG_COSTO_CUENTAPLUS); $user_id = $this->session->userdata('user_id'); $date_end = add_date(date('d-m-Y'), 0, 0, CFG_TIME_CUENTAPLUS); $query = $this->db->get_where(TBL_CUENTAPLUS, array('user_id' => $user_id)); if ($query->num_rows == 0) { $sql = "INSERT INTO " . TBL_CUENTAPLUS . "(user_id, date_start, date_end) VALUES("; $sql .= $user_id . ","; $sql .= "now(),"; $sql .= "'" . $date_end . "'"; $sql .= ")"; if (!$this->db->query($sql)) { display_error(__FILE__, "debit", ERR_DB_INSERT, array(TBL_CUENTAPLUS)); } } else { $sql = "UPDATE " . TBL_CUENTAPLUS . " SET "; $sql .= "date_start = now(),"; $sql .= "date_end = '" . $date_end . "' "; $sql .= "WHERE user_id=" . $user_id; if (!$this->db->query($sql)) { display_error(__FILE__, "debit", ERR_DB_UPDATE, array(TBL_CUENTAPLUS)); } } return true; }
function can_process() { $Auth_Result = hook_authenticate($_SESSION["wa_current_user"]->username, $_POST['cur_password']); if (!isset($Auth_Result)) { // if not used external login: standard method $Auth_Result = get_user_auth($_SESSION["wa_current_user"]->username, md5($_POST['cur_password'])); } if (!$Auth_Result) { display_error(_("Invalid password entered.")); set_focus('cur_password'); return false; } if (strlen($_POST['password']) < 4) { display_error(_("The password entered must be at least 4 characters long.")); set_focus('password'); return false; } if (strstr($_POST['password'], $_SESSION["wa_current_user"]->username) != false) { display_error(_("The password cannot contain the user login.")); set_focus('password'); return false; } if ($_POST['password'] != $_POST['passwordConfirm']) { display_error(_("The passwords entered are not the same.")); set_focus('password'); return false; } return true; }
function can_process() { if (strlen($_POST['CustName']) == 0) { display_error(_("The customer name cannot be empty.")); set_focus('CustName'); return false; } if (strlen($_POST['cust_ref']) == 0) { display_error(_("The customer short name cannot be empty.")); set_focus('cust_ref'); return false; } if (!check_num('credit_limit', 0)) { display_error(_("The credit limit must be numeric and not less than zero.")); set_focus('credit_limit'); return false; } if (!check_num('pymt_discount', 0, 100)) { display_error(_("The payment discount must be numeric and is expected to be less than 100% and greater than or equal to 0.")); set_focus('pymt_discount'); return false; } if (!check_num('discount', 0, 100)) { display_error(_("The discount percentage must be numeric and is expected to be less than 100% and greater than or equal to 0.")); set_focus('discount'); return false; } return true; }
public function sign_in() { // retrieve local parameters $user_name = mysql_escape_string($this->_parameters['user_name']); $password = mysql_escape_string($this->_parameters['password']); if (empty($user_name)) { display_error(100); } else { if (empty($password)) { display_error(102); } } // check credentials $signIn = mysql_query("SELECT user_id FROM users WHERE user_name='" . $user_name . "' AND password='******' AND status='Approved' LIMIT 1"); $checkIfPending = mysql_query("SELECT user_id FROM users WHERE user_name='" . $user_name . "' AND password='******' AND status='Pending' LIMIT 1"); if (mysql_num_rows($checkIfPending) > 0) { display_error(107); } else { if (mysql_num_rows($signIn) == 0) { display_error(106); } else { $userInfo = mysql_fetch_array($signIn); $data = array("user_id" => $userInfo['user_id']); display_success($data); } } }
function check_data() { global $Refs; if (!is_date($_POST['date'])) { display_error(_("The entered date is invalid.")); set_focus('date'); return false; } if (!is_date_in_fiscalyear($_POST['date'])) { display_error(_("The entered date is not in fiscal year.")); set_focus('date'); return false; } if (!$Refs->is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); set_focus('ref'); return false; } if (!is_new_reference($_POST['ref'], ST_JOURNAL)) { display_error(_("The entered reference is already in use.")); set_focus('ref'); return false; } return true; }
function can_process() { if (strlen($_POST['fname']) == 0) { display_error(_("First name cannot be empty.")); set_focus('code'); return false; } if (strlen($_POST['lname']) == 0) { display_error(_("Last name cannot be empty.")); set_focus('code'); return false; } if (strlen($_POST['address']) == 0) { display_error(_("Address cannot be empty.")); set_focus('code'); return false; } if (strlen($_POST['contact_number']) == 0) { display_error(_("Contact number cannot be empty.")); set_focus('code'); return false; } if (strlen($_POST['email_address']) == 0) { display_error(_("Email address cannot be empty.")); set_focus('code'); return false; } return true; }
function upgrade_step($index, $conn) { global $path_to_root, $installers; $inst = $installers[$index]; $pref = $conn['tbpref']; $ret = true; $force = get_post('force_' . $index); if ($force || get_post('install_' . $index)) { $state = $inst->installed($pref); if (!$state || $force) { if (!$inst->pre_check($pref, $force)) { return false; } $sql = $inst->sql; error_log(sprintf(_("Database upgrade for company '%s' (%s:%s*) started..."), $conn['name'], $conn['dbname'], $conn['tbpref'])); if ($sql != '') { $ret &= db_import($path_to_root . '/sql/' . $sql, $conn, $force); } $ret &= $inst->install($pref, $force); error_log(_("Database upgrade finished.")); } else { if ($state !== true) { display_error(_("Upgrade cannot be done because database has been already partially upgraded. Please downgrade database to clean previous version or try forced upgrade.")); $ret = false; } } } return $ret; }
function can_process() { if (!is_date($_POST['CreditDate'])) { display_error(tr("The entered date is invalid.")); set_focus('CreditDate'); return false; } elseif (!is_date_in_fiscalyear($_POST['CreditDate'])) { display_error(tr("The entered date is not in fiscal year.")); set_focus('CreditDate'); return false; } if ($_SESSION['Items']->trans_no == 0) { if (!references::is_valid($_POST['ref'])) { display_error(tr("You must enter a reference.")); set_focus('ref'); return false; } if (!is_new_reference($_POST['ref'], 11)) { display_error(tr("The entered reference is already in use.")); set_focus('ref'); return false; } } if (!check_num('ChargeFreightCost', 0)) { display_error(tr("The entered shipping cost is invalid or less than zero.")); set_focus('ChargeFreightCost'); return false; } return true; }
function create_recurrent_invoices($customer_id, $branch_id, $order_no, $tmpl_no, $date, $from, $to) { global $Refs; $doc = new Cart(ST_SALESORDER, array($order_no)); get_customer_details_to_order($doc, $customer_id, $branch_id); $doc->trans_type = ST_SALESORDER; $doc->trans_no = 0; $doc->document_date = $date; $doc->due_date = get_invoice_duedate($doc->payment, $doc->document_date); $doc->reference = $Refs->get_next($doc->trans_type); if ($doc->Comments != "") { $doc->Comments .= "\n"; } $doc->Comments .= sprintf(_("Recurrent Invoice covers period %s - %s."), $from, add_days($to, -1)); foreach ($doc->line_items as $line_no => $item) { $line =& $doc->line_items[$line_no]; $line->price = get_price($line->stock_id, $doc->customer_currency, $doc->sales_type, $doc->price_factor, $doc->document_date); } $cart = $doc; $cart->trans_type = ST_SALESINVOICE; $cart->reference = $Refs->get_next($cart->trans_type); $invno = $cart->write(1); if ($invno == -1) { display_error(_("The entered reference is already in use.")); display_footer_exit(); } update_last_sent_recurrent_invoice($tmpl_no, $to); return $invno; }
/** * renders a view template using twig and passes needed data to the view * @param string $view | the view template file * @param array $data | array of parametres passed to the view */ public function view($view, $data = []) { /** * specifies the views directory for twig * @var object */ $loader = new \Twig_Loader_Filesystem(Config::get('paths.views')); /** * twig templating engine instance * @var object */ $twig = new \Twig_Environment($loader); /** * contains additional stuff needed to be present in the view * @var array */ $additionals = ['base' => Config::get('app.url'), 'home' => Config::get('app.url') . '/home']; /** * contains the result of mergin the passed data from the model & the additional stuff * @var array */ $passed_to_view = array_merge($data, $additionals); // render the template if it exists if (file_exists(Config::get('paths.views') . '/' . $view . '.html')) { echo $twig->render($view . '.html', $passed_to_view); } else { display_error('View file "' . $view . '" does not exist!'); } }
function display_errors($error_array) { foreach (explode('.', $error_array) as $key => $value) { if (!empty($value)) { display_error($value); } } }
public function __construct($duration = '', $location = '') { $this->duration = $duration != '' ? $duration : CACHE_TIME; $this->location = $location != '' ? $location : '/app/cache'; if (perms($this->location) != '777') { display_error('Please make your cache writable by running the following command $ chmod -R 777 ' . path($this->location)); } }
function check_journal_entry(&$entry, $entryid) { // Check that this journal entry adds up! if (abs($entry->gl_items_total()) > 0.0001) { display_error("Error: journal entry with entryid '{$entryid}' does not balance (import file: '{$_FILES['imp']['name']}')"); return true; } }
function can_delete($selected_id) { if (key_in_foreign_table($selected_id, 'debtors_master', 'credit_status')) { display_error(_("Cannot delete this credit status because customer accounts have been created referring to it.")); return false; } return true; }
function can_delete($selected_id) { if (key_in_foreign_table($selected_id, 'tax_group_items', 'tax_type_id')) { display_error(_("Cannot delete this tax type because tax groups been created referring to it.")); return false; } return true; }
function can_delete($selected_id) { if (movement_types_in_stock_moves($selected_id)) { display_error(_("Cannot delete this inventory movement type because item transactions have been created referring to it.")); return false; } return true; }
function can_delete($selected_id) { if (requisitions_in_details($selected_id)) { display_error(_("Cannot delete this requisition because details transactions have been created referring to it.")); return false; } return true; }
function can_delete($selected_id) { if (asset_types_in_assets($selected_id)) { display_error(_("Cannot delete this asset type because assets transactions have been created referring to it.")); return false; } return true; }
function can_process() { if (strlen($_POST['sales_type']) == 0) { display_error(tr("The sales type description cannot be empty.")); return false; } return true; }