function compare_invoices_transaction($op) { $indic = false; $amount = str_replace(',', '.', $op->montant); $tva = getTVA(); $f = 1 + $tva / 100; $min = $amount / $f - 0.1; $max = $amount / $f + 0.1; // S'il s'agit d'un crédit, tenter de retrouver la facture correspondante // $q = "SELECT id_facture, is_paye, date_facture, num_facture, ref_contrat, total_facture_ht, 1.196*total_facture_ht as total_facture FROM wf_view_invoices ". // "WHERE total_facture_ht>=%s AND total_facture_ht<=%s "; $q = "SELECT " . "wf_in.id_facture, " . "is_paye, " . "date_facture, " . "num_facture, " . "ref_contrat, " . "SUM(qtt * prix_ht) as total_facture_ht, " . "{$f}*SUM(qtt * prix_ht) as total_facture " . "FROM webfinance_invoices wf_in , webfinance_invoice_rows wf_in_rows " . "WHERE wf_in_rows.id_facture=wf_in.id_facture " . "AND " . "( " . "SELECT SUM( qtt * prix_ht ) as total_facture_ht " . "FROM webfinance_invoice_rows, webfinance_invoices " . "WHERE webfinance_invoice_rows.id_facture = webfinance_invoices.id_facture " . "AND webfinance_invoice_rows.id_facture=wf_in.id_facture " . "GROUP BY webfinance_invoice_rows.id_facture " . ") " . "BETWEEN '%s' AND '%s' " . "GROUP BY id_facture"; $query = sprintf($q, $min, $max); $result = mysql_query($query) or wf_mysqldie(); if (mysql_num_rows($result) < 1) { print "<b style=\"color: red;\">Impossible de trouver la facture correspondante à ce virement ! Incohérence dans les factures ou paiement erroné !</b><br/>"; } else { while ($invoice = mysql_fetch_assoc($result)) { //print_r($invoice); if ($invoice['is_paye'] < 1) { printf("<b style=\"color: green;\">%s</b><br/>", _('The related invoice is found, it\'s unpaid!')); printf("<input type='hidden' name='date_tr[%d]' value='%s'>", $invoice['id_facture'], $op->date); printf("<input type='hidden' name='id_tr[%d]' value='%s'>", $invoice['id_facture'], $op->id); printf("<input type='checkbox' name='invoices[]' value='%d' >", $invoice['id_facture']); $indic = true; } else { printf("<b style=\"color: green;\">%s</b><br/>", _('The related invoice is found, it\'s paid!')); } printf("<a href='../prospection/edit_facture.php?id_facture=%d' target='_blank' ><span style='background-color: rgb(255, 102, 102);'>#%s : %s : %s€ : %s </span></a><br/>", $invoice['id_facture'], $invoice['num_facture'], $invoice['ref_contrat'], round($invoice['total_facture'], 3), strftime($invoice['date_facture'])); } } return $indic; }
function renum($id_facture, $id_facture_ligne, $order = 'DESC') { $sens = $order == 'DESC' ? '<=' : '>='; $query = sprintf("SELECT id_facture_ligne, ordre " . "FROM webfinance_invoice_rows " . "WHERE id_facture = %d " . "AND ordre %s (" . " SELECT ordre " . " FROM webfinance_invoice_rows " . " WHERE id_facture_ligne = %d " . ") " . "ORDER BY ordre %s LIMIT 2", $id_facture, $sens, $id_facture_ligne, $order); $result = mysql_query($query); if (mysql_num_rows($result) != 2) { return false; } $query = "UPDATE webfinance_invoice_rows " . "SET ordre = %d " . "WHERE id_facture_ligne = %d "; mysql_query(sprintf($query, mysql_result($result, 0, "ordre"), mysql_result($result, 1, "id_facture_ligne"))) or wf_mysqldie(); mysql_query(sprintf($query, mysql_result($result, 1, "ordre"), mysql_result($result, 0, "id_facture_ligne"))) or wf_mysqldie(); }
function renum() { $result = mysql_query("SELECT id_facture FROM webfinance_invoice_rows") or wf_mysqldie(); while (list($id_facture) = mysql_fetch_array($result)) { $count = 1; $result2 = mysql_query("SELECT id_facture_ligne FROM webfinance_invoice_rows WHERE id_facture={$id_facture} ORDER BY ordre") or wf_mysqldie(); while (list($id_facture_ligne) = mysql_fetch_array($result2)) { mysql_query("UPDATE webfinance_invoice_rows SET ordre={$count} WHERE id_facture_ligne={$id_facture_ligne}") or wf_mysqldie(); $count += 2; } mysql_free_result($result2); } mysql_free_result($result); }
function show_file($id_transaction, $type) { $result = mysql_query("SELECT " . "file, " . "file_type as type, " . "file_name as name " . "FROM webfinance_{$type} " . "WHERE id=" . $id_transaction) or wf_mysqldie(); if (mysql_num_rows($result) > 0) { $afile = mysql_fetch_assoc($result); mysql_free_result($result); $file_name = $afile['name']; $file_type = $afile['type']; $file = $afile['file']; header('Content-type: $file_type'); header("Content-Disposition: attachment; filename={$file_name}"); echo $file; //echo base64_decode($afile['file']); } else { echo "File not found"; } exit; }
function _getInfos() { $query = sprintf(self::getRequest() . "WHERE c.id_client = %d", $this->id); $result = $this->SQL(sprintf($query, $this->id)) or wf_mysqldie("Client::_getInfos"); if (mysql_num_rows($result)) { $data = mysql_fetch_assoc($result); foreach ($data as $n => $v) { $this->{$n} = $v; } $this->emails = explode(',', $this->email); mysql_free_result($result); } // If user specified data in the siren field it can be either the RCS number // (format 9 digits) or the INSEE code (format : same 9 digits + 5 digits for // address identifier). // See : https://fr.wikipedia.org/wiki/Codes_INSEE // sensible default value $this->link_societe = sprintf('<a href="http://www.societe.com/cgi-bin/liste?nom=%s&dep=%s"> <img src="/imgs/icons/societe.com.gif" class="bouton" onMouseOut="UnTip();" onmouseover="Tip(\'%s\');" /></a>', isset($this->nom) ? urlencode($this->nom) : '', isset($this->departement) ? $this->departement : '', addslashes(_('Cannot link to societe.com if no RCS or siren specified. Click icon to perform a search.'))); if (isset($this->siren) and $this->siren != "") { // Trim non-digits from value $this->siren = preg_replace("/[^0-9]/", "", $this->siren); switch (strlen($this->siren)) { case 9: // RCS $this->link_societe = sprintf('<a href="http://www.societe.com/cgi-bin/recherche?rncs=%s"><img src="/imgs/icons/societe.com.gif" class="bouton" onMouseOut="UnTip();" onmouseover="Tip(\'%s\');" /></a>', $this->siren, addslashes(_('See financial info about this company on Societe.com'))); $this->siren = preg_replace("!([0-9]{3})([0-9]{3})([0-9]{3})!", '\\1 \\2 \\3', $this->siren); break; case 14: // INSEE $this->link_societe = sprintf('<a href="http://www.societe.com/cgi-bin/recherche?rncs=%s"><img src="/imgs/icons/societe.com.gif" class="bouton" onMouseOut="UnTip();" onmouseover="Tip(\'%s\');" /></a>', substr($this->siren, 0, 9), addslashes(_('See financial info about this company on Societe.com'))); $this->siren = preg_replace("!([0-9]{3})([0-9]{3})([0-9]{3})([0-9]{5})!", '\\1 \\2 \\3 \\4', $this->siren); break; } } $this->login = ""; if (isset($this->id_user) and $this->id_user > 0) { $login_res = $this->SQL("SELECT login FROM webfinance_users WHERE id_user=" . $this->id_user); if (mysql_num_rows($login_res) > 0) { list($this->login) = mysql_fetch_array($login_res); } } }
<input type="hidden" name="action" value="select"/> <tr style="text-align: center;" class="row_header"> <td width="80"><?php echo _('Transaction'); ?> </td> <td colspan="3"> <form action="expenses.php" id="main_form" onchange="this.submit();"> <select class="form" name="id_transaction"> <option> ------------------ <?php echo _('Select a transaction'); ?> ------------------ </option> <?php $result = mysql_query("SELECT id, date, text FROM webfinance_transactions ORDER BY date DESC") or wf_mysqldie(); while ($transaction = mysql_fetch_assoc($result)) { $len = 80; $text = $transaction['text']; if (strlen($transaction['text']) >= $len) { $text = substr($text, 0, $len) . " ..."; } ?> <option value="<?php echo $transaction['id']; ?> " <?php if ($_GET['id_transaction'] == $transaction['id']) { echo "selected"; } ?>
function logmessage($msg, $id_client = 'NULL', $id_facture = 'NULL') { $id = empty($_SESSION['id_user']) ? -1 : $_SESSION['id_user']; $msg = preg_replace("/'/", "\\'", $msg); $msg = preg_replace('/"/', "\\'", $msg); $query = sprintf("INSERT INTO webfinance_userlog " . " (log,date,id_user,id_client,id_facture) VALUES('%s', now(), %s, %s, %s) ", $msg, $id, $id_client, $id_facture); mysql_query($query) or wf_mysqldie(); }
function createUser($data = null) { if (!$this->isAuthorized('admin,manager')) { $_SESSION['message'] = _("You aren't the Administrator"); $_SESSION['error'] = 1; return false; } extract($data); if (!isset($disabled)) { $disabled = 'off'; } $roles = implode(",", $data['role']); if ($this->existsLogin($login)) { $_SESSION['message'] = _("Sorry, this user already exists!"); $_SESSION['error'] = 1; return -1; } else { if (empty($password)) { $password = $this->randomPass(); } $q = sprintf("INSERT INTO webfinance_users (login, first_name, last_name, password, email, role, disabled, modification_date, creation_date) " . "VALUES('%s', '%s', '%s', md5('%s'), '%s','%s', %d, now(), now() )", $login, $first_name, $last_name, $password, $email, $roles, $disabled == "on" ? 1 : 0); mysql_query($q) or wf_mysqldie(); $new_id_user = mysql_insert_id(); logmessage("Created new user user:{$new_id_user} ({$last_name} {$first_name})"); $_SESSION['message'] = _("User added"); return $new_id_user; } }
print "<form action='save_transaction.php' method='post'>"; print "<input type='hidden' name='action' value='update_invoices'>"; //recherche de la catégorie unknow $id_default_category = 1; $result = mysql_query("SELECT COUNT(*) , id FROM webfinance_categories WHERE name RLIKE 'unknown' GROUP BY id") or wf_mysqldie(); list($nb_matches, $id, $name) = mysql_fetch_array($result); if ($nb_matches == 1) { $id_default_category = $id; } foreach ($transactions as $op) { printf("Transaction de <b>%s€</b> du <b>%s</b> intitulée <i>%s</i><div style=\"font-size: 10px; border-left: solid 4px #ceceff; margin-left: 10px; padding-left: 10px;\">\n", $op->montant, $op->date, $op->desc); // Dans tous les cas on essaie de retrouver la catégorie de la transaction // automagiquement. //default id category $id_categorie = $id_default_category; $result = mysql_query("SELECT COUNT(*) , id , name FROM webfinance_categories WHERE re IS NOT NULL AND '" . addslashes($op->desc) . "' RLIKE re GROUP BY id") or wf_mysqldie(); list($nb_matches, $id, $name) = mysql_fetch_array($result); switch ($nb_matches) { case 0: print "<b style=\"color: orange;\">Aucune catégorie ne correspond, à vous de classer cette transaction</b><br/>"; break; case 1: print "<b style=\"color: green;\">Correspondance avec la catégorie « {$name} »</b><br/>"; $id_categorie = $id; break; default: print "<b style=\"color: orange;\">Plus d'une catégorie correspond, classement automatique impossible</b><br/>"; } // Insertion de la transaction $erreur = 0; $q = sprintf("INSERT INTO webfinance_transactions (text,id_account,amount,type,date, id_category, comment) " . "VALUES('%s', %d, '%s', 'real', STR_TO_DATE('%s', '%%d/%%m/%%Y'), %d, '%s')", $op->desc, $id_account, $op->montant, $op->date, $id_categorie, "ref: " . $op->ref . " " . $op->comment);
} else { $width = 700; } if (is_numeric($_GET['height'])) { $height = $_GET['height']; } else { $height = 300; } if (is_numeric($_GET['nb_months'])) { $nb_months = $_GET['nb_months']; } else { $nb_months = 12; } if (preg_match("!^[0-9]+(|,[0-9]+)\$!", $_GET['limit_clients'])) { // Matches 5 and 10,5 and nothing else $limit_clients = "LIMIT " . $_GET['limit_clients']; } else { $limit_clients = ""; } global $User; $bar = new barGraph($width, $height, $User->prefs->graphgrid); $bar->setFont($GLOBALS['_SERVER']['DOCUMENT_ROOT'] . "/css/themes/" . $User->prefs->theme . "/buttonfont.ttf"); $bar->setBarColor(103, 133, 195); # NBI blue $result = mysql_query("SELECT sum(fl.prix_ht*fl.qtt) as total, count(f.id_facture) as nb_factures, c.nom\n FROM webfinance_invoices as f, webfinance_invoice_rows as fl, webfinance_clients as c\n WHERE fl.id_facture=f.id_facture\n AND f.type_doc = 'facture'\n AND f.id_client = c.id_client\n AND f.date_facture>=DATE_SUB(now(), INTERVAL {$nb_months} MONTH)\n GROUP BY c.id_client\n ORDER BY total DESC\n {$limit_clients}") or wf_mysqldie(); $count = mysql_num_rows($result); while ($billed = mysql_fetch_object($result)) { $billed->total = sprintf("%d", $billed->total); $bar->addValue($billed->total, $count--, $billed->nom . "\n" . preg_replace("/\\./", ",", sprintf("%.1f", $billed->total / 1000)) . "K€", preg_replace("/\\./", ",", sprintf("%.1f", $billed->total / 1000)) . "K€"); } $bar->realise();
$var = explode("-", $start_date); $query_date_last_real = mysql_query("select UNIX_TIMESTAMP(max(date)) from webfinance_transactions where type='real' " . $query_account) or wf_mysqldie(); $date_last_real = mysql_result($query_date_last_real, 0); $q = "SELECT amount, type, date, UNIX_TIMESTAMP(date) as ts_date , id_account, exchange_rate FROM webfinance_transactions ORDER BY date "; $res = mysql_query($q) or wf_mysqldie(); $trs = array(); while ($row = mysql_fetch_assoc($res)) { if (empty($row['exchange_rate'])) { $row['exchange_rate'] = 1; } $row['amount'] = $row['amount'] / $row['exchange_rate']; $trs[] = $row; } mysql_free_result($res); $q_real = "SELECT amount, type, date, UNIX_TIMESTAMP(date) as ts_date, id_account, exchange_rate FROM webfinance_transactions WHERE type='real' ORDER BY date "; $res_real = mysql_query($q_real) or wf_mysqldie(); while ($row = mysql_fetch_assoc($res_real)) { if (empty($row['exchange_rate'])) { $row['exchange_rate'] = 1; } $row['amount'] = $row['amount'] / $row['exchange_rate']; $trs_real[] = $row; } mysql_free_result($res_real); for ($step = 0; $step <= $nb_day; $step++) { $current_date = mktime(0, 0, 0, $var[1], $var[2] + $step, $var[0]); $tmp[0] = $current_date; //prev $x = 0; $i = 0; $sum = 0;
switch ($_GET['sort']) { case "login": $critere = " login {$order} "; break; case "name": $critere = " first_name {$order}, last_name {$order} "; break; case "email": $critere = " email {$order} "; break; case "last_login": $critere = " last_login {$order}"; break; } } $result = mysql_query("SELECT first_name,last_name,id_user,email,login, role, date_format(last_login,'%d/%m/%Y') as nice_last_login\n FROM webfinance_users ORDER by " . $critere) or wf_mysqldie(); $count = 1; while ($user = mysql_fetch_object($result)) { $rowclass = $count % 2 == 0 ? "odd" : "even"; if ($user->role != 'client') { print <<<EOF <tr class="row_{$rowclass}"> <td style="text-align: center">{$user->login}</td> <td>{$user->first_name} {$user->last_name}</td> <td><a href="mailto:{$user->email}">{$user->email}</a></td> <td>{$user->nice_last_login}</td> <td> <a href="javascript:confirmDeleteUser({$user->id_user});"><img src="/imgs/icons/delete.png" alt="<?= _('Delete')?>" /></a> <a href="#" onclick="inpagePopup(event, this, 280, 260, 'edit_user.php?id={$user->id_user}{$link}');" ><img src="/imgs/icons/edit.png" alt="Modifier" /></a> </td> </tr>
if (!isset($width)) { $width = 500; } if (!isset($height)) { $height = 400; } if (!isset($hidetitle)) { $hidetitle = 0; } $query_account = ""; $text = ""; if (!empty($_GET['account'])) { $query_account = " AND id_account=" . $_GET['account']; $query = mysql_query("SELECT " . "MIN(date) as min , " . "UNIX_TIMESTAMP(MIN(date)) as ts_min , " . "MAX(date) as max , " . "UNIX_TIMESTAMP(MAX(date)) as ts_max " . "FROM webfinance_transactions WHERE id_account=" . $_GET['account']) or wf_mysqldie(); } else { $query = mysql_query("SELECT MIN(date) as min , " . "UNIX_TIMESTAMP(MIN(date)) as ts_min , " . "MAX(date) as max , " . "UNIX_TIMESTAMP(MAX(date)) as ts_max " . "FROM webfinance_transactions ") or wf_mysqldie(); } $res = mysql_fetch_assoc($query); if ($res['ts_min'] == 0) { $res['ts_min'] == mktime(); } if ($res['ts_max'] == 0) { $res['ts_max'] == mktime(); } if (isset($_GET['end_date']) and isset($_GET['start_date'])) { $end_date = $_GET['end_date']; $start_date = $_GET['start_date']; list($start_year, $start_month, $start_day) = explode("-", $start_date); list($end_year, $end_month, $end_day) = explode("-", $end_date); $start_date_ts = mktime(0, 0, 0, $start_month, $start_day, $start_year); $start_date = date("Y-m-d", $start_date_ts);
function getCurrency($id_bank) { $result = mysql_query("SELECT value FROM webfinance_pref WHERE id_pref={$id_bank}") or wf_mysqldie(); list($value) = mysql_fetch_array($result); $account = unserialize(base64_decode($value)); return array(isset($account->currency) ? $account->currency : "", isset($account->exchange) ? $account->exchange : ""); }
echo _('Taxe'); ?> </td> <td><?php echo _('Value'); ?> </td> <td><?php echo _('Actions'); ?> </td> </tr> <?php $txt = _('Confirm ?'); $result = mysql_query("SELECT id_pref, type_pref, value FROM webfinance_pref WHERE type_pref RLIKE '^taxe_'") or wf_mysqldie(); while ($c = mysql_fetch_assoc($result)) { extract($c); $taxe_name = preg_replace('/^taxe_/', '', $type_pref); print <<<EOF <tr class="row_even"> <td><input type="text" name="taxes[{$id_pref}][taxe]" value="{$taxe_name}" style="width: 100px;" /></td> <td><input type="text" name="taxes[{$id_pref}][value]" value="{$value}" style="width: 100px;" /></td> <td align="center"><a href="javascript:confirmDeleteTaxe({$id_pref},'{$txt}');"><img src="/imgs/icons/delete.gif" /></a> </tr> EOF; } ?> <tr style="background: #ceffce;"> <td><input type="text" name="taxes[new][taxe]" value="" style="width: 100px;" /></td> <td><input type="text" name="taxes[new][value]" value="" style="width: 100px;" /></td>
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ ?> <script type="text/javascript"> function confirmDeleteType(id, txt) { if (confirm(txt)) { window.location = 'save_preferences.php?action=type_presta_delete&id='+id; } } </script> <form action="save_preferences.php" id="main_form" method="post"> <input type="hidden" name="action" value="type_presta"/> <table border="0" cellspacing="0" cellpadding="3"> <?php $result = mysql_query("SELECT id_type_presta, nom\n FROM webfinance_type_presta\n ORDER BY nom") or wf_mysqldie(); while ($c = mysql_fetch_assoc($result)) { extract($c); $txt = _("Do you really want to delete it?"); print <<<EOF <tr class="row_even"> <td><input type="text" name="cat[{$id_type_presta}][nom]" value="{$nom}" style="width: 350px;" /></td> <td align="center"><a href="javascript:confirmDeleteType({$id_type_presta},'{$txt}');"><img src="/imgs/icons/delete.gif" /></a> </tr> EOF; } ?> <tr style="background: #ceffce;"> <td colspan="2"><input type="text" name="cat[new][nom]" value="" style="width: 350px;" /></td> </tr> <tr class="row_even">
// Get number of total pages for this filter : $result = WFO::SQL($q); $nb_transactions = mysql_num_rows($result); mysql_free_result($result); $q .= $limit_clause; $result = WFO::SQL($q); $filter_base = sprintf("sort=%d&filter[start_date]=%s&filter[end_date]=%s&filter[textsearch]=%s&filter[amount]=%s&view=%s", $_GET['sort'], $filter['start_date'], $filter['end_date'], isset($filter['textsearch']) ? $filter['textsearch'] : '', isset($filter['amount']) ? $filter['amount'] : '', $view); $result = WFO::SQL($q); $total_shown = 0; $count = 1; $prev_date = ""; $cur_date = $ts_start_date; while ($tr = mysql_fetch_object($result)) { //id des factures liées $id_invoices = array(); $result_invoices = mysql_query("SELECT id_invoice as id , num_facture , ref_contrat " . "FROM webfinance_transaction_invoice AS wf_tr_inv LEFT JOIN webfinance_invoices AS wf_inv ON (wf_tr_inv.id_invoice = wf_inv.id_facture) " . "WHERE wf_tr_inv.id_transaction=" . $tr->id) or wf_mysqldie(); while ($invoice_obj = mysql_fetch_object($result_invoices)) { $id_invoices[] = $invoice_obj; } mysql_free_result($result_invoices); //currency list($currency, $ex) = getCurrency($tr->id_account); if (empty($tr->exchange_rate)) { $tr->exchange_rate = 1; } //s�parer les mois $current_month = ucfirst(strftime("%B %Y", $tr->ts_date)); if (!empty($prev_date)) { if (date("m", $prev_date) != date("m", $tr->ts_date)) { echo "<tr class=\"row_even\"><td colspan='8' align='center'><b>{$current_month}</b></td></tr>"; }
</tr> <?php $order_clause = "color"; $sort = "color"; if (isset($_GET['sort']) and !empty($_GET['sort'])) { $sort = $_GET['sort']; switch ($_GET['sort']) { case 'color': // Sort by color is complicated since we store HTML colors like #ff0000 $order_clause = "HEX(MID(color, 1,2)),HEX(MID(color,3,2)),HEX(MID(color,5,2))"; break; default: $order_clause = $_GET['sort']; } } $result = mysql_query("SELECT id,name,comment,re,plan_comptable,color\n FROM webfinance_categories\n ORDER BY {$order_clause}") or wf_mysqldie(); $count = 1; while ($c = mysql_fetch_assoc($result)) { extract($c); $class = $count++ % 2 == 0 ? "even" : "odd"; $color_picker = sprintf('<input type="hidden" name="cat[%d][color]" id="color_%d" value="%s"><div id="couleur_%d" onclick="inpagePopup(event, this, 260, 240, \'/inc/color_picker.php?sample=couleur_%d&input=color_%d\');" onmouseover="return escape(\'Cliquez pour modifier la couleur.<br/>Actuellement : %s\');" style="width: 40px; height: 16px; background: %s"></div>', $id, $id, $color, $id, $id, $id, $color, $color); print <<<EOF <tr class="row_{$class}"> <td><input type="text" name="cat[{$id}][name]" value="{$name}" style="width: 130px;" /></td> <td><input type="text" name="cat[{$id}][re]" value="{$re}" style="width: 175px;" /></td> <td><input type="text" name="cat[{$id}][comment]" value="{$comment}" style="width: 175px;" /></td> <td><input type="text" name="cat[{$id}][plan_comptable]" value="{$plan_comptable}" style="text-align: center; width: 40px;" /></td> <td>{$color_picker}</td> <td><a href="javascript:confirmDelete({$id},'{$sort}');"><img src="/imgs/icons/delete.gif" /></a> <a href="index.php?filter[shown_cat][{$id}]='on'"><img src="/imgs/icons/zoom.gif" /></a></td> </tr> EOF;
?> </td> </tr> <?php //client // Search 'word boundaries' at // https://dev.mysql.com/doc/refman/5.0/en/regexp.html $clause = " log REGEXP '[[:<:]]client:{$_GET['id']}[[:>:]]\$' OR"; //invoices $result = mysql_query("SELECT id_facture FROM webfinance_invoices WHERE id_client=" . $_GET['id']) or wf_mysqldie(); while (list($id) = mysql_fetch_array($result)) { $clause .= " log REGEXP '[[:<:]]fa:{$id}" . "[[:>:]]' OR"; } $clause = preg_replace('/OR$/', '', $clause); //echo $clause; $result = mysql_query("SELECT id_userlog, log, date, wf_userlog.id_user, date_format(date,'%d/%m/%Y %k:%i') as nice_date, login " . "FROM webfinance_userlog wf_userlog, webfinance_users wf_users WHERE wf_users.id_user=wf_userlog.id_user " . "AND ({$clause}) " . "ORDER BY date DESC") or wf_mysqldie(); $count = 1; while ($log = mysql_fetch_object($result)) { $class = $count % 2 == 0 ? "odd" : "even"; $message = parselogline($log->log); print <<<EOF <tr class="row_{$class}"> <td>{$log->nice_date}</td> <td>{$message}</td> <td>{$log->login}</td> </tr> EOF; $count++; } mysql_free_result($result); ?>
<?php // Display some results // Search in clients if ($search_in['clients']) { $result = mysql_query("SELECT c.id_client,c.nom\n FROM webfinance_client AS c\n WHERE (\n c.nom LIKE '%{$q}%'\n )") or wf_mysqldie(); if (mysql_num_rows($result)) { $nb = mysql_num_rows($result); print "<h2>" . _('Results found in companies :') . "</h2>"; printf("<h3>" . _('%d invoice%s matching your search') . "</h3>", $nb, $nb > 1 ? "s" : ""); print '<ul class="search_results">'; print '</ul>'; } } // Search in invoices if ($search_in['invoices']) { $result = mysql_query("SELECT f.id_facture,id_client,sum(fl.qtt*fl.prix_ht) as total_facture,\n f.extra_top, f.extra_bottom, f.commentaire\n FROM webfinance_invoices AS f, webfinance_invoice_rows fl\n WHERE fl.id_facture=f.id_facture\n AND (\n f.extra_top LIKE '%{$q}%' OR\n f.extra_bottom LIKE '%{$q}%' OR\n f.num_facture LIKE '%{$q}%' OR\n f.commentaire LIKE '%{$q}%' OR\n fl.description LIKE '%{$q}%'\n ) GROUP BY f.id_facture") or wf_mysqldie(); if (mysql_num_rows($result)) { $nb = mysql_num_rows($result); print "<h2>" . _('Results found in invoices :') . "</h2>"; printf("<h3>" . _('%d invoice%s matching your search') . "</h3>", $nb, $nb > 1 ? "s" : ""); print '<ul class="search_results">'; while ($found = mysql_fetch_object($result)) { $invoice = new Facture(); $data = $invoice->getInfos($found->id_facture); print "<pre>"; print_r($data); print "</pre>"; } } } ?>
die("Argggl"); } if (is_numeric($_GET['width'])) { $width = $_GET['width']; } else { $width = 700; } if (is_numeric($_GET['height'])) { $height = $_GET['height']; } else { $height = 300; } if (is_numeric($_GET['nb_months'])) { $nb_months = $_GET['nb_months']; } else { $nb_months = 12; } global $User; $bar = new barGraph($width, $height, $User->prefs->graphgrid); $bar->setFont($GLOBALS['_SERVER']['DOCUMENT_ROOT'] . "/css/themes/" . $User->prefs->theme . "/buttonfont.ttf"); $bar->setBarColor(255, 92, 92); for ($i = $nb_months - 1; $i >= 0; $i--) { $result = mysql_query("SELECT date_format(date_sub(now(), INTERVAL {$i} MONTH), '%m/%y') as mois_shown, date_format(date_sub(now(), INTERVAL {$i} MONTH), '%Y%m') as mois"); list($mois_shown, $mois) = mysql_fetch_array($result); mysql_free_result($result); $result = mysql_query("SELECT sum(fl.prix_ht*fl.qtt) as total, count(f.id_facture) as nb_factures,\n date_format(f.date_facture, '%Y%m') as groupme, date_format(f.date_facture, '%m/%y') as mois\n FROM webfinance_invoices as f, webfinance_invoice_rows as fl\n WHERE fl.id_facture=f.id_facture\n AND f.type_doc = 'facture'\n AND f.is_paye=0\n AND f.id_client=" . $_GET['id_client'] . "\n AND date_format(f.date_facture,'%Y%m') = '{$mois}' GROUP BY groupme") or wf_mysqldie(); $billed = mysql_fetch_object($result); $billed->total = sprintf("%d", $billed->total); $bar->addValue($billed->total, $mois_shown, preg_replace("/\\./", ",", sprintf("%.1f", $billed->total / 1000)) . "K€"); } $bar->realise();
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Webfinance; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ include "../../inc/main.php"; $title = _("Paybox"); $roles = "manager,accounting,employee,client"; include "../../top.php"; //echo "<pre/>"; //print_r($_GET); $Invoice = new Facture(); if (isset($_GET['ref'])) { mysql_query("UPDATE webfinance_paybox SET state='cancel' WHERE reference='" . $_GET['ref'] . "'") or wf_mysqldie(); $_SESSION['message'] = _("The transaction is canceled"); header("Location: ../../client/"); exit; ?> <span class="text"> <?php echo _("The transaction is canceled"); ?> </span> <?php } else { ?> <span class="text"> <?php echo _("Wrong arguments");
Webfinance is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Webfinance is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Webfinance; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ $result = mysql_query("SELECT value FROM webfinance_pref WHERE type_pref='mail_quote_{$mail_tpl_lang}'") or wf_mysqldie(); list($data) = mysql_fetch_array($result); $pref = unserialize(base64_decode($data)); echo $language_form; ?> <form onchange="formChanged()" id="main_form" action="save_preferences.php" method="post"> <input type="hidden" name="action" value="mail_quote_<?php echo $mail_tpl_lang; ?> " /> <input type="hidden" name="mail_tpl_lang" value="<?php echo $mail_tpl_lang; ?> " /> <table border="0" cellspacing="7" cellpadding="0"> <tr>
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Webfinance; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // // This file is part of « Webfinance » // // Copyright (c) 2004-2006 NBI SARL // Author : Nicolas Bouthors <*****@*****.**> // // You can use and redistribute this file under the term of the GNU GPL v2.0 // // $Id: save_paybox.php 531 2007-06-13 12:32:31Z thierry $ require "../inc/main.php"; must_login(); $data = new stdClass(); $data->PBX_SITE = $_GET['PBX_SITE']; $data->PBX_RANG = $_GET['PBX_RANG']; $data->PBX_IDENTIFIANT = $_GET['PBX_IDENTIFIANT']; $data = base64_encode(serialize($data)); if ($_GET['id'] > 0) { mysql_query("UPDATE webfinance_pref SET value='{$data}' WHERE id_pref=" . $_GET['id']) or wf_mysqldie(); } else { mysql_query("INSERT INTO webfinance_pref SET type_pref='paybox', value='{$data}' ") or wf_mysqldie(); } header("Location: preferences.php?tab=Paybox"); exit;
exit; } $Client = new Client($_GET['id_client']); } #site $result = mysql_query("SELECT value FROM webfinance_pref WHERE type_pref='societe' AND owner=-1") or wf_mysqldie(); list($value) = mysql_fetch_array($result); mysql_free_result($result); $company = unserialize(base64_decode($value)); $site = "webfinance.dev.jexiste.org"; if (!empty($company->wf_url) and strlen($company->wf_url) > 3) { $site = preg_replace('/^http:\\/\\//i', '', $company->wf_url); } $ref_cmd = "WEBFINANCE;" . random_int(10); $params = array("PBX_MODE" => "1", "PBX_SITE" => "1999888", "PBX_RANG" => "99", "PBX_TOTAL" => $inv->nice_total_ttc * 100, "PBX_DEVISE" => "978", "PBX_CMD" => $ref_cmd, "PBX_PORTEUR" => $Client->email, "PBX_RETOUR" => "ref:R;auto:A;trans:T;montant:M;pbxtype:P;card:C;soletrans:S;error:E", "PBX_IDENTIFIANT" => "2", "PBX_EFFECTUE" => "http://{$site}/payment/paybox/ok.php", "PBX_REFUSE" => "http://{$site}/payment/paybox/deny.php", "PBX_ERROR" => "http://{$site}/payment/paybox/deny.php", "PBX_ANNULE" => "http://{$site}/payment/paybox/cancel.php", "PBX_LANGUAGE" => "FR"); $res = mysql_query("SELECT value FROM webfinance_pref WHERE type_pref='paybox'") or wf_mysqldie(); if (mysql_num_rows($res) > 0) { list($value) = mysql_fetch_array($res); $paybox = unserialize(base64_decode($value)); $params['PBX_SITE'] = $paybox->PBX_SITE; $params['PBX_RANG'] = $paybox->PBX_RANG; $params['PBX_IDENTIFIANT'] = $paybox->PBX_IDENTIFIANT; } $args = ""; foreach ($params as $param => $v) { $args .= $param . "=" . $v . "&"; } //insert the transation in the db $r = mysql_query("INSERT INTO webfinance_paybox SET id_invoice={$inv->id_facture}, " . "email='" . $params['PBX_PORTEUR'] . "' , " . "reference='" . $params['PBX_CMD'] . "' , " . "state='pending', " . "amount='{$inv->nice_total_ttc}' , " . "currency='" . $params['PBX_DEVISE'] . "' , " . "date=NOW() ") or wf_mysqldie(); header("Location: /cgi-bin/paybox/modulev2.cgi?{$args}"); exit;
function phone_number_format($number = '') { // France if (preg_match('/\\+33(\\d{1})(\\d{2})(\\d{2})(\\d{2})(\\d{2})$/', $number, $matches)) { return "+33 {$matches['1']} {$matches['2']} {$matches['3']} {$matches['4']} {$matches['5']}"; } // Generic return rtrim(chunk_split($number, 2, '-'), '-'); } ?> <div style="overflow: auto; height: 300px;"> <table width="100%" border="0" cellspacing="0" cellpadding="2"> <?php global $Client; // Liste les personnes contacts pour ce client $result = mysql_query("SELECT id_personne,nom,prenom,fonction,mobile,tel,note,email FROM webfinance_personne WHERE client=" . $_GET['id'] . " ORDER BY nom") or wf_mysqldie(); $count = 1; while ($contact = mysql_fetch_object($result)) { $contact->note = preg_replace("!\r\n!", "<br/>", $contact->note); $class = $count % 2 == 0 ? "odd" : "even"; if ($contact->email != "") { $mail = sprintf('<a href="mailto:%s %s <%s>"><img class="icon" src="/imgs/icons/mail.gif" alt="%s" /></a>', $contact->prenom, $contact->nom, $contact->email, $contact->email); } else { $mail = ""; } if ($contact->tel != "") { $tel = sprintf('<img style="vertical-align: middle;" src="/imgs/icons/tel.gif" alt="Tel" /> %s<br/>', phone_number_format($contact->tel)); } else { $tel = ""; } if ($contact->mobile != "") {
Créé le <?php echo $user->nice_creation_date; ?> <br/> Modifié le <?php echo $user->nice_modification_date; ?> </td> </tr> <tr> <td colspan="4"> <table> <tr> <td>Roles:</td> <?php $result = mysql_query("SELECT id_role, name FROM webfinance_roles") or wf_mysqldie(); while ($role = mysql_fetch_assoc($result)) { printf("<td><input type='checkbox' name='role[]' %s value='%s' >%s</td>", $User->hasRole($role['name'], $user->id_user) > 0 ? "checked" : "", $role['name'], $role['name']); } ?> </tr> </table> </td> </tr> <tr> <td colspan="4" style="text-align: center;"> <?php $save_off = '/imgs/boutons/' . urlencode(_('Save') . "_off_" . $User->prefs->theme) . ".png"; $save_on = '/imgs/boutons/' . urlencode(_('Save') . "_on_" . $User->prefs->theme) . ".png"; $cancel_off = '/imgs/boutons/' . urlencode(_('Cancel') . "_off_" . $User->prefs->theme) . ".png"; $cancel_on = '/imgs/boutons/' . urlencode(_('Cancel') . "_on_" . $User->prefs->theme) . ".png";
} return true; } </script> <form onsubmit="return checkForm(this);" id="main_form" action="do_import.php" method="post" enctype="multipart/form-data"> <table class="bordered" border="0" cellspacing="0" cellpadding="3"> <tr> <td><?php echo _('Account :'); ?> </td> <td><select name="id_account" style="width: 250px;"> <?php $result = mysql_query("SELECT id_pref,value FROM webfinance_pref WHERE owner=-1 AND type_pref='rib'") or wf_mysqldie(); if (mysql_num_rows($result) > 1) { printf("<option value='-1'>%s</option>", _('-- Select an account --')); } while (list($id_cpt, $cpt) = mysql_fetch_array($result)) { $cpt = unserialize(base64_decode($cpt)); printf(_(' <option value="%d"%s>%s #%s</option>') . "\n", $id_cpt, $filter['id_account'] == $id_cpt ? " selected" : "", $cpt->banque, $cpt->compte); } mysql_free_result($result); ?> </td> </tr> <tr> <td>Fichier CSV</td><td><input type="file" name="csv" /></td> </tr> <tr>
<div style="overflow: auto; height: 250px;"> <table width="100%" border="0" cellspacing="0" cellpadding="5"> <?php $w_clause = ""; if (count($num_factures) > 0) { $w_clause .= " AND ( "; $tmp = array(); foreach ($num_factures as $id_facture => $num_facture) { $tmp[] .= " log RLIKE '#{$num_facture}' "; #$tmp[] .= " log RLIKE 'fa:$id_facture' "; } $w_clause .= implode(" OR ", $tmp); $w_clause .= ") "; } $q = "SELECT id_userlog,log,date,id_user,date_format(date,'%d/%m/%Y %k:%i') as nice_date " . "FROM webfinance_userlog " . "WHERE log RLIKE 'fa:' {$w_clause} " . "ORDER BY date DESC"; $result = mysql_query($q) or wf_mysqldie(); $count = 1; while ($log = mysql_fetch_object($result)) { $class = $count % 2 == 0 ? "odd" : "even"; $result2 = mysql_query("SELECT login FROM webfinance_users WHERE id_user="******"row_{$class}"> <td style="border:none;" nowrap>{$log->nice_date}</td> <td style="border:none;">{$message}</td> <td style="border:none;">{$login}</td> </tr> EOF; $count++;
$File->deleteAllFiles($id_transaction); } if (isset($_FILES['file']) && is_uploaded_file($_FILES['file']['tmp_name'])) { $File->addFile($_FILES['file'], $id_transaction); } //factures liées if (isset($id_invoices)) { mysql_query("DELETE FROM webfinance_transaction_invoice WHERE id_transaction={$id_transaction}") or wf_mysqldie(); $id_invoices = array_unique($id_invoices); if (count($id_invoices)) { $q = ""; foreach ($id_invoices as $id_invoice) { if (is_numeric($id_invoice) && $id_invoice > 0) { $q .= " ({$id_transaction} , {$id_invoice} ),"; } } $q = preg_replace('/,$/', '', $q); if (!empty($q)) { mysql_query("INSERT INTO webfinance_transaction_invoice (id_transaction , id_invoice ) VALUES {$q} ") or wf_mysqldie(); } } } ?> <script> popup = window.parent.document.getElementById('inpage_popup'); popup.style.display = 'none'; // Reload parent window to update contacts filter = window.parent.document.getElementById('main_form'); filter.submit(); </script>