function entrySetReady($entry) { global $invoice_sendto, $systemurl, $login; if (!count($entry)) { echo __('No entry found.'); return FALSE; } /* * Set new status * Set new rev_num, time of edit, etc */ $rev_num = $entry['rev_num'] + 1; mysql_query("UPDATE `entry` SET `invoice_status` = '2', `user_last_edit` = '" . $login['user_id'] . "', `time_last_edit` = '" . time() . "', `rev_num` = '{$rev_num}' WHERE `entry_id` = '" . $entry['entry_id'] . "' LIMIT 1 ;"); $log_data = array(); if (!newEntryLog($entry['entry_id'], 'edit', 'invoice_readyfor', $rev_num, $log_data)) { echo __('Can\'t log the changes for the entry.'); echo '<br><br>'; return FALSE; } if (isset($invoice_sendto) && is_array($invoice_sendto)) { $entry_summary = 'Bookingid: ' . $entry['entry_id'] . chr(10); $area = getArea($entry['area_id']); if (count($area)) { foreach ($invoice_sendto as $email) { emailSendDirect($email, 'Booking klar til fakturering - ' . $area['area_name'] . ', ' . date('d.m.Y', $entry['time_start']) . ' (' . $entry['entry_id'] . ')', 'Hei' . chr(10) . chr(10) . $login['user_name'] . ' har satt en ny booking, fra ' . $area['area_name'] . ', klar til fakturering. Bookingen var fra ' . date('d.m.Y', $entry['time_start']) . '.' . chr(10) . chr(10) . 'Gå inn på følgende adresse for å få tilsendt fakturagrunnlagene:' . chr(10) . $systemurl . '/invoice_tobemade_ready.php' . chr(10) . 'Hvis det er flere fakturaer som er klar til fakturering, så kan samtlige hentes ut på likt.' . chr(10) . chr(10) . 'Oppsummert booking:' . chr(10) . 'Bookingid: ' . $entry['entry_id'] . chr(10) . 'Tittel: ' . html_entity_decode($entry['entry_name']) . chr(10) . 'Anlegg: ' . $area['area_name'] . chr(10) . 'Sum eks mva: kr ' . smarty_modifier_commify($entry['eks_mva_tot'], 2, ',', ' ') . chr(10) . ' + MVA kr ' . smarty_modifier_commify($entry['faktura_belop_sum_mva'], 2, ',', ' ') . chr(10) . 'Sum ink. mva: kr ' . smarty_modifier_commify($entry['faktura_belop_sum'], 2, ',', ' ') . chr(10) . chr(10) . 'Mvh. Bookingsystemet'); } } } return TRUE; }
function entrySetReady($entry) { if (!count($entry)) { echo _('No entry found.'); return FALSE; } /* * Set new status * Set new rev_num, time of edit, etc */ $rev_num = $entry['rev_num'] + 1; mysql_query("UPDATE `entry` SET `invoice_status` = '2', `user_last_edit` = '" . $login['user_id'] . "', `time_last_edit` = '" . time() . "', `rev_num` = '{$rev_num}' WHERE `entry_id` = '" . $entry['entry_id'] . "' LIMIT 1 ;"); $log_data = array(); if (!newEntryLog($entry['entry_id'], 'edit', 'invoice_readyfor', $rev_num, $log_data)) { echo _('Can\'t log the changes for the entry.'); echo '<br><br>'; return FALSE; } return TRUE; }
} $pdf_invoicedata = array(); $from = null; $to = null; foreach ($entries as $entry) { /* * Set new status * Set new rev_num, time of edit, etc */ $rev_num = $entry['rev_num'] + 1; // Add to entry_invoiced mysql_query("INSERT INTO `entry_invoiced` (`entry_id` , `invoiced_id`) VALUES ('" . $entry['entry_id'] . "', '" . $invoiced_id . "');"); // Updating invoice status mysql_query("UPDATE `entry` " . "SET " . "`invoice_status` = '3', " . "`user_last_edit` = '" . $login['user_id'] . "', " . "`time_last_edit` = '" . time() . "', " . "`rev_num` = '{$rev_num}', " . "`invoice_exported_time` = '" . time() . "' " . " WHERE `entry_id` = '" . $entry['entry_id'] . "' LIMIT 1 ;"); $log_data = array(); if (!newEntryLog($entry['entry_id'], 'edit', 'invoice_exported', $rev_num, $log_data)) { } if (is_null($from) || $from > $entry['time_start']) { $from = $entry['time_start']; } if (is_null($to) || $to < $entry['time_end']) { $to = $entry['time_end']; } // Generate PDF data $smarty = new Smarty(); templateAssignEntry('smarty', $entry); templateAssignEntryChanges('smarty', $entry, $entry['rev_num']); templateAssignSystemvars('smarty'); $invoicedata[] = $smarty->fetch('file:fakturagrunnlag.tpl'); } if (count($entries) != 1) {
if ($confirm_pdf == '1') { if (emailSendConfirmationPDF($entry, $email, $confirm_pdffile, $attachments, $confirm_txt)) { $log_data['emailPDF' . $i] = $email; } else { $log_data['emailPDF_faild' . $i] = $email; } } else { if (emailSendConfirmation($entry, $email, $confirm_txt)) { $log_data['email' . $i] = $email; } else { $log_data['email_faild' . $i] = $email; } } $i++; } if (!newEntryLog($entry['entry_id'], 'edit', 'confirm', $rev_num, $log_data)) { echo _('Can\'t log the changes for the entry.'); exit; } // Log usage of attachments foreach ($attachments as $att) { mysql_query("\n\t\tINSERT INTO `entry_confirm_usedatt` (\n\t\t\t`confirm_id` ,\n\t\t\t`att_id` ,\n\t\t\t`timeused`\n\t\t)\n\t\tVALUES (\n\t\t\t'" . $log_data['confirm_id'] . "', \n\t\t\t'" . $att['att_id'] . "', \n\t\t\t'" . time() . "'\n\t\t);"); } /* if(isset($_POST['save_template']) && $_POST['save_template'] == '1') { // Saving template as $_POST['save_template_as'] $save_template_as = ''; if(isset($_POST['save_template_as'])) { $save_template_as = slashes(htmlspecialchars(strip_tags($_POST['save_template_as']),ENT_QUOTES)); }
unset($log_data['mva_grunnlag']); unset($log_data['mva_grunnlag_sum']); unset($log_data['faktura_belop_sum']); unset($log_data['faktura_belop_sum_mva']); unset($log_data['eks_mva_tot']); unset($log_data['grunnlag_mva_tot']); unset($log_data['mva_vis']); unset($log_data['customer_name']); unset($log_data['time_day']); unset($log_data['time_month']); unset($log_data['time_year']); unset($log_data['time_hour']); unset($log_data['time_min']); unset($log_data['invoice_locked']); unset($log_data['entry_id']); newEntryLog($entry['entry_id'], 'edit', $log_action2, $entry['rev_num'] + 1, $log_data); // Verify that it is copied $q = mysql_query('select entry_id from ' . $to_table . ' where `entry_id` = \'' . $entry['entry_id'] . '\' limit 1'); if (mysql_error()) { emailSendAdmin('Problems in entry_delete', 'Mysql error on verify query:' . chr(10) . mysql_error() . chr(10)); echo 'En feil oppsto. Feilmelding er sendt til systemadministrator.<br />'; echo 'Sletting vil ikke være tilgjengelig før dette er fikset.'; exit; } if (!mysql_num_rows($q)) { emailSendAdmin('Problems in entry_delete', 'Entry id ' . $entry['entry_id'] . ' is not in ' . $to_table . ' after copying.' . chr(10)); echo 'En feil oppsto. Feilmelding er sendt til systemadministrator.<br />'; echo 'Sletting vil ikke være tilgjengelig før dette er fikset.'; exit; } // Deleting
$only_invoice_changed = true; $log_data = array(); foreach ($changed2 as $change) { if ($change == 'user_assigned' || $change == 'room_id') { $log_data[$change] = splittalize(${$change}); } elseif ($change == "customer_municipal") { // Ignore } else { $log_data[$change] = ${$change}; } // Only invoice changes? if (substr($change, 0, 7) != 'invoice') { $only_invoice_changed = false; } } if (!newEntryLog($entry_id, 'edit', '', $rev_num, $log_data)) { echo __('Can\'t log the changes for the entry.'); exit; } // iCal // TODO: Jobb med ical og gw //send_iCal($entry_id); // no more... if (!$only_invoice_changed) { // Sending email to other users that are assigned // $user_assigned = the new once // $entry['user_assigned'] = the old once $user_in_both = array(); $user_deleted = array(); $user_new = array(); foreach ($user_assigned as $user_id) {
function register_payment($payment_time, $payment_amount, $payment_comment) { if (!$this->sjekk_hentstatus()) { return FALSE; // Feil oppsto } /* ## SJEKKER ULIKE TING ## */ // Behandler tidspunktet $str2 = array(); $str = ''; for ($i = 0; $i < strlen($payment_time); $i++) { $char = $payment_time[$i]; if (is_numeric($char)) { $str .= $char; } else { $str2[] = $str; $str = ''; } } if ($str != '') { $str2[] = $str; } if (count($str2) != 3) { $this->error_code = '106'; // Ugyldig dato for betalingstidspunktet. return FALSE; } $payment_amount = str_replace(',', '.', $payment_amount); $payment_amount = round((double) $payment_amount, 2); if ($payment_amount < 0) { $this->error_code = '107'; // Det kan ikke registeres minus-betalinger return FALSE; } $this->invoice_time_payed = mktime(0, 0, 0, $str2[1], $str2[0], $str2[2]); $this->invoice_payed_amount += $payment_amount; if ($this->invoice_payed_amount >= $this->invoice_topay_total) { $this->invoice_payed = 1; } else { $this->invoice_payed = 0; } $SQL = "UPDATE `invoice` SET \n\t\t\t`invoice_time_payed`\t= '" . $this->invoice_time_payed . "',\n\t\t\t`invoice_payed`\t\t\t= '" . $this->invoice_payed . "',\n\t\t\t`invoice_payed_amount`\t= '" . $this->invoice_payed_amount . "'\n\t\t\tWHERE `invoice_id` ='" . $this->invoice_id . "' LIMIT 1 ;"; $log_data = array(); $log_data['invoice_time_payed'] = $this->invoice_time_payed; $log_data['invoice_payed'] = $this->invoice_payed; $log_data['invoice_payment_amount'] = $payment_amount; $log_data['invoice_payment_comment'] = htmlspecialchars($payment_comment, ENT_QUOTES); mysql_query($SQL); if (mysql_error()) { $this->error_code = '1'; return FALSE; } newInvoiceLog($this->invoice_id, 'edit', 'invoice_payed', 1, $log_data); /* Linked to any entries? */ foreach ($this->invoice_idlinks as $link) { list($idtype, $id) = explode('=', $link); switch ($idtype) { case 'e': // Entry $entry = getEntry($id); if (count($entry)) { /* * Set new status * Set new rev_num, time of edit, etc */ $rev_num = $entry['rev_num'] + 1; mysql_query("UPDATE `entry` SET `invoice_status` = '4', `user_last_edit` = '" . $this->invoice_created_by_id . "', `time_last_edit` = '" . time() . "', `rev_num` = '{$rev_num}' WHERE `entry_id` = '" . $entry['entry_id'] . "' LIMIT 1 ;"); $log_data = array(); if (!newEntryLog($entry['entry_id'], 'edit', 'invoice_payed', $rev_num, $log_data)) { } } break; default: // Do nothing break; } } return TRUE; }