Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
Scrutinizer Auto-Fixer 2019-11-11 23:15:34 +00:00
parent d368cf7a52
commit df664e790b
36 changed files with 5200 additions and 5200 deletions

View File

@ -34,24 +34,24 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$langs->loadLangs(array("accountancy", "bills", "companies", "salaries", "compta"));
$date_start =GETPOST('date_start', 'alpha');
$date_startDay= GETPOST('date_startday', 'int');
$date_startMonth= GETPOST('date_startmonth', 'int');
$date_startYear= GETPOST('date_startyear', 'int');
$date_start=($date_startDay)?dol_mktime(0, 0, 0, $date_startMonth, $date_startDay, $date_startYear):strtotime($date_start);
$date_stop =GETPOST('date_stop', 'alpha');
$date_stopDay= GETPOST('date_stopday', 'int');
$date_stopMonth= GETPOST('date_stopmonth', 'int');
$date_stopYear= GETPOST('date_stopyear', 'int');
$date_start = GETPOST('date_start', 'alpha');
$date_startDay = GETPOST('date_startday', 'int');
$date_startMonth = GETPOST('date_startmonth', 'int');
$date_startYear = GETPOST('date_startyear', 'int');
$date_start = ($date_startDay) ?dol_mktime(0, 0, 0, $date_startMonth, $date_startDay, $date_startYear) : strtotime($date_start);
$date_stop = GETPOST('date_stop', 'alpha');
$date_stopDay = GETPOST('date_stopday', 'int');
$date_stopMonth = GETPOST('date_stopmonth', 'int');
$date_stopYear = GETPOST('date_stopyear', 'int');
//FIXME doldate
$date_stop=($date_stopDay)?dol_mktime(23, 59, 59, $date_stopMonth, $date_stopDay, $date_stopYear):strtotime($date_stop);
$action =GETPOST('action', 'alpha');
$date_stop = ($date_stopDay) ?dol_mktime(23, 59, 59, $date_stopMonth, $date_stopDay, $date_stopYear) : strtotime($date_stop);
$action = GETPOST('action', 'alpha');
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('comptafileslist','globallist'));
$hookmanager->initHooks(array('comptafileslist', 'globallist'));
// Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -59,11 +59,11 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) $sortfield="date,item"; // Set here default search field
if (! $sortorder) $sortorder="DESC";
if (!$sortfield) $sortfield = "date,item"; // Set here default search field
if (!$sortorder) $sortorder = "DESC";
$arrayfields=array(
$arrayfields = array(
'type'=>array('label'=>"Type", 'checked'=>1),
'date'=>array('label'=>"Date", 'checked'=>1),
//...
@ -77,7 +77,7 @@ if ($user->socid > 0) {
accessforbidden();
}
$entity = GETPOST('entity', 'int')?GETPOST('entity', 'int'):$conf->entity;
$entity = GETPOST('entity', 'int') ?GETPOST('entity', 'int') : $conf->entity;
/*
@ -89,9 +89,9 @@ $entity = GETPOST('entity', 'int')?GETPOST('entity', 'int'):$conf->entity;
//$reshook = $hookmanager->executeHooks('doActions', $parameters, $object); // Note that $object may have been modified by some hooks
//if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
$filesarray=array();
$result=false;
if (($action=="searchfiles" || $action=="dl" )) {
$filesarray = array();
$result = false;
if (($action == "searchfiles" || $action == "dl")) {
if (empty($date_start))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateStart")), null, 'errors');
@ -103,159 +103,159 @@ if (($action=="searchfiles" || $action=="dl" )) {
$error++;
}
if (! $error)
if (!$error)
{
$wheretail=" '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'";
$wheretail = " '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'";
$sql="SELECT t.rowid as id, t.ref, t.paye as paid, total as total_ht, total_ttc, tva as total_vat, fk_soc, t.datef as date, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum";
$sql.=" FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays";
$sql.=" WHERE datef between ".$wheretail;
$sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')';
$sql.=" AND t.fk_statut <> ".Facture::STATUS_DRAFT;
$sql.=" UNION ALL";
$sql.=" SELECT t.rowid as id, t.ref, paye as paid, total_ht, total_ttc, total_tva as total_vat, fk_soc, datef as date, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum";
$sql.=" FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays";
$sql.=" WHERE datef between ".$wheretail;
$sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')';
$sql.=" AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT;
$sql.=" UNION ALL";
$sql.=" SELECT t.rowid as id, t.ref, paid, total_ht, total_ttc, total_tva as total_vat, fk_user_author as fk_soc, date_fin as date, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum";
$sql.=" FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country";
$sql.=" WHERE date_fin between ".$wheretail;
$sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')';
$sql.=" AND t.fk_statut <> ".ExpenseReport::STATUS_DRAFT;
$sql.=" UNION ALL";
$sql.=" SELECT t.rowid as id, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, datedon as date, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum";
$sql.=" FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country";
$sql.=" WHERE datedon between ".$wheretail;
$sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')';
$sql.=" AND t.fk_statut <> ".Don::STATUS_DRAFT;
$sql.=" UNION ALL";
$sql.=" SELECT t.rowid as id, t.label as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, t.fk_user as fk_soc, datep as date, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum";
$sql.=" FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country";
$sql.=" WHERE datep between ".$wheretail;
$sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')';
$sql = "SELECT t.rowid as id, t.ref, t.paye as paid, total as total_ht, total_ttc, tva as total_vat, fk_soc, t.datef as date, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays";
$sql .= " WHERE datef between ".$wheretail;
$sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')';
$sql .= " AND t.fk_statut <> ".Facture::STATUS_DRAFT;
$sql .= " UNION ALL";
$sql .= " SELECT t.rowid as id, t.ref, paye as paid, total_ht, total_ttc, total_tva as total_vat, fk_soc, datef as date, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays";
$sql .= " WHERE datef between ".$wheretail;
$sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')';
$sql .= " AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT;
$sql .= " UNION ALL";
$sql .= " SELECT t.rowid as id, t.ref, paid, total_ht, total_ttc, total_tva as total_vat, fk_user_author as fk_soc, date_fin as date, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country";
$sql .= " WHERE date_fin between ".$wheretail;
$sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')';
$sql .= " AND t.fk_statut <> ".ExpenseReport::STATUS_DRAFT;
$sql .= " UNION ALL";
$sql .= " SELECT t.rowid as id, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, datedon as date, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum";
$sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country";
$sql .= " WHERE datedon between ".$wheretail;
$sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')';
$sql .= " AND t.fk_statut <> ".Don::STATUS_DRAFT;
$sql .= " UNION ALL";
$sql .= " SELECT t.rowid as id, t.label as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, t.fk_user as fk_soc, datep as date, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum";
$sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country";
$sql .= " WHERE datep between ".$wheretail;
$sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')';
//$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT;
$sql.=" UNION ALL";
$sql.=" SELECT t.rowid as id, t.libelle as ref, paye as paid, amount as total_ht, amount as total_ttc, 0 as total_tva, 0 as fk_soc, date_creation as date, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum";
$sql.=" FROM ".MAIN_DB_PREFIX."chargesociales as t";
$sql.=" WHERE date_creation between ".$wheretail;
$sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')';
$sql .= " UNION ALL";
$sql .= " SELECT t.rowid as id, t.libelle as ref, paye as paid, amount as total_ht, amount as total_ttc, 0 as total_tva, 0 as fk_soc, date_creation as date, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum";
$sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t";
$sql .= " WHERE date_creation between ".$wheretail;
$sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')';
//$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT;
$sql.= $db->order($sortfield, $sortorder);
$sql .= $db->order($sortfield, $sortorder);
//print $sql;
$resd = $db->query($sql);
$files=array();
$link='';
$files = array();
$link = '';
if ($resd)
{
$numd = $db->num_rows($resd);
$tmpinvoice=new Facture($db);
$tmpinvoicesupplier=new FactureFournisseur($db);
$tmpdonation=new Don($db);
$tmpinvoice = new Facture($db);
$tmpinvoicesupplier = new FactureFournisseur($db);
$tmpdonation = new Don($db);
$upload_dir ='';
$i=0;
$upload_dir = '';
$i = 0;
while ($i < $numd)
{
$objd = $db->fetch_object($resd);
switch($objd->item)
switch ($objd->item)
{
case "Invoice":
$subdir = '';
$subdir.=($subdir ? '/' : '').dol_sanitizeFileName($objd->ref);
$subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref);
$upload_dir = $conf->facture->dir_output.'/'.$subdir;
$link="document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F';
$link = "document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F';
break;
case "SupplierInvoice":
$tmpinvoicesupplier->fetch($objd->id);
$subdir = get_exdir($tmpinvoicesupplier->id, 2, 0, 1, $tmpinvoicesupplier, 'invoice_supplier'); // TODO Use first file
$subdir.=($subdir ? '/' : '').dol_sanitizeFileName($objd->ref);
$subdir = get_exdir($tmpinvoicesupplier->id, 2, 0, 1, $tmpinvoicesupplier, 'invoice_supplier'); // TODO Use first file
$subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref);
$upload_dir = $conf->fournisseur->facture->dir_output.'/'.$subdir;
$link="document.php?modulepart=facture_fournisseur&file=".str_replace('/', '%2F', $subdir).'%2F';
$link = "document.php?modulepart=facture_fournisseur&file=".str_replace('/', '%2F', $subdir).'%2F';
break;
case "ExpenseReport":
$subdir = '';
$subdir.=($subdir ? '/' : '').dol_sanitizeFileName($objd->ref);
$subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref);
$upload_dir = $conf->expensereport->dir_output.'/'.$subdir;
$link="document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F';
$link = "document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F';
break;
case "SalaryPayment":
$subdir = '';
$subdir.=($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
$subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
$upload_dir = $conf->salaries->dir_output.'/'.$subdir;
$link="document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F';
$link = "document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F';
break;
case "Donation":
$tmpdonation->fetch($objp->id);
$subdir=get_exdir(0, 0, 0, 0, $tmpdonation, 'donation');
$subdir.=($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
$upload_dir = $conf->don->dir_output . '/' . $subdir;
$link="document.php?modulepart=don&file=".str_replace('/', '%2F', $subdir).'%2F';
$subdir = get_exdir(0, 0, 0, 0, $tmpdonation, 'donation');
$subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
$upload_dir = $conf->don->dir_output.'/'.$subdir;
$link = "document.php?modulepart=don&file=".str_replace('/', '%2F', $subdir).'%2F';
break;
case "SocialContributions":
$subdir = '';
$subdir.=($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
$upload_dir = $conf->tax->dir_output . '/' . $subdir;
$link="document.php?modulepart=tax&file=".str_replace('/', '%2F', $subdir).'%2F';
$subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id);
$upload_dir = $conf->tax->dir_output.'/'.$subdir;
$link = "document.php?modulepart=tax&file=".str_replace('/', '%2F', $subdir).'%2F';
break;
default:
$subdir='';
$upload_dir='';
$link='';
$subdir = '';
$upload_dir = '';
$link = '';
break;
}
if (!empty($upload_dir))
{
$result=true;
$files=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview\.png)$', '', SORT_ASC, 1);
$result = true;
$files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview\.png)$', '', SORT_ASC, 1);
//var_dump($upload_dir);
if (count($files) < 1)
{
$nofile['id']=$objd->id;
$nofile['date']=$db->idate($objd->date);
$nofile['paid']=$objd->paid;
$nofile['amount_ht']=$objd->total_ht;
$nofile['amount_ttc']=$objd->total_ttc;
$nofile['amount_vat']=$objd->total_vat;
$nofile['ref']=($objd->ref ? $objd->ref : $objd->id);
$nofile['fk']=$objd->fk_soc;
$nofile['item']=$objd->item;
$nofile['thirdparty_name']=$objd->thirdparty_name;
$nofile['thirdparty_code']=$objd->thirdparty_code;
$nofile['country_code']=$objd->country_code;
$nofile['vatnum']=$objd->vatnum;
$nofile['id'] = $objd->id;
$nofile['date'] = $db->idate($objd->date);
$nofile['paid'] = $objd->paid;
$nofile['amount_ht'] = $objd->total_ht;
$nofile['amount_ttc'] = $objd->total_ttc;
$nofile['amount_vat'] = $objd->total_vat;
$nofile['ref'] = ($objd->ref ? $objd->ref : $objd->id);
$nofile['fk'] = $objd->fk_soc;
$nofile['item'] = $objd->item;
$nofile['thirdparty_name'] = $objd->thirdparty_name;
$nofile['thirdparty_code'] = $objd->thirdparty_code;
$nofile['country_code'] = $objd->country_code;
$nofile['vatnum'] = $objd->vatnum;
$filesarray[]=$nofile;
$filesarray[] = $nofile;
}
else
{
foreach ($files as $key => $file)
{
$file['id']=$objd->id;
$file['date']=$db->idate($objd->date);
$file['paid']=$objd->paid;
$file['amount_ht']=$objd->total_ht;
$file['amount_ttc']=$objd->total_ttc;
$file['amount_vat']=$objd->total_vat;
$file['ref']=($objd->ref ? $objd->ref : $objd->id);
$file['fk']=$objd->fk_soc;
$file['item']=$objd->item;
$file['id'] = $objd->id;
$file['date'] = $db->idate($objd->date);
$file['paid'] = $objd->paid;
$file['amount_ht'] = $objd->total_ht;
$file['amount_ttc'] = $objd->total_ttc;
$file['amount_vat'] = $objd->total_vat;
$file['ref'] = ($objd->ref ? $objd->ref : $objd->id);
$file['fk'] = $objd->fk_soc;
$file['item'] = $objd->item;
$file['thirdparty_name']=$objd->thirdparty_name;
$file['thirdparty_code']=$objd->thirdparty_code;
$file['country_code']=$objd->country_code;
$file['vatnum']=$objd->vatnum;
$file['thirdparty_name'] = $objd->thirdparty_name;
$file['thirdparty_code'] = $objd->thirdparty_code;
$file['country_code'] = $objd->country_code;
$file['vatnum'] = $objd->vatnum;
$file['link']=$link.$file['name'];
$file['link'] = $link.$file['name'];
$file['relpathnamelang'] = $langs->trans($file['item']).'/'.$file['name'];
$filesarray[]=$file;
$filesarray[] = $file;
}
}
}
@ -284,9 +284,9 @@ if (empty($dirfortmpfile))
}
if ($result && $action == "dl" && ! $error)
if ($result && $action == "dl" && !$error)
{
if (! extension_loaded('zip'))
if (!extension_loaded('zip'))
{
setEventMessages('PHPZIPExtentionNotLoaded', null, 'errors');
exit;
@ -295,41 +295,41 @@ if ($result && $action == "dl" && ! $error)
dol_mkdir($dirfortmpfile);
$log = $langs->transnoentitiesnoconv("Type");
$log .= ',' . $langs->transnoentitiesnoconv("Date");
$log .= ',' . $langs->transnoentitiesnoconv("Ref");
$log .= ',' . $langs->transnoentitiesnoconv("TotalHT");
$log .= ',' . $langs->transnoentitiesnoconv("TotalTTC");
$log .= ',' . $langs->transnoentitiesnoconv("TotalVAT");
$log .= ',' . $langs->transnoentitiesnoconv("Paid");
$log .= ','.$langs->transnoentitiesnoconv("Date");
$log .= ','.$langs->transnoentitiesnoconv("Ref");
$log .= ','.$langs->transnoentitiesnoconv("TotalHT");
$log .= ','.$langs->transnoentitiesnoconv("TotalTTC");
$log .= ','.$langs->transnoentitiesnoconv("TotalVAT");
$log .= ','.$langs->transnoentitiesnoconv("Paid");
$log .= ',filename,item_id';
$log .= ',' . $langs->transnoentitiesnoconv("ThirdParty");
$log .= ',' . $langs->transnoentitiesnoconv("Code");
$log .= ',' . $langs->transnoentitiesnoconv("Country");
$log .= ',' . $langs->transnoentitiesnoconv("VATIntra")."\n";
$log .= ','.$langs->transnoentitiesnoconv("ThirdParty");
$log .= ','.$langs->transnoentitiesnoconv("Code");
$log .= ','.$langs->transnoentitiesnoconv("Country");
$log .= ','.$langs->transnoentitiesnoconv("VATIntra")."\n";
$zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc')."-".dol_print_date($date_stop, 'dayrfc').'_export.zip';
dol_delete_file($zipname);
$zip = new ZipArchive;
$res = $zip->open($zipname, ZipArchive::OVERWRITE|ZipArchive::CREATE);
$res = $zip->open($zipname, ZipArchive::OVERWRITE | ZipArchive::CREATE);
if ($res)
{
foreach ($filesarray as $key => $file)
{
if (file_exists($file["fullname"])) $zip->addFile($file["fullname"], $file["relpathnamelang"]);
$log .= $file['item'];
$log .= ',' . dol_print_date($file['date'], 'dayrfc');
$log .= ',' . $file['ref'];
$log .= ',' . $file['amount_ht'];
$log .= ',' . $file['amount_ttc'];
$log .= ',' . $file['amount_vat'];
$log .= ',' . $file['paid'];
$log .= ',' . $file["name"];
$log .= ',' . $file['fk'];
$log .= ',' . $file['thirdparty_name'];
$log .= ',' . $file['thirdparty_code'];
$log .= ',' . $file['country_code'];
$log .= ',"' . $file['vatnum'].'"'."\n";
$log .= ','.dol_print_date($file['date'], 'dayrfc');
$log .= ','.$file['ref'];
$log .= ','.$file['amount_ht'];
$log .= ','.$file['amount_ttc'];
$log .= ','.$file['amount_vat'];
$log .= ','.$file['paid'];
$log .= ','.$file["name"];
$log .= ','.$file['fk'];
$log .= ','.$file['thirdparty_name'];
$log .= ','.$file['thirdparty_code'];
$log .= ','.$file['country_code'];
$log .= ',"'.$file['vatnum'].'"'."\n";
}
$zip->addFromString('transactions.csv', $log);
$zip->close();
@ -337,7 +337,7 @@ if ($result && $action == "dl" && ! $error)
///Then download the zipped file.
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename='.basename($zipname));
header('Content-Length: ' . filesize($zipname));
header('Content-Length: '.filesize($zipname));
readfile($zipname);
dol_delete_file($zipname);
@ -356,13 +356,13 @@ if ($result && $action == "dl" && ! $error)
*/
$form = new Form($db);
$userstatic=new User($db);
$userstatic = new User($db);
$title=$langs->trans("ComptaFiles").' - '.$langs->trans("List");
$title = $langs->trans("ComptaFiles").' - '.$langs->trans("List");
llxHeader('', $title, $help_url);
$h=0;
$h = 0;
$head[$h][0] = $_SERVER["PHP_SELF"].$varlink;
$head[$h][1] = $langs->trans("AccountantFiles");
$head[$h][2] = 'AccountancyFiles';
@ -376,7 +376,7 @@ print $langs->trans("ReportPeriod").': '.$form->selectDate($date_start, 'date_st
print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n</a>";
// Export is for current company only !
if (! empty($conf->multicompany->enabled) && is_object($mc))
if (!empty($conf->multicompany->enabled) && is_object($mc))
{
print '<span class="marginleftonly marginrightonly">('.$langs->trans("Entity").' : ';
$mc->dao->getEntities();
@ -393,13 +393,13 @@ dol_fiche_end();
if (!empty($date_start) && !empty($date_stop))
{
$param='action=searchfiles';
$param.='&date_startday='.GETPOST('date_startday', 'int');
$param.='&date_startmonth='.GETPOST('date_startmonth', 'int');
$param.='&date_startyear='.GETPOST('date_startyear', 'int');
$param.='&date_stopday='.GETPOST('date_stopday', 'int');
$param.='&date_stopmonth='.GETPOST('date_stopmonth', 'int');
$param.='&date_stopyear='.GETPOST('date_stopyear', 'int');
$param = 'action=searchfiles';
$param .= '&date_startday='.GETPOST('date_startday', 'int');
$param .= '&date_startmonth='.GETPOST('date_startmonth', 'int');
$param .= '&date_startyear='.GETPOST('date_startyear', 'int');
$param .= '&date_stopday='.GETPOST('date_stopday', 'int');
$param .= '&date_stopmonth='.GETPOST('date_stopmonth', 'int');
$param .= '&date_stopyear='.GETPOST('date_stopyear', 'int');
print '<form name="dl" action="?action=dl" method="POST" >'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -422,7 +422,7 @@ if (!empty($date_start) && !empty($date_stop))
print '<br>';
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'nowrap ');
@ -457,7 +457,7 @@ if (!empty($date_start) && !empty($date_stop))
$totalCredit = 0;
// Display array
foreach($TData as $data)
foreach ($TData as $data)
{
$html_class = '';
//if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture'];

View File

@ -32,28 +32,28 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
// Load translation files required by the page
$langs->loadLangs(array('banks', 'categories'));
$WIDTH=DolGraph::getDefaultGraphSizeForStats('width', 380); // Large for one graph in a smarpthone.
$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height', 160);
$WIDTH = DolGraph::getDefaultGraphSizeForStats('width', 380); // Large for one graph in a smarpthone.
$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height', 160);
$id=GETPOST('account')?GETPOST('account', 'alpha'):GETPOST('id');
$ref=GETPOST('ref');
$id = GETPOST('account') ?GETPOST('account', 'alpha') : GETPOST('id');
$ref = GETPOST('ref');
// Security check
$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :''));
$fieldtype = (! empty($ref) ? 'ref' :'rowid');
if ($user->socid) $socid=$user->socid;
$result=restrictedArea($user, 'banque', $fieldvalue, 'bank_account&bank_account', '', '', $fieldtype);
$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
$fieldtype = (!empty($ref) ? 'ref' : 'rowid');
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account&bank_account', '', '', $fieldtype);
$year_start=GETPOST('year_start');
$year_start = GETPOST('year_start');
$year_current = strftime("%Y", time());
if (! $year_start)
if (!$year_start)
{
$year_start = $year_current - 2;
$year_end = $year_current;
}
else
{
$year_end=$year_start+2;
$year_end = $year_start + 2;
}
@ -70,15 +70,15 @@ $form = new Form($db);
// Get account informations
$object = new Account($db);
if ($id > 0 && ! preg_match('/,/', $id)) // if for a particular account and not a list
if ($id > 0 && !preg_match('/,/', $id)) // if for a particular account and not a list
{
$result=$object->fetch($id);
$id=$object->id;
$result = $object->fetch($id);
$id = $object->id;
}
if (! empty($ref))
if (!empty($ref))
{
$result=$object->fetch(0, $ref);
$id=$object->id;
$result = $object->fetch(0, $ref);
$id = $object->id;
}
@ -86,17 +86,17 @@ if (! empty($ref))
// plutot que sur llx_paiement + llx_paiementfourn
$sql = "SELECT SUM(b.amount)";
$sql.= ", date_format(b.dateo,'%Y-%m') as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
$sql.= " AND b.amount >= 0";
if (! empty($id))
$sql .= ", date_format(b.dateo,'%Y-%m') as dm";
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql .= " WHERE b.fk_account = ba.rowid";
$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
$sql .= " AND b.amount >= 0";
if (!empty($id))
$sql .= " AND b.fk_account IN (".$db->escape($id).")";
$sql.= " GROUP BY dm";
$sql .= " GROUP BY dm";
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
@ -114,17 +114,17 @@ else
}
$sql = "SELECT SUM(b.amount)";
$sql.= ", date_format(b.dateo,'%Y-%m') as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
$sql.= " AND b.amount <= 0";
if (! empty($id))
$sql .= ", date_format(b.dateo,'%Y-%m') as dm";
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql .= " WHERE b.fk_account = ba.rowid";
$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
$sql .= " AND b.amount <= 0";
if (!empty($id))
$sql .= " AND b.fk_account IN (".$db->escape($id).")";
$sql.= " GROUP BY dm";
$sql .= " GROUP BY dm";
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
@ -143,31 +143,31 @@ else
// Onglets
$head=bank_prepare_head($object);
$head = bank_prepare_head($object);
dol_fiche_head($head, 'annual', $langs->trans("FinancialAccount"), 0, 'account');
$title=$langs->trans("FinancialAccount")." : ".$object->label;
$link=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?account=".$object->id."&year_start=".($year_start-1)."'>".img_previous('', 'class="valignbottom"')."</a> ".$langs->trans("Year")." <a href='".$_SERVER["PHP_SELF"]."?account=".$object->id."&year_start=".($year_start+1)."'>".img_next('', 'class="valignbottom"')."</a>":"");
$title = $langs->trans("FinancialAccount")." : ".$object->label;
$link = ($year_start ? "<a href='".$_SERVER["PHP_SELF"]."?account=".$object->id."&year_start=".($year_start - 1)."'>".img_previous('', 'class="valignbottom"')."</a> ".$langs->trans("Year")." <a href='".$_SERVER["PHP_SELF"]."?account=".$object->id."&year_start=".($year_start + 1)."'>".img_next('', 'class="valignbottom"')."</a>" : "");
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
if (!empty($id))
{
if (! preg_match('/,/', $id))
if (!preg_match('/,/', $id))
{
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
}
else
{
$bankaccount=new Account($db);
$listid=explode(',', $id);
foreach($listid as $key => $aId)
$bankaccount = new Account($db);
$listid = explode(',', $id);
foreach ($listid as $key => $aId)
{
$bankaccount->fetch($aId);
$bankaccount->label=$bankaccount->ref;
$bankaccount->label = $bankaccount->ref;
print $bankaccount->getNomUrl(1);
if ($key < (count($listid)-1)) print ', ';
if ($key < (count($listid) - 1)) print ', ';
}
}
}
@ -182,11 +182,11 @@ dol_fiche_end();
// Affiche tableau
print load_fiche_titre('', $link, '');
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="liste_titre">'.$langs->trans("Month").'</td>';
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
for ($annee = $year_start; $annee <= $year_end; $annee++)
{
print '<td align="center" width="20%" colspan="2" class="liste_titre borderrightlight">'.$annee.'</td>';
}
@ -194,33 +194,33 @@ print '</tr>';
print '<tr class="liste_titre">';
print '<td class="liste_titre">&nbsp;</td>';
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
for ($annee = $year_start; $annee <= $year_end; $annee++)
{
print '<td class="liste_titre" align="center">'.$langs->trans("Debit").'</td><td class="liste_titre" align="center">'.$langs->trans("Credit").'</td>';
}
print '</tr>';
for ($mois = 1 ; $mois < 13 ; $mois++)
for ($mois = 1; $mois < 13; $mois++)
{
print '<tr class="oddeven">';
print "<td>".dol_print_date(dol_mktime(1, 1, 1, $mois, 1, 2000), "%B")."</td>";
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
for ($annee = $year_start; $annee <= $year_end; $annee++)
{
$case = sprintf("%04s-%02s", $annee, $mois);
print '<td class="right" width="10%">&nbsp;';
if ($decaiss[$case]>0)
if ($decaiss[$case] > 0)
{
print price($decaiss[$case]);
$totsorties[$annee]+=$decaiss[$case];
$totsorties[$annee] += $decaiss[$case];
}
print "</td>";
print '<td class="right borderrightlight" width="10%">&nbsp;';
if ($encaiss[$case]>0)
if ($encaiss[$case] > 0)
{
print price($encaiss[$case]);
$totentrees[$annee]+=$encaiss[$case];
$totentrees[$annee] += $encaiss[$case];
}
print "</td>";
}
@ -229,7 +229,7 @@ for ($mois = 1 ; $mois < 13 ; $mois++)
// Total debit-credit
print '<tr class="liste_total"><td><b>'.$langs->trans("Total")."</b></td>";
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
for ($annee = $year_start; $annee <= $year_end; $annee++)
{
print '<td class="right nowraponall"><b>'.price($totsorties[$annee]).'</b></td><td class="right nowraponall"><b>'.price($totentrees[$annee]).'</b></td>';
}
@ -242,21 +242,21 @@ print '<br>';
// Current balance
$balance=0;
$balance = 0;
$sql = "SELECT SUM(b.amount) as total";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
if (! empty($id))
$sql.= " AND b.fk_account IN (".$db->escape($id).")";
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql .= " WHERE b.fk_account = ba.rowid";
$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
if (!empty($id))
$sql .= " AND b.fk_account IN (".$db->escape($id).")";
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
if ($obj) $balance=$obj->total;
if ($obj) $balance = $obj->total;
}
else {
dol_print_error($db);
@ -274,7 +274,7 @@ print "</table>";
$year = $year_end;
$result=dol_mkdir($conf->bank->dir_temp);
$result = dol_mkdir($conf->bank->dir_temp);
if ($result < 0)
{
$langs->load("errors");
@ -285,11 +285,11 @@ else
{
// Calcul de $min et $max
$sql = "SELECT MIN(b.datev) as min, MAX(b.datev) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
if ($id && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$id.")";
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql .= " WHERE b.fk_account = ba.rowid";
$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
if ($id && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$id.")";
$resql = $db->query($sql);
if ($resql)
@ -303,7 +303,7 @@ else
{
dol_print_error($db);
}
$log="graph.php: min=".$min." max=".$max;
$log = "graph.php: min=".$min." max=".$max;
dol_syslog($log);
// CRED PART
@ -312,18 +312,18 @@ else
$tblyear[1] = array();
$tblyear[2] = array();
for ($annee=0;$annee<3;$annee++)
for ($annee = 0; $annee < 3; $annee++)
{
$sql = "SELECT date_format(b.datev,'%m')";
$sql.= ", SUM(b.amount)";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
$sql.= " AND b.datev >= '".($year-$annee)."-01-01 00:00:00'";
$sql.= " AND b.datev <= '".($year-$annee)."-12-31 23:59:59'";
$sql.= " AND b.amount > 0";
if ($id && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$id.")";
$sql .= ", SUM(b.amount)";
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql .= " WHERE b.fk_account = ba.rowid";
$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
$sql .= " AND b.datev >= '".($year - $annee)."-01-01 00:00:00'";
$sql .= " AND b.datev <= '".($year - $annee)."-12-31 23:59:59'";
$sql .= " AND b.amount > 0";
if ($id && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$id.")";
$sql .= " GROUP BY date_format(b.datev,'%m');";
$resql = $db->query($sql);
@ -350,38 +350,38 @@ else
$data_year_1 = array();
$data_year_2 = array();
for ($i = 0 ; $i < 12 ; $i++)
for ($i = 0; $i < 12; $i++)
{
$data_year_0[$i] = isset($tblyear[0][substr("0".($i+1), -2)]) ? $tblyear[0][substr("0".($i+1), -2)] : 0;
$data_year_1[$i] = isset($tblyear[1][substr("0".($i+1), -2)]) ? $tblyear[1][substr("0".($i+1), -2)] : 0;
$data_year_2[$i] = isset($tblyear[2][substr("0".($i+1), -2)]) ? $tblyear[2][substr("0".($i+1), -2)] : 0;
$labels[$i] = $langs->transnoentitiesnoconv("MonthVeryShort".sprintf("%02d", $i+1));
$data_year_0[$i] = isset($tblyear[0][substr("0".($i + 1), -2)]) ? $tblyear[0][substr("0".($i + 1), -2)] : 0;
$data_year_1[$i] = isset($tblyear[1][substr("0".($i + 1), -2)]) ? $tblyear[1][substr("0".($i + 1), -2)] : 0;
$data_year_2[$i] = isset($tblyear[2][substr("0".($i + 1), -2)]) ? $tblyear[2][substr("0".($i + 1), -2)] : 0;
$labels[$i] = $langs->transnoentitiesnoconv("MonthVeryShort".sprintf("%02d", $i + 1));
$datamin[$i] = 0;
}
// Fabrication tableau 4b
$file= $conf->bank->dir_temp."/credmovement".$id."-".$year.".png";
$fileurl=DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/credmovement".$id."-".$year.".png";
$title=$langs->transnoentities("Credit").' - '.$langs->transnoentities("Year").': '.($year-2).' - '.($year-1)." - ".$year;
$graph_datas=array();
for($i=0;$i<12;$i++)
$file = $conf->bank->dir_temp."/credmovement".$id."-".$year.".png";
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/credmovement".$id."-".$year.".png";
$title = $langs->transnoentities("Credit").' - '.$langs->transnoentities("Year").': '.($year - 2).' - '.($year - 1)." - ".$year;
$graph_datas = array();
for ($i = 0; $i < 12; $i++)
{
$graph_datas[$i]=array($labels[$i], $data_year_0[$i], $data_year_1[$i], $data_year_2[$i]);
$graph_datas[$i] = array($labels[$i], $data_year_0[$i], $data_year_1[$i], $data_year_2[$i]);
}
$px1 = new DolGraph();
$px1->SetData($graph_datas);
$px1->SetLegend(array(($year),($year-1),($year-2)));
$px1->SetLegend(array(($year), ($year - 1), ($year - 2)));
$px1->SetLegendWidthMin(180);
$px1->SetMaxValue($px1->GetCeilMaxValue()<0?0:$px1->GetCeilMaxValue());
$px1->SetMinValue($px1->GetFloorMinValue()>0?0:$px1->GetFloorMinValue());
$px1->SetMaxValue($px1->GetCeilMaxValue() < 0 ? 0 : $px1->GetCeilMaxValue());
$px1->SetMinValue($px1->GetFloorMinValue() > 0 ? 0 : $px1->GetFloorMinValue());
$px1->SetTitle($title);
$px1->SetWidth($WIDTH);
$px1->SetHeight($HEIGHT);
$px1->SetType(array('line','line','line'));
$px1->SetType(array('line', 'line', 'line'));
$px1->SetShading(3);
$px1->setBgColor('onglet');
$px1->setBgColorGrid(array(255,255,255));
$px1->setBgColorGrid(array(255, 255, 255));
$px1->SetHorizTickIncrement(1);
$px1->draw($file, $fileurl);
@ -399,18 +399,18 @@ else
$tblyear[1] = array();
$tblyear[2] = array();
for ($annee=0;$annee<3;$annee++)
for ($annee = 0; $annee < 3; $annee++)
{
$sql = "SELECT date_format(b.datev,'%m')";
$sql.= ", SUM(b.amount)";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
$sql.= " AND b.datev >= '".($year-$annee)."-01-01 00:00:00'";
$sql.= " AND b.datev <= '".($year-$annee)."-12-31 23:59:59'";
$sql.= " AND b.amount < 0";
if ($id && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$id.")";
$sql .= ", SUM(b.amount)";
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql .= " WHERE b.fk_account = ba.rowid";
$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
$sql .= " AND b.datev >= '".($year - $annee)."-01-01 00:00:00'";
$sql .= " AND b.datev <= '".($year - $annee)."-12-31 23:59:59'";
$sql .= " AND b.amount < 0";
if ($id && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$id.")";
$sql .= " GROUP BY date_format(b.datev,'%m');";
$resql = $db->query($sql);
@ -437,37 +437,37 @@ else
$data_year_1 = array();
$data_year_2 = array();
for ($i = 0 ; $i < 12 ; $i++)
for ($i = 0; $i < 12; $i++)
{
$data_year_0[$i] = isset($tblyear[0][substr("0".($i+1), -2)]) ? $tblyear[0][substr("0".($i+1), -2)] : 0;
$data_year_1[$i] = isset($tblyear[1][substr("0".($i+1), -2)]) ? $tblyear[1][substr("0".($i+1), -2)] : 0;
$data_year_2[$i] = isset($tblyear[2][substr("0".($i+1), -2)]) ? $tblyear[2][substr("0".($i+1), -2)] : 0;
$labels[$i] = $langs->transnoentitiesnoconv("MonthVeryShort".sprintf("%02d", $i+1));
$data_year_0[$i] = isset($tblyear[0][substr("0".($i + 1), -2)]) ? $tblyear[0][substr("0".($i + 1), -2)] : 0;
$data_year_1[$i] = isset($tblyear[1][substr("0".($i + 1), -2)]) ? $tblyear[1][substr("0".($i + 1), -2)] : 0;
$data_year_2[$i] = isset($tblyear[2][substr("0".($i + 1), -2)]) ? $tblyear[2][substr("0".($i + 1), -2)] : 0;
$labels[$i] = $langs->transnoentitiesnoconv("MonthVeryShort".sprintf("%02d", $i + 1));
$datamin[$i] = 0;
}
$file= $conf->bank->dir_temp."/debmovement".$id."-".$year.".png";
$fileurl= DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/debmovement".$id."-".$year.".png";
$title=$langs->transnoentities("Debit").' - '.$langs->transnoentities("Year").': '.($year-2).' - '.($year-1)." - ".$year;
$graph_datas=array();
for($i=0;$i<12;$i++)
$file = $conf->bank->dir_temp."/debmovement".$id."-".$year.".png";
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/debmovement".$id."-".$year.".png";
$title = $langs->transnoentities("Debit").' - '.$langs->transnoentities("Year").': '.($year - 2).' - '.($year - 1)." - ".$year;
$graph_datas = array();
for ($i = 0; $i < 12; $i++)
{
$graph_datas[$i]=array($labels[$i], $data_year_0[$i], $data_year_1[$i], $data_year_2[$i]);
$graph_datas[$i] = array($labels[$i], $data_year_0[$i], $data_year_1[$i], $data_year_2[$i]);
}
$px2 = new DolGraph();
$px2->SetData($graph_datas);
$px2->SetLegend(array(($year),($year-1),($year-2)));
$px2->SetLegend(array(($year), ($year - 1), ($year - 2)));
$px2->SetLegendWidthMin(180);
$px2->SetMaxValue($px2->GetCeilMaxValue()<0?0:$px2->GetCeilMaxValue());
$px2->SetMinValue($px2->GetFloorMinValue()>0?0:$px2->GetFloorMinValue());
$px2->SetMaxValue($px2->GetCeilMaxValue() < 0 ? 0 : $px2->GetCeilMaxValue());
$px2->SetMinValue($px2->GetFloorMinValue() > 0 ? 0 : $px2->GetFloorMinValue());
$px2->SetTitle($title);
$px2->SetWidth($WIDTH);
$px2->SetHeight($HEIGHT);
$px2->SetType(array('line','line','line'));
$px2->SetType(array('line', 'line', 'line'));
$px2->SetShading(3);
$px2->setBgColor('onglet');
$px2->setBgColorGrid(array(255,255,255));
$px2->setBgColorGrid(array(255, 255, 255));
$px2->SetHorizTickIncrement(1);
$px2->draw($file, $fileurl);
@ -479,9 +479,9 @@ else
unset($tblyear[1]);
unset($tblyear[2]);
print '<div class="fichecenter"><div class="fichehalfleft"><div align="center">'; // do not use class="center" here, it will have no effect for the js graph inside.
print '<div class="fichecenter"><div class="fichehalfleft"><div align="center">'; // do not use class="center" here, it will have no effect for the js graph inside.
print $show1;
print '</div></div><div class="fichehalfright"><div class="ficheaddleft"><div align="center">'; // do not use class="center" here, it will have no effect for the js graph inside.
print '</div></div><div class="fichehalfright"><div class="ficheaddleft"><div align="center">'; // do not use class="center" here, it will have no effect for the js graph inside.
print $show2;
print '</div></div></div></div>';
print '<div style="clear:both"></div>';

View File

@ -43,38 +43,38 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("banks","categories","companies","bills","trips"));
$langs->loadLangs(array("banks", "categories", "companies", "bills", "trips"));
$action=GETPOST('action', 'alpha');
$id=GETPOST('account', 'int');
$ref=GETPOST('ref', 'alpha');
$dvid=GETPOST('dvid', 'alpha');
$numref=GETPOST('num', 'alpha');
$ve=GETPOST("ve", 'alpha');
$brref=GETPOST('brref', 'alpha');
$oldbankreceipt=GETPOST('oldbankreceipt', 'alpha');
$newbankreceipt=GETPOST('newbankreceipt', 'alpha');
$action = GETPOST('action', 'alpha');
$id = GETPOST('account', 'int');
$ref = GETPOST('ref', 'alpha');
$dvid = GETPOST('dvid', 'alpha');
$numref = GETPOST('num', 'alpha');
$ve = GETPOST("ve", 'alpha');
$brref = GETPOST('brref', 'alpha');
$oldbankreceipt = GETPOST('oldbankreceipt', 'alpha');
$newbankreceipt = GETPOST('newbankreceipt', 'alpha');
// Security check
$fieldid = (! empty($ref)?$ref:$id);
$fieldname = isset($ref)?'ref':'rowid';
if ($user->socid) $socid=$user->socid;
$result=restrictedArea($user, 'banque', $fieldid, 'bank_account', '', '', $fieldname);
$fieldid = (!empty($ref) ? $ref : $id);
$fieldname = isset($ref) ? 'ref' : 'rowid';
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'banque', $fieldid, 'bank_account', '', '', $fieldname);
if ($user->rights->banque->consolidate && $action == 'dvnext' && ! empty($dvid))
if ($user->rights->banque->consolidate && $action == 'dvnext' && !empty($dvid))
{
$al = new AccountLine($db);
$al->datev_next($dvid);
}
if ($user->rights->banque->consolidate && $action == 'dvprev' && ! empty($dvid))
if ($user->rights->banque->consolidate && $action == 'dvprev' && !empty($dvid))
{
$al = new AccountLine($db);
$al->datev_previous($dvid);
}
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int');
@ -84,31 +84,31 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="s.nom";
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "s.nom";
$object = new Account($db);
if ($id > 0 || ! empty($ref))
if ($id > 0 || !empty($ref))
{
$result=$object->fetch($id, $ref);
$account = $object->id; // Force the search field on id of account
$result = $object->fetch($id, $ref);
$account = $object->id; // Force the search field on id of account
}
// Initialize technical object to manage context to save list fields
$contextpage='banktransactionlist'.(empty($object->ref)?'':'-'.$object->id);
$contextpage = 'banktransactionlist'.(empty($object->ref) ? '' : '-'.$object->id);
// Define number of receipt to show (current, previous or next one ?)
$found=false;
$found = false;
if ($_GET["rel"] == 'prev')
{
// Recherche valeur pour num = numero releve precedent
$sql = "SELECT DISTINCT(b.num_releve) as num";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= " WHERE b.num_releve < '".$db->escape($numref)."'";
$sql.= " AND b.fk_account = ".$object->id;
$sql.= " ORDER BY b.num_releve DESC";
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= " WHERE b.num_releve < '".$db->escape($numref)."'";
$sql .= " AND b.fk_account = ".$object->id;
$sql .= " ORDER BY b.num_releve DESC";
dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG);
$resql = $db->query($sql);
@ -119,7 +119,7 @@ if ($_GET["rel"] == 'prev')
{
$obj = $db->fetch_object($resql);
$numref = $obj->num;
$found=true;
$found = true;
}
}
}
@ -127,10 +127,10 @@ elseif ($_GET["rel"] == 'next')
{
// Recherche valeur pour num = numero releve precedent
$sql = "SELECT DISTINCT(b.num_releve) as num";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= " WHERE b.num_releve > '".$db->escape($numref)."'";
$sql.= " AND b.fk_account = ".$object->id;
$sql.= " ORDER BY b.num_releve ASC";
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= " WHERE b.num_releve > '".$db->escape($numref)."'";
$sql .= " AND b.fk_account = ".$object->id;
$sql .= " ORDER BY b.num_releve ASC";
dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG);
$resql = $db->query($sql);
@ -141,29 +141,29 @@ elseif ($_GET["rel"] == 'next')
{
$obj = $db->fetch_object($resql);
$numref = $obj->num;
$found=true;
$found = true;
}
}
}
else {
// On veut le releve num
$found=true;
$found = true;
}
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv,";
$sql.= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,";
$sql.= " b.fk_bordereau,";
$sql.= " bc.ref,";
$sql.= " ba.rowid as bankid, ba.ref as bankref, ba.label as banklabel";
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= ", ".MAIN_DB_PREFIX."bank as b";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bordereau_cheque as bc ON bc.rowid=b.fk_bordereau';
$sql.= " WHERE b.num_releve='".$db->escape($numref)."'";
if (empty($numref)) $sql.= " OR b.num_releve is null";
$sql.= " AND b.fk_account = ".$object->id;
$sql.= " AND b.fk_account = ba.rowid";
$sql.= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day
$sql .= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,";
$sql .= " b.fk_bordereau,";
$sql .= " bc.ref,";
$sql .= " ba.rowid as bankid, ba.ref as bankref, ba.label as banklabel";
$sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
$sql .= ", ".MAIN_DB_PREFIX."bank as b";
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bordereau_cheque as bc ON bc.rowid=b.fk_bordereau';
$sql .= " WHERE b.num_releve='".$db->escape($numref)."'";
if (empty($numref)) $sql .= " OR b.num_releve is null";
$sql .= " AND b.fk_account = ".$object->id;
$sql .= " AND b.fk_account = ba.rowid";
$sql .= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day
$sqlrequestforbankline = $sql;
@ -173,14 +173,14 @@ $sqlrequestforbankline = $sql;
* Actions
*/
if ($action == 'confirm_editbankreceipt' && ! empty($oldbankreceipt) && ! empty($newbankreceipt))
if ($action == 'confirm_editbankreceipt' && !empty($oldbankreceipt) && !empty($newbankreceipt))
{
// TODO Add a test to check newbankreceipt does not exists yet
$sqlupdate = 'UPDATE '.MAIN_DB_PREFIX.'bank SET num_releve = "'.$db->escape($newbankreceipt).'" WHERE num_releve = "'.$db->escape($oldbankreceipt).'"';
$result = $db->query($sqlupdate);
if ($result < 0) dol_print_error($db);
$action='view';
$action = 'view';
}
@ -193,33 +193,33 @@ $helpurl = "";
llxHeader('', $title, $helpurl);
$form = new Form($db);
$societestatic=new Societe($db);
$chargestatic=new ChargeSociales($db);
$memberstatic=new Adherent($db);
$paymentstatic=new Paiement($db);
$paymentsupplierstatic=new PaiementFourn($db);
$paymentvatstatic=new TVA($db);
$bankstatic=new Account($db);
$banklinestatic=new AccountLine($db);
$societestatic = new Societe($db);
$chargestatic = new ChargeSociales($db);
$memberstatic = new Adherent($db);
$paymentstatic = new Paiement($db);
$paymentsupplierstatic = new PaiementFourn($db);
$paymentvatstatic = new TVA($db);
$bankstatic = new Account($db);
$banklinestatic = new AccountLine($db);
$remisestatic = new RemiseCheque($db);
// Must be before button action
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($id > 0) $param.='&id='.urlencode($id);
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
if ($id > 0) $param .= '&id='.urlencode($id);
if (empty($numref))
{
$sortfield='numr';
$sortorder='DESC';
$sortfield = 'numr';
$sortorder = 'DESC';
// List of all standing receipts
$sql = "SELECT DISTINCT(b.num_releve) as numr";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= " WHERE b.fk_account = ".$object->id;
$sql.=$db->order($sortfield, $sortorder);
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= " WHERE b.fk_account = ".$object->id;
$sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
@ -229,7 +229,7 @@ if (empty($numref))
$nbtotalofrecords = $db->num_rows($result);
}
$sql.= $db->plimit($conf->liste_limit+1, $offset);
$sql .= $db->plimit($conf->liste_limit + 1, $offset);
$result = $db->query($sql);
if ($result)
@ -238,7 +238,7 @@ if (empty($numref))
$i = 0;
// Onglets
$head=bank_prepare_head($object);
$head = bank_prepare_head($object);
dol_fiche_head($head, 'statement', $langs->trans("FinancialAccount"), 0, 'account');
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
@ -279,14 +279,14 @@ if (empty($numref))
print '<td></td>';
print '</tr>';
$balancestart=array();
$content=array();
$balancestart = array();
$content = array();
while ($i < min($numrows, $conf->liste_limit))
{
$objp = $db->fetch_object($result);
if (! isset($objp->numr))
if (!isset($objp->numr))
{
//
}
@ -309,13 +309,13 @@ if (empty($numref))
// Calculate start amount
$sql = "SELECT sum(b.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= " WHERE b.num_releve < '".$db->escape($objp->numr)."'";
$sql.= " AND b.fk_account = ".$object->id;
$resql=$db->query($sql);
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= " WHERE b.num_releve < '".$db->escape($objp->numr)."'";
$sql .= " AND b.fk_account = ".$object->id;
$resql = $db->query($sql);
if ($resql)
{
$obj=$db->fetch_object($resql);
$obj = $db->fetch_object($resql);
$balancestart[$objp->numr] = $obj->amount;
$db->free($resql);
}
@ -323,17 +323,17 @@ if (empty($numref))
// Calculate end amount
$sql = "SELECT sum(b.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= " WHERE b.num_releve = '".$db->escape($objp->numr)."'";
$sql.= " AND b.fk_account = ".$object->id;
$resql=$db->query($sql);
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= " WHERE b.num_releve = '".$db->escape($objp->numr)."'";
$sql .= " AND b.fk_account = ".$object->id;
$resql = $db->query($sql);
if ($resql)
{
$obj=$db->fetch_object($resql);
$obj = $db->fetch_object($resql);
$content[$objp->numr] = $obj->amount;
$db->free($resql);
}
print '<td class="right">'.price(($balancestart[$objp->numr]+$content[$objp->numr]), '', $langs, 1, -1, -1, $conf->currency).'</td>';
print '<td class="right">'.price(($balancestart[$objp->numr] + $content[$objp->numr]), '', $langs, 1, -1, -1, $conf->currency).'</td>';
print '<td class="center">';
if ($user->rights->banque->consolidate && $action != 'editbankreceipt') {
@ -362,20 +362,20 @@ else
*/
// Onglets
$head=account_statement_prepare_head($object, $numref);
$head = account_statement_prepare_head($object, $numref);
dol_fiche_head($head, 'statement', $langs->trans("FinancialAccount"), 0, 'account');
$mesprevnext='';
$mesprevnext.='<div class="pagination"><ul>';
$mesprevnext.='<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=prev&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-left" title="'.dol_escape_htmltag($langs->trans("Previous")).'"></i></a></li>';
$mesprevnext = '';
$mesprevnext .= '<div class="pagination"><ul>';
$mesprevnext .= '<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=prev&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-left" title="'.dol_escape_htmltag($langs->trans("Previous")).'"></i></a></li>';
//$mesprevnext.=' &nbsp; ';
$mesprevnext.='<li class="pagination"><span class="active">'.$langs->trans("AccountStatement")." ".$numref.'</span></li>';
$mesprevnext .= '<li class="pagination"><span class="active">'.$langs->trans("AccountStatement")." ".$numref.'</span></li>';
//$mesprevnext.=' &nbsp; ';
$mesprevnext.='<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=next&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-right" title="'.dol_escape_htmltag($langs->trans("Next")).'"></i></a></li>';
$mesprevnext.='</ul></div>';
$mesprevnext .= '<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=next&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-right" title="'.dol_escape_htmltag($langs->trans("Next")).'"></i></a></li>';
$mesprevnext .= '</ul></div>';
$title=$langs->trans("AccountStatement").' '.$numref.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts');
$title = $langs->trans("AccountStatement").' '.$numref.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts');
print load_fiche_titre($title, $mesprevnext, 'title_bank.png');
//print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, 0, $nbtotalofrecords, 'title_bank.png', 0, '', '', 0, 1);
@ -398,14 +398,14 @@ else
// Calcul du solde de depart du releve
$sql = "SELECT sum(b.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= " WHERE b.num_releve < '".$db->escape($numref)."'";
$sql.= " AND b.fk_account = ".$object->id;
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= " WHERE b.num_releve < '".$db->escape($numref)."'";
$sql .= " AND b.fk_account = ".$object->id;
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
$obj=$db->fetch_object($resql);
$obj = $db->fetch_object($resql);
$total = $obj->amount;
$db->free($resql);
}
@ -437,142 +437,142 @@ else
// Date de valeur
print '<td valign="center" class="center nowrap">';
print dol_print_date($db->jdate($objp->dv), "day") .' ';
print dol_print_date($db->jdate($objp->dv), "day").' ';
print '<a href="releve.php?action=dvprev&amp;num='.$numref.'&amp;account='.$object->id.'&amp;dvid='.$objp->rowid.'">';
print img_edit_remove() . "</a> ";
print img_edit_remove()."</a> ";
print '<a href="releve.php?action=dvnext&amp;num='.$numref.'&amp;account='.$object->id.'&amp;dvid='.$objp->rowid.'">';
print img_edit_add() ."</a>";
print img_edit_add()."</a>";
print "</td>\n";
print '<a class="ajax" href="'.$_SERVER['PHP_SELF'].'?action=dvnext&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';
// Type and num
if ($objp->fk_type == 'SOLD') {
$type_label='&nbsp;';
$type_label = '&nbsp;';
} else {
$type_label=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$objp->fk_type;
$type_label = ($langs->trans("PaymentTypeShort".$objp->fk_type) != "PaymentTypeShort".$objp->fk_type) ? $langs->trans("PaymentTypeShort".$objp->fk_type) : $objp->fk_type;
}
$link='';
if ($objp->fk_bordereau>0) {
$link = '';
if ($objp->fk_bordereau > 0) {
$remisestatic->id = $objp->fk_bordereau;
$remisestatic->ref = $objp->ref;
$link = ' '.$remisestatic->getNomUrl(1);
}
print '<td class="nowrap">'.$type_label.' '.($objp->num_chq?$objp->num_chq:'').$link.'</td>';
print '<td class="nowrap">'.$type_label.' '.($objp->num_chq ? $objp->num_chq : '').$link.'</td>';
// Description
print '<td valign="center"><a href="'.DOL_URL_ROOT.'/compta/bank/line.php?rowid='.$objp->rowid.'&amp;account='.$object->id.'">';
$reg=array();
preg_match('/\((.+)\)/i', $objp->label, $reg); // Si texte entoure de parenthese on tente recherche de traduction
if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) print $langs->trans($reg[1]);
$reg = array();
preg_match('/\((.+)\)/i', $objp->label, $reg); // Si texte entoure de parenthese on tente recherche de traduction
if ($reg[1] && $langs->trans($reg[1]) != $reg[1]) print $langs->trans($reg[1]);
else print $objp->label;
print '</a>';
/*
* Ajout les liens (societe, company...)
*/
$newline=1;
$newline = 1;
$links = $object->get_url($objp->rowid);
foreach($links as $key=>$val)
foreach ($links as $key=>$val)
{
if (! $newline) print ' - ';
if (!$newline) print ' - ';
else print '<br>';
if ($links[$key]['type']=='payment')
if ($links[$key]['type'] == 'payment')
{
$paymentstatic->id=$links[$key]['url_id'];
$paymentstatic->ref=$langs->trans("Payment");
$paymentstatic->id = $links[$key]['url_id'];
$paymentstatic->ref = $langs->trans("Payment");
print ' '.$paymentstatic->getNomUrl(1);
$newline=0;
$newline = 0;
}
elseif ($links[$key]['type']=='payment_supplier')
elseif ($links[$key]['type'] == 'payment_supplier')
{
$paymentsupplierstatic->id=$links[$key]['url_id'];
$paymentsupplierstatic->ref=$langs->trans("Payment");
$paymentsupplierstatic->id = $links[$key]['url_id'];
$paymentsupplierstatic->ref = $langs->trans("Payment");
print ' '.$paymentsupplierstatic->getNomUrl(1);
$newline=0;
$newline = 0;
}
elseif ($links[$key]['type']=='payment_sc')
elseif ($links[$key]['type'] == 'payment_sc')
{
print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$links[$key]['url_id'].'">';
print ' '.img_object($langs->trans('ShowPayment'), 'payment').' ';
print $langs->trans("SocialContributionPayment");
print '</a>';
$newline=0;
$newline = 0;
}
elseif ($links[$key]['type']=='payment_vat')
elseif ($links[$key]['type'] == 'payment_vat')
{
$paymentvatstatic->id=$links[$key]['url_id'];
$paymentvatstatic->ref=$langs->trans("Payment");
$paymentvatstatic->id = $links[$key]['url_id'];
$paymentvatstatic->ref = $langs->trans("Payment");
print ' '.$paymentvatstatic->getNomUrl(1);
}
elseif ($links[$key]['type']=='payment_salary')
elseif ($links[$key]['type'] == 'payment_salary')
{
print '<a href="'.DOL_URL_ROOT.'/salaries/card.php?id='.$links[$key]['url_id'].'">';
print ' '.img_object($langs->trans('ShowPayment'), 'payment').' ';
print $langs->trans("Payment");
print '</a>';
$newline=0;
$newline = 0;
}
elseif ($links[$key]['type']=='banktransfert') {
elseif ($links[$key]['type'] == 'banktransfert') {
// Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail.
if ($objp->amount > 0)
{
$banklinestatic->fetch($links[$key]['url_id']);
$bankstatic->id=$banklinestatic->fk_account;
$bankstatic->label=$banklinestatic->bank_account_label;
$bankstatic->id = $banklinestatic->fk_account;
$bankstatic->label = $banklinestatic->bank_account_label;
print ' ('.$langs->trans("from").' ';
print $bankstatic->getNomUrl(1, 'transactions');
print ' '.$langs->trans("toward").' ';
$bankstatic->id=$objp->bankid;
$bankstatic->label=$objp->bankref;
$bankstatic->id = $objp->bankid;
$bankstatic->label = $objp->bankref;
print $bankstatic->getNomUrl(1, '');
print ')';
}
else
{
$bankstatic->id=$objp->bankid;
$bankstatic->label=$objp->bankref;
$bankstatic->id = $objp->bankid;
$bankstatic->label = $objp->bankref;
print ' ('.$langs->trans("from").' ';
print $bankstatic->getNomUrl(1, '');
print ' '.$langs->trans("toward").' ';
$banklinestatic->fetch($links[$key]['url_id']);
$bankstatic->id=$banklinestatic->fk_account;
$bankstatic->label=$banklinestatic->bank_account_label;
$bankstatic->id = $banklinestatic->fk_account;
$bankstatic->label = $banklinestatic->bank_account_label;
print $bankstatic->getNomUrl(1, 'transactions');
print ')';
}
}
elseif ($links[$key]['type']=='company') {
elseif ($links[$key]['type'] == 'company') {
$societestatic->id = $links[$key]['url_id'];
$societestatic->name = $links[$key]['label'];
print $societestatic->getNomUrl(1, 'company', 24);
$newline=0;
$newline = 0;
}
elseif ($links[$key]['type']=='member') {
elseif ($links[$key]['type'] == 'member') {
print '<a href="'.DOL_URL_ROOT.'/adherents/card.php?rowid='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowMember'), 'user').' ';
print $links[$key]['label'];
print '</a>';
$newline=0;
$newline = 0;
}
elseif ($links[$key]['type']=='user') {
elseif ($links[$key]['type'] == 'user') {
print '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowUser'), 'user').' ';
print $links[$key]['label'];
print '</a>';
$newline=0;
$newline = 0;
}
elseif ($links[$key]['type']=='sc') {
elseif ($links[$key]['type'] == 'sc') {
print '<a href="'.DOL_URL_ROOT.'/compta/sociales/card.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowBill'), 'bill').' ';
print $langs->trans("SocialContribution");
print '</a>';
$newline=0;
$newline = 0;
}
else {
print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
print $links[$key]['label'];
print '</a>';
$newline=0;
$newline = 0;
}
}
@ -580,18 +580,18 @@ else
if ($ve)
{
$sql = "SELECT label";
$sql.= " FROM ".MAIN_DB_PREFIX."bank_categ as ct";
$sql.= ", ".MAIN_DB_PREFIX."bank_class as cl";
$sql.= " WHERE ct.rowid = cl.fk_categ";
$sql.= " AND ct.entity = ".$conf->entity;
$sql.= " AND cl.lineid = ".$objp->rowid;
$sql .= " FROM ".MAIN_DB_PREFIX."bank_categ as ct";
$sql .= ", ".MAIN_DB_PREFIX."bank_class as cl";
$sql .= " WHERE ct.rowid = cl.fk_categ";
$sql .= " AND ct.entity = ".$conf->entity;
$sql .= " AND cl.lineid = ".$objp->rowid;
$resc = $db->query($sql);
if ($resc)
{
$numc = $db->num_rows($resc);
$ii = 0;
if ($numc && ! $newline) print '<br>';
if ($numc && !$newline) print '<br>';
while ($ii < $numc)
{
$objc = $db->fetch_object($resc);

View File

@ -45,17 +45,17 @@ $hookmanager->initHooks(array('specialexpensesindex'));
$langs->loadLangs(array('compta', 'bills'));
// Security check
if ($user->socid) $socid=$user->socid;
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'tax|salaries', '', '', 'charges|');
$mode=GETPOST("mode", 'alpha');
$year=GETPOST("year", 'int');
$filtre=GETPOST("filtre", 'alpha');
if (! $year && $mode != 'sconly') { $year=date("Y", time()); }
$mode = GETPOST("mode", 'alpha');
$year = GETPOST("year", 'int');
$filtre = GETPOST("filtre", 'alpha');
if (!$year && $mode != 'sconly') { $year = date("Y", time()); }
$search_account = GETPOST('search_account', 'int');
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int');
@ -63,8 +63,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) $sortfield="cs.date_ech";
if (! $sortorder) $sortorder="DESC";
if (!$sortfield) $sortfield = "cs.date_ech";
if (!$sortorder) $sortorder = "DESC";
/*
@ -72,22 +72,22 @@ if (! $sortorder) $sortorder="DESC";
*/
$tva_static = new Tva($db);
$socialcontrib=new ChargeSociales($db);
$payment_sc_static=new PaymentSocialContribution($db);
$socialcontrib = new ChargeSociales($db);
$payment_sc_static = new PaymentSocialContribution($db);
$sal_static = new PaymentSalary($db);
$accountstatic = new Account($db);
llxHeader('', $langs->trans("SpecialExpensesArea"));
$title=$langs->trans("SpecialExpensesArea");
if ($mode == 'sconly') $title=$langs->trans("SocialContributionsPayments");
$title = $langs->trans("SpecialExpensesArea");
if ($mode == 'sconly') $title = $langs->trans("SocialContributionsPayments");
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($mode == 'sconly') $param='&mode=sconly';
if ($sortfield) $param.='&sortfield='.$sortfield;
if ($sortorder) $param.='&sortorder='.$sortorder;
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
if ($mode == 'sconly') $param = '&mode=sconly';
if ($sortfield) $param .= '&sortfield='.$sortfield;
if ($sortorder) $param .= '&sortorder='.$sortorder;
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
@ -101,7 +101,7 @@ print '<input type="hidden" name="mode" value="'.$mode.'">';
if ($mode != 'sconly')
{
$center=($year?'<a href="index.php?year='.($year-1).$param.'">'.img_previous($langs->trans("Previous"), 'class="valignbottom"')."</a> ".$langs->trans("Year").' '.$year.' <a href="index.php?year='.($year+1).$param.'">'.img_next($langs->trans("Next"), 'class="valignbottom"')."</a>":"");
$center = ($year ? '<a href="index.php?year='.($year - 1).$param.'">'.img_previous($langs->trans("Previous"), 'class="valignbottom"')."</a> ".$langs->trans("Year").' '.$year.' <a href="index.php?year='.($year + 1).$param.'">'.img_next($langs->trans("Next"), 'class="valignbottom"')."</a>" : "");
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit, 1);
}
else
@ -109,7 +109,7 @@ else
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit);
}
if ($year) $param.='&year='.$year;
if ($year) $param .= '&year='.$year;
if ($mode != 'sconly')
{
@ -117,12 +117,12 @@ if ($mode != 'sconly')
print "<br>";
}
if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
{
// Social contributions only
if ($mode != 'sconly')
{
print load_fiche_titre($langs->trans("SocialContributionsPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', '');
print load_fiche_titre($langs->trans("SocialContributionsPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', '');
}
print '<table class="noborder centpercent">';
@ -134,23 +134,23 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pc.rowid", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pc.datep", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder);
if (! empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
if (!empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pc.amount", "", $param, 'class="right"', $sortfield, $sortorder);
print "</tr>\n";
$sql = "SELECT c.id, c.libelle as label,";
$sql.= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,";
$sql.= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment, pc.fk_bank,";
$sql.= " pct.code as payment_code,";
$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,";
$sql.= " ".MAIN_DB_PREFIX."chargesociales as cs";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pc.fk_bank = b.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
$sql.= " WHERE cs.fk_type = c.id";
$sql.= " AND cs.entity IN (".getEntity("tax").")";
$sql .= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,";
$sql .= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment, pc.fk_bank,";
$sql .= " pct.code as payment_code,";
$sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
$sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,";
$sql .= " ".MAIN_DB_PREFIX."chargesociales as cs";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pc.fk_bank = b.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
$sql .= " WHERE cs.fk_type = c.id";
$sql .= " AND cs.entity IN (".getEntity("tax").")";
if ($year > 0)
{
$sql .= " AND (";
@ -160,12 +160,12 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
$sql .= " OR (cs.periode IS NULL AND cs.date_ech between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')";
$sql .= ")";
}
if (preg_match('/^cs\./', $sortfield) || preg_match('/^c\./', $sortfield) || preg_match('/^pc\./', $sortfield) || preg_match('/^pct\./', $sortfield)) $sql.= $db->order($sortfield, $sortorder);
if (preg_match('/^cs\./', $sortfield) || preg_match('/^c\./', $sortfield) || preg_match('/^pc\./', $sortfield) || preg_match('/^pct\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder);
//$sql.= $db->plimit($limit+1,$offset);
//print $sql;
dol_syslog("compta/charges/index.php: select payment", LOG_DEBUG);
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
@ -179,14 +179,14 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
// Date
$date=$obj->periode;
if (empty($date)) $date=$obj->date_ech;
$date = $obj->periode;
if (empty($date)) $date = $obj->date_ech;
print '<td>'.dol_print_date($date, 'day').'</td>';
// Label
print '<td>';
$socialcontrib->id=$obj->rowid;
$socialcontrib->ref=$obj->label;
$socialcontrib->label=$obj->label;
$socialcontrib->id = $obj->rowid;
$socialcontrib->ref = $obj->label;
$socialcontrib->label = $obj->label;
print $socialcontrib->getNomUrl(1, '20');
print '</td>';
// Type
@ -194,8 +194,8 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
// Expected to pay
print '<td class="right">'.price($obj->total).'</td>';
// Ref payment
$payment_sc_static->id=$obj->pid;
$payment_sc_static->ref=$obj->pid;
$payment_sc_static->id = $obj->pid;
$payment_sc_static->ref = $obj->pid;
print '<td>'.$payment_sc_static->getNomUrl(1)."</td>\n";
// Date payment
print '<td align="center">'.dol_print_date($db->jdate($obj->datep), 'day').'</td>';
@ -204,18 +204,18 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' ';
print $obj->num_payment.'</td>';
// Account
if (! empty($conf->banque->enabled))
if (!empty($conf->banque->enabled))
{
print '<td>';
if ($obj->fk_bank > 0)
{
//$accountstatic->fetch($obj->fk_bank);
$accountstatic->id=$obj->bid;
$accountstatic->ref=$obj->bref;
$accountstatic->number=$obj->bnumber;
$accountstatic->accountancy_number=$obj->account_number;
$accountstatic->accountancy_journal=$obj->accountancy_journal;
$accountstatic->label=$obj->blabel;
$accountstatic->id = $obj->bid;
$accountstatic->ref = $obj->bref;
$accountstatic->number = $obj->bnumber;
$accountstatic->accountancy_number = $obj->account_number;
$accountstatic->accountancy_journal = $obj->accountancy_journal;
$accountstatic->label = $obj->blabel;
print $accountstatic->getNomUrl(1);
}
else print '&nbsp;';
@ -233,11 +233,11 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
$i++;
}
print '<tr class="liste_total"><td colspan="3" class="liste_total">'.$langs->trans("Total").'</td>';
print '<td class="liste_total right"></td>'; // A total here has no sense
print '<td class="liste_total right"></td>'; // A total here has no sense
print '<td align="center" class="liste_total">&nbsp;</td>';
print '<td align="center" class="liste_total">&nbsp;</td>';
print '<td align="center" class="liste_total">&nbsp;</td>';
if (! empty($conf->banque->enabled)) print '<td></td>';
if (!empty($conf->banque->enabled)) print '<td></td>';
print '<td class="liste_total right">'.price($totalpaye)."</td>";
print "</tr>";
}
@ -249,38 +249,38 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
}
// VAT
if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
{
if (! $mode || $mode != 'sconly')
if (!$mode || $mode != 'sconly')
{
print "<br>";
$tva = new Tva($db);
print load_fiche_titre($langs->trans("VATPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', '');
print load_fiche_titre($langs->trans("VATPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', '');
$sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.fk_bank,";
$sql.= " pct.code as payment_code,";
$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
$sql.= " FROM ".MAIN_DB_PREFIX."tva as pv";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pv.fk_bank = b.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pv.fk_typepayment = pct.id";
$sql.= " WHERE pv.entity IN (".getEntity("tax").")";
$sql .= " pct.code as payment_code,";
$sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
$sql .= " FROM ".MAIN_DB_PREFIX."tva as pv";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pv.fk_bank = b.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pv.fk_typepayment = pct.id";
$sql .= " WHERE pv.entity IN (".getEntity("tax").")";
if ($year > 0)
{
// Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance,
// ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire
$sql.= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'";
$sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'";
}
if (preg_match('/^pv\./', $sortfield)) $sql.= $db->order($sortfield, $sortorder);
if (preg_match('/^pv\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
$total = 0 ;
$total = 0;
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'width="140px"', $sortfield, $sortorder);
@ -289,10 +289,10 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pv.rowid", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder);
if (! empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
if (!empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pv.amount", "", $param, 'class="right"', $sortfield, $sortorder);
print "</tr>\n";
$var=1;
$var = 1;
while ($i < $num)
{
$obj = $db->fetch_object($result);
@ -308,8 +308,8 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
print '<td class="right">'.price($obj->amount)."</td>";
// Ref payment
$tva_static->id=$obj->rowid;
$tva_static->ref=$obj->rowid;
$tva_static->id = $obj->rowid;
$tva_static->ref = $obj->rowid;
print '<td class="left">'.$tva_static->getNomUrl(1)."</td>\n";
// Date
@ -321,18 +321,18 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
print $obj->num_payment.'</td>';
// Account
if (! empty($conf->banque->enabled))
if (!empty($conf->banque->enabled))
{
print '<td>';
if ($obj->fk_bank > 0)
{
//$accountstatic->fetch($obj->fk_bank);
$accountstatic->id=$obj->bid;
$accountstatic->ref=$obj->bref;
$accountstatic->number=$obj->bnumber;
$accountstatic->accountancy_number=$obj->account_number;
$accountstatic->accountancy_journal=$obj->accountancy_journal;
$accountstatic->label=$obj->blabel;
$accountstatic->id = $obj->bid;
$accountstatic->ref = $obj->bref;
$accountstatic->number = $obj->bnumber;
$accountstatic->accountancy_number = $obj->account_number;
$accountstatic->accountancy_journal = $obj->accountancy_journal;
$accountstatic->label = $obj->blabel;
print $accountstatic->getNomUrl(1);
}
else print '&nbsp;';
@ -365,55 +365,55 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
}
// Localtax
if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1")
{
$j=1;
$numlt=3;
$j = 1;
$numlt = 3;
}
elseif($mysoc->localtax1_assuj=="1")
elseif ($mysoc->localtax1_assuj == "1")
{
$j=1;
$numlt=2;
$j = 1;
$numlt = 2;
}
elseif($mysoc->localtax2_assuj=="1")
elseif ($mysoc->localtax2_assuj == "1")
{
$j=2;
$numlt=3;
$j = 2;
$numlt = 3;
}
else
{
$j=0;
$numlt=0;
$j = 0;
$numlt = 0;
}
while($j<$numlt)
while ($j < $numlt)
{
if (! $mode || $mode != 'sconly')
if (!$mode || $mode != 'sconly')
{
print "<br>";
$tva = new Tva($db);
print load_fiche_titre($langs->transcountry(($j==1?"LT1Payments":"LT2Payments"), $mysoc->country_code).($year?' ('.$langs->trans("Year").' '.$year.')':''), '', '');
print load_fiche_titre($langs->transcountry(($j == 1 ? "LT1Payments" : "LT2Payments"), $mysoc->country_code).($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', '');
$sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.datep as dp";
$sql.= " FROM ".MAIN_DB_PREFIX."localtax as pv";
$sql.= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".$j ;
$sql .= " FROM ".MAIN_DB_PREFIX."localtax as pv";
$sql .= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".$j;
if ($year > 0)
{
// Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance,
// ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire
$sql.= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'";
$sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'";
}
if (preg_match('/^pv/', $sortfield)) $sql.= $db->order($sortfield, $sortorder);
if (preg_match('/^pv/', $sortfield)) $sql .= $db->order($sortfield, $sortorder);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
$total = 0 ;
$total = 0;
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'width="120"', $sortfield, $sortorder);
@ -435,8 +435,8 @@ while($j<$numlt)
print "<td>".$obj->label."</td>\n";
// Ref payment
$tva_static->id=$obj->rowid;
$tva_static->ref=$obj->rowid;
$tva_static->id = $obj->rowid;
$tva_static->ref = $obj->rowid;
print '<td class="left">'.$tva_static->getNomUrl(1)."</td>\n";
print '<td align="center">'.dol_print_date($db->jdate($obj->dp), 'day')."</td>\n";
@ -462,39 +462,39 @@ while($j<$numlt)
// Payment Salary
if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read))
{
if (! $mode || $mode != 'sconly')
if (!$mode || $mode != 'sconly')
{
$sal = new PaymentSalary($db);
print "<br>";
print load_fiche_titre($langs->trans("SalariesPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', '');
print load_fiche_titre($langs->trans("SalariesPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', '');
$sql = "SELECT s.rowid, s.amount, s.label, s.datep as datep, s.datev as datev, s.datesp, s.dateep, s.salary, s.fk_bank, u.salary as current_salary,";
$sql.= " pct.code as payment_code,";
$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON s.fk_typepayment = pct.id";
$sql.= " , ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE s.entity IN (".getEntity('user').")";
$sql.= " AND u.rowid = s.fk_user";
$sql .= " pct.code as payment_code,";
$sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
$sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as s";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON s.fk_typepayment = pct.id";
$sql .= " , ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE s.entity IN (".getEntity('user').")";
$sql .= " AND u.rowid = s.fk_user";
if ($year > 0)
{
$sql.= " AND (s.datesp between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'";
$sql.= " OR s.dateep between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."')";
$sql .= " AND (s.datesp between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'";
$sql .= " OR s.dateep between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."')";
}
if (preg_match('/^s\./', $sortfield)) $sql.= $db->order($sortfield, $sortorder);
if (preg_match('/^s\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
$total = 0 ;
$total = 0;
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "s.dateep", "", $param, 'width="140px"', $sortfield, $sortorder);
@ -502,7 +502,7 @@ if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "s.rowid", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "s.datep", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder);
if (! empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
if (!empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder);
print "</tr>\n";
@ -520,8 +520,8 @@ if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
print "<td>".$obj->label."</td>\n";
// Ref payment
$sal_static->id=$obj->rowid;
$sal_static->ref=$obj->rowid;
$sal_static->id = $obj->rowid;
$sal_static->ref = $obj->rowid;
print '<td class="left">'.$sal_static->getNomUrl(1)."</td>\n";
// Date
@ -533,18 +533,18 @@ if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
print $obj->num_payment.'</td>';
// Account
if (! empty($conf->banque->enabled))
if (!empty($conf->banque->enabled))
{
print '<td>';
if ($obj->fk_bank > 0)
{
//$accountstatic->fetch($obj->fk_bank);
$accountstatic->id=$obj->bid;
$accountstatic->ref=$obj->bref;
$accountstatic->number=$obj->bnumber;
$accountstatic->accountancy_number=$obj->account_number;
$accountstatic->accountancy_journal=$obj->accountancy_journal;
$accountstatic->label=$obj->blabel;
$accountstatic->id = $obj->bid;
$accountstatic->ref = $obj->bref;
$accountstatic->number = $obj->bnumber;
$accountstatic->accountancy_number = $obj->account_number;
$accountstatic->accountancy_journal = $obj->accountancy_journal;
$accountstatic->label = $obj->blabel;
print $accountstatic->getNomUrl(1);
}
else print '&nbsp;';

View File

@ -29,7 +29,7 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/trip.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
if (! empty($conf->projet->enabled))
if (!empty($conf->projet->enabled))
{
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
}
@ -40,7 +40,7 @@ $langs->load("trips");
// Security check
$id = GETPOST('id', 'int');
if ($user->socid) $socid=$user->socid;
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'deplacement', $id, '');
$action = GETPOST('action', 'alpha');
@ -49,16 +49,16 @@ $confirm = GETPOST('confirm', 'alpha');
$object = new Deplacement($db);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('tripsandexpensescard','globalcard'));
$hookmanager->initHooks(array('tripsandexpensescard', 'globalcard'));
$permissionnote=$user->rights->deplacement->creer; // Used by the include of actions_setnotes.inc.php
$permissionnote = $user->rights->deplacement->creer; // Used by the include of actions_setnotes.inc.php
/*
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
if ($action == 'validate' && $user->rights->deplacement->creer)
{
@ -68,7 +68,7 @@ if ($action == 'validate' && $user->rights->deplacement->creer)
$result = $object->setStatut(1);
if ($result > 0)
{
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
else
@ -86,7 +86,7 @@ elseif ($action == 'classifyrefunded' && $user->rights->deplacement->creer)
$result = $object->setStatut(2);
if ($result > 0)
{
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
else
@ -98,7 +98,7 @@ elseif ($action == 'classifyrefunded' && $user->rights->deplacement->creer)
elseif ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->deplacement->supprimer)
{
$result=$object->delete($id);
$result = $object->delete($id);
if ($result >= 0)
{
header("Location: index.php");
@ -112,20 +112,20 @@ elseif ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->depla
elseif ($action == 'add' && $user->rights->deplacement->creer)
{
if (! GETPOST('cancel', 'alpha'))
if (!GETPOST('cancel', 'alpha'))
{
$error=0;
$error = 0;
$object->date = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
$object->km = price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formated amount
$object->km = price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formated amount
$object->type = GETPOST('type', 'alpha');
$object->socid = GETPOST('socid', 'int');
$object->fk_user = GETPOST('fk_user', 'int');
$object->note_private = GETPOST('note_private', 'alpha');
$object->socid = GETPOST('socid', 'int');
$object->fk_user = GETPOST('fk_user', 'int');
$object->note_private = GETPOST('note_private', 'alpha');
$object->note_public = GETPOST('note_public', 'alpha');
$object->statut = 0;
if (! $object->date)
if (!$object->date)
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
$error++;
@ -135,30 +135,30 @@ elseif ($action == 'add' && $user->rights->deplacement->creer)
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
$error++;
}
if (! ($object->fk_user > 0))
if (!($object->fk_user > 0))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Person")), null, 'errors');
$error++;
}
if (! $error)
if (!$error)
{
$id = $object->create($user);
if ($id > 0)
{
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
else
{
setEventMessages($object->error, $object->errors, 'errors');
$action='create';
$action = 'create';
}
}
else
{
$action='create';
$action = 'create';
}
}
else
@ -171,23 +171,23 @@ elseif ($action == 'add' && $user->rights->deplacement->creer)
// Update record
elseif ($action == 'update' && $user->rights->deplacement->creer)
{
if (! GETPOST('cancel', 'alpha'))
if (!GETPOST('cancel', 'alpha'))
{
$result = $object->fetch($id);
$object->date = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
$object->km = price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formated amount
$object->km = price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formated amount
$object->type = GETPOST('type', 'alpha');
$object->socid = GETPOST('socid', 'int');
$object->fk_user = GETPOST('fk_user', 'int');
$object->note_private = GETPOST('note_private', 'alpha');
$object->note_public = GETPOST('note_public', 'alpha');
$object->socid = GETPOST('socid', 'int');
$object->fk_user = GETPOST('fk_user', 'int');
$object->note_private = GETPOST('note_private', 'alpha');
$object->note_public = GETPOST('note_public', 'alpha');
$result = $object->update($user);
if ($result > 0)
{
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
else
@ -197,7 +197,7 @@ elseif ($action == 'update' && $user->rights->deplacement->creer)
}
else
{
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
}
@ -206,22 +206,22 @@ elseif ($action == 'update' && $user->rights->deplacement->creer)
elseif ($action == 'classin' && $user->rights->deplacement->creer)
{
$object->fetch($id);
$result=$object->setProject(GETPOST('projectid', 'int'));
$result = $object->setProject(GETPOST('projectid', 'int'));
if ($result < 0) dol_print_error($db, $object->error);
}
// Set fields
elseif ($action == 'setdated' && $user->rights->deplacement->creer)
{
$dated=dol_mktime(GETPOST('datedhour', 'int'), GETPOST('datedmin', 'int'), GETPOST('datedsec', 'int'), GETPOST('datedmonth', 'int'), GETPOST('datedday', 'int'), GETPOST('datedyear', 'int'));
$dated = dol_mktime(GETPOST('datedhour', 'int'), GETPOST('datedmin', 'int'), GETPOST('datedsec', 'int'), GETPOST('datedmonth', 'int'), GETPOST('datedday', 'int'), GETPOST('datedyear', 'int'));
$object->fetch($id);
$result=$object->setValueFrom('dated', $dated, '', '', 'date', '', $user, 'DEPLACEMENT_MODIFY');
$result = $object->setValueFrom('dated', $dated, '', '', 'date', '', $user, 'DEPLACEMENT_MODIFY');
if ($result < 0) dol_print_error($db, $object->error);
}
elseif ($action == 'setkm' && $user->rights->deplacement->creer)
{
$object->fetch($id);
$result=$object->setValueFrom('km', GETPOST('km', 'int'), '', null, 'text', '', $user, 'DEPLACEMENT_MODIFY');
$result = $object->setValueFrom('km', GETPOST('km', 'int'), '', null, 'text', '', $user, 'DEPLACEMENT_MODIFY');
if ($result < 0) dol_print_error($db, $object->error);
}
@ -246,7 +246,7 @@ if ($action == 'create')
$datec = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
@ -264,11 +264,11 @@ if ($action == 'create')
print "<tr>";
print '<td class="fieldrequired">'.$langs->trans("Date").'</td><td>';
print $form->selectDate($datec?$datec:-1, '', '', '', '', 'add', 1, 1);
print $form->selectDate($datec ? $datec : -1, '', '', '', '', 'add', 1, 1);
print '</td></tr>';
// Km
print '<tr><td class="fieldrequired">'.$langs->trans("FeesKilometersOrAmout").'</td><td><input name="km" size="10" value="' . GETPOST("km") . '"></td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("FeesKilometersOrAmout").'</td><td><input name="km" size="10" value="'.GETPOST("km").'"></td></tr>';
// Company
print "<tr>";
@ -300,8 +300,8 @@ if ($action == 'create')
}
// Other attributes
$parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '</table>';
@ -334,7 +334,7 @@ elseif ($id)
$soc->fetch($object->socid);
}
print '<form name="update" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$id.'">';
@ -350,13 +350,13 @@ elseif ($id)
// Type
print "<tr>";
print '<td class="fieldrequired">'.$langs->trans("Type").'</td><td>';
$form->select_type_fees(GETPOST('type', 'int')?GETPOST('type', 'int'):$object->type, 'type', 0);
$form->select_type_fees(GETPOST('type', 'int') ?GETPOST('type', 'int') : $object->type, 'type', 0);
print '</td></tr>';
// Who
print "<tr>";
print '<td class="fieldrequired">'.$langs->trans("Person").'</td><td>';
print $form->select_dolusers(GETPOST('fk_user', 'int')?GETPOST('fk_user', 'int'):$object->fk_user, 'fk_user', 0, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
print $form->select_dolusers(GETPOST('fk_user', 'int') ?GETPOST('fk_user', 'int') : $object->fk_user, 'fk_user', 0, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
print '</td></tr>';
// Date
@ -397,8 +397,8 @@ elseif ($id)
}
// Other attributes
$parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '</table>';
@ -428,7 +428,7 @@ elseif ($id)
print '<table class="border centpercent">';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/deplacement/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/deplacement/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td>';
@ -446,7 +446,7 @@ elseif ($id)
// Who
print '<tr><td>'.$langs->trans("Person").'</td><td>';
$userfee=new User($db);
$userfee = new User($db);
$userfee->fetch($object->fk_user);
print $userfee->getNomUrl(1);
print '</td></tr>';
@ -472,7 +472,7 @@ elseif ($id)
print '</td></tr>';
// Project
if (! empty($conf->projet->enabled))
if (!empty($conf->projet->enabled))
{
$langs->load('projects');
print '<tr>';
@ -505,8 +505,8 @@ elseif ($id)
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
// Other attributes
$parameters=array('socid'=>$object->id);
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
$parameters = array('socid'=>$object->id);
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
print "</table><br>";

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -31,12 +31,12 @@ require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php';
// Load translation files required by the page
$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin"));
$langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin"));
$localTaxType=GETPOST('localTaxType', 'int');
$localTaxType = GETPOST('localTaxType', 'int');
// Date range
$year=GETPOST("year", "int");
$year = GETPOST("year", "int");
if (empty($year))
{
$year_current = strftime("%Y", dol_now());
@ -45,38 +45,38 @@ if (empty($year))
$year_current = $year;
$year_start = $year;
}
$date_start=dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"));
$date_end=dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"));
$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"));
$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"));
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
$q=GETPOST("q", "int");
$q = GETPOST("q", "int");
if (empty($q))
{
if (GETPOST("month", "int")) { $date_start=dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end=dol_get_last_day($year_start, GETPOST("month", "int"), false); }
if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); }
else
{
$date_start=dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START, false);
$date_end=dol_time_plus_duree($date_start, 1, 'y') - 1;
$date_start = dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START, false);
$date_end = dol_time_plus_duree($date_start, 1, 'y') - 1;
}
}
else
{
if ($q==1) { $date_start=dol_get_first_day($year_start, 1, false); $date_end=dol_get_last_day($year_start, 3, false); }
if ($q==2) { $date_start=dol_get_first_day($year_start, 4, false); $date_end=dol_get_last_day($year_start, 6, false); }
if ($q==3) { $date_start=dol_get_first_day($year_start, 7, false); $date_end=dol_get_last_day($year_start, 9, false); }
if ($q==4) { $date_start=dol_get_first_day($year_start, 10, false); $date_end=dol_get_last_day($year_start, 12, false); }
if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); }
if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); }
if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); }
if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); }
}
}
// Define modetax (0 or 1)
// 0=normal, 1=option vat for services is on debit, 2=option on payments for products
$modetax = $conf->global->TAX_MODE;
if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax", 'int');
if (empty($modetax)) $modetax=0;
if (GETPOSTISSET("modetax")) $modetax = GETPOST("modetax", 'int');
if (empty($modetax)) $modetax = 0;
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) $socid=$user->socid;
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'tax', '', '', 'charges');
@ -90,7 +90,7 @@ $result = restrictedArea($user, 'tax', '', '', 'charges');
*/
function pt($db, $sql, $date)
{
global $conf, $bc,$langs;
global $conf, $bc, $langs;
$result = $db->query($sql);
if ($result) {
@ -118,7 +118,7 @@ function pt($db, $sql, $date)
$mode = $obj->mode;
//print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode;
if ($obj->mode == 'claimed' && ! empty($previousmode))
if ($obj->mode == 'claimed' && !empty($previousmode))
{
print '<tr class="oddeven">';
print '<td class="nowrap">'.$previousmonth."</td>\n";
@ -162,7 +162,7 @@ function pt($db, $sql, $date)
$i++;
}
if ($mode == 'claimed' && ! empty($previousmode))
if ($mode == 'claimed' && !empty($previousmode))
{
print '<tr class="oddeven">';
print '<td class="nowrap">'.$previousmonth."</td>\n";
@ -206,30 +206,30 @@ if (empty($localTaxType))
* View
*/
$form=new Form($db);
$company_static=new Societe($db);
$form = new Form($db);
$company_static = new Societe($db);
$tva = new Tva($db);
if($localTaxType==1) {
$LT='LT1';
$LTSummary='LT1Summary';
$LTPaid='LT1Paid';
$LTCustomer='LT1Customer';
$LTSupplier='LT1Supplier';
$CalcLT= $conf->global->MAIN_INFO_LOCALTAX_CALC1;
if ($localTaxType == 1) {
$LT = 'LT1';
$LTSummary = 'LT1Summary';
$LTPaid = 'LT1Paid';
$LTCustomer = 'LT1Customer';
$LTSupplier = 'LT1Supplier';
$CalcLT = $conf->global->MAIN_INFO_LOCALTAX_CALC1;
} else {
$LT='LT2';
$LTSummary='LT2Summary';
$LTPaid='LT2Paid';
$LTCustomer='LT2Customer';
$LTSupplier='LT2Supplier';
$CalcLT= $conf->global->MAIN_INFO_LOCALTAX_CALC2;
$LT = 'LT2';
$LTSummary = 'LT2Summary';
$LTPaid = 'LT2Paid';
$LTCustomer = 'LT2Customer';
$LTSupplier = 'LT2Supplier';
$CalcLT = $conf->global->MAIN_INFO_LOCALTAX_CALC2;
}
$fsearch = '<!-- hidden fields for form -->';
$fsearch.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$fsearch.= '<input type="hidden" name="localTaxType" value="'.$localTaxType.'">';
$fsearch.= '<input type="hidden" name="modetax" value="'.$modetax.'">';
$fsearch .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$fsearch .= '<input type="hidden" name="localTaxType" value="'.$localTaxType.'">';
$fsearch .= '<input type="hidden" name="modetax" value="'.$modetax.'">';
$description = $fsearch;
@ -237,13 +237,13 @@ $description = $fsearch;
$name = $langs->trans("ReportByMonth");
$description .= $langs->trans($LT);
$calcmode = $langs->trans("LTReportBuildWithOptionDefinedInModule").' ';
$calcmode.= '('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')<br>';
$calcmode .= '('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')<br>';
//if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='<br>'.$langs->trans("ThisIsAnEstimatedValue");
$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$builddate=dol_now();
$builddate = dol_now();
llxHeader('', $name);
@ -265,29 +265,29 @@ print load_fiche_titre($langs->transcountry($LTSummary, $mysoc->country_code), '
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td width="30%">'.$langs->trans("Year")." ".$y."</td>";
if($CalcLT==0) {
if ($CalcLT == 0) {
print '<td class="right">'.$langs->transcountry($LTCustomer, $mysoc->country_code).'</td>';
print '<td class="right">'.$langs->transcountry($LTSupplier, $mysoc->country_code).'</td>';
}
if($CalcLT==1) {
if ($CalcLT == 1) {
print '<td class="right">'.$langs->transcountry($LTSupplier, $mysoc->country_code).'</td><td></td>';
}
if($CalcLT==2) {
if ($CalcLT == 2) {
print '<td class="right">'.$langs->transcountry($LTCustomer, $mysoc->country_code).'</td><td></td>';
}
print '<td class="right">'.$langs->trans("TotalToPay").'</td>';
print "<td>&nbsp;</td>\n";
print "</tr>\n";
$tmp=dol_getdate($date_start);
$tmp = dol_getdate($date_start);
$y = $tmp['year'];
$m = $tmp['mon'];
$tmp=dol_getdate($date_end);
$tmp = dol_getdate($date_end);
$yend = $tmp['year'];
$mend = $tmp['mon'];
$total=0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0;
$i=0; $mcursor=0;
$total = 0; $subtotalcoll = 0; $subtotalpaye = 0; $subtotal = 0;
$i = 0; $mcursor = 0;
while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mcursor is to avoid too large loop
{
//$m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12);
@ -296,15 +296,15 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc
$mcursor++;
// Get array with details of each line
$x_coll = tax_by_rate(($localTaxType==1?'localtax1':'localtax2'), $db, $y, 0, 0, 0, $modetax, 'sell', $m);
$x_paye = tax_by_rate(($localTaxType==1?'localtax1':'localtax2'), $db, $y, 0, 0, 0, $modetax, 'buy', $m);
$x_coll = tax_by_rate(($localTaxType == 1 ? 'localtax1' : 'localtax2'), $db, $y, 0, 0, 0, $modetax, 'sell', $m);
$x_paye = tax_by_rate(($localTaxType == 1 ? 'localtax1' : 'localtax2'), $db, $y, 0, 0, 0, $modetax, 'buy', $m);
$x_both = array();
//now, from these two arrays, get another array with one rate per line
foreach(array_keys($x_coll) as $my_coll_rate)
foreach (array_keys($x_coll) as $my_coll_rate)
{
$x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht'];
$x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat'];
$x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat'];
$x_both[$my_coll_rate]['coll']['localtax1'] = $x_coll[$my_coll_rate]['localtax1'];
$x_both[$my_coll_rate]['coll']['localtax2'] = $x_coll[$my_coll_rate]['localtax2'];
$x_both[$my_coll_rate]['paye']['totalht'] = 0;
@ -313,7 +313,7 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc
$x_both[$my_coll_rate]['paye']['localtax2'] = 0;
$x_both[$my_coll_rate]['coll']['links'] = '';
$x_both[$my_coll_rate]['coll']['detail'] = array();
foreach($x_coll[$my_coll_rate]['facid'] as $id=>$dummy) {
foreach ($x_coll[$my_coll_rate]['facid'] as $id=>$dummy) {
//$invoice_customer->id=$x_coll[$my_coll_rate]['facid'][$id];
//$invoice_customer->ref=$x_coll[$my_coll_rate]['facnum'][$id];
//$invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id];
@ -432,15 +432,15 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('externalbalance'));
$reshook=$hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if (! is_array($x_coll) && $coll_listbuy == -1)
if (!is_array($x_coll) && $coll_listbuy == -1)
{
$langs->load("errors");
print '<tr><td colspan="5">'.$langs->trans("ErrorNoAccountancyModuleLoaded").'</td></tr>';
break;
}
if (! is_array($x_paye) && $coll_listbuy == -2)
if (!is_array($x_paye) && $coll_listbuy == -2)
{
print '<tr><td colspan="5">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
break;
@ -459,19 +459,19 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc
foreach ($x_both[$rate]['coll']['detail'] as $index => $fields)
{
// Payment
$ratiopaymentinvoice=1;
$ratiopaymentinvoice = 1;
if ($modetax != 1)
{
// Define type
// We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
$type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']);
$type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']);
// Try to enhance type detection using date_start and date_end for free lines where type
// was not saved.
if (!empty($fields['ddate_start'])) {
$type=1;
$type = 1;
}
if (!empty($fields['ddate_end'])) {
$type=1;
$type = 1;
}
if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice')
@ -480,13 +480,13 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc
//print $langs->trans("NA");
} else {
if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) {
$ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
$ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']);
}
}
}
//var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice);
$temp_ht=$fields['totalht']*$ratiopaymentinvoice;
$temp_vat=$fields['localtax'.$localTaxType]*$ratiopaymentinvoice;
$temp_ht = $fields['totalht'] * $ratiopaymentinvoice;
$temp_vat = $fields['localtax'.$localTaxType] * $ratiopaymentinvoice;
$subtot_coll_total_ht += $temp_ht;
$subtot_coll_vat += $temp_vat;
$x_coll_sum += $temp_vat;
@ -503,19 +503,19 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc
foreach ($x_both[$rate]['paye']['detail'] as $index => $fields)
{
// Payment
$ratiopaymentinvoice=1;
$ratiopaymentinvoice = 1;
if ($modetax != 1)
{
// Define type
// We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
$type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']);
$type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']);
// Try to enhance type detection using date_start and date_end for free lines where type
// was not saved.
if (!empty($fields['ddate_start'])) {
$type=1;
$type = 1;
}
if (!empty($fields['ddate_end'])) {
$type=1;
$type = 1;
}
if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice')
@ -524,13 +524,13 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc
//print $langs->trans("NA");
} else {
if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) {
$ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
$ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']);
}
}
}
//var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice);
$temp_ht=$fields['totalht']*$ratiopaymentinvoice;
$temp_vat=$fields['localtax'.$localTaxType]*$ratiopaymentinvoice;
$temp_ht = $fields['totalht'] * $ratiopaymentinvoice;
$temp_vat = $fields['localtax'.$localTaxType] * $ratiopaymentinvoice;
$subtot_paye_total_ht += $temp_ht;
$subtot_paye_vat += $temp_vat;
$x_paye_sum += $temp_vat;
@ -553,13 +553,13 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc
if ($i > 2)
{
print '<tr class="liste_total">';
print '<td class="right"><a href="quadri_detail.php?leftmenu=tax_vat&q='.round($m/3).'&year='.$y.'">'.$langs->trans("SubTotal").'</a>:</td>';
print '<td class="right"><a href="quadri_detail.php?leftmenu=tax_vat&q='.round($m / 3).'&year='.$y.'">'.$langs->trans("SubTotal").'</a>:</td>';
print '<td class="nowrap right">'.price(price2num($subtotalcoll, 'MT')).'</td>';
print '<td class="nowrap right">'.price(price2num($subtotalpaye, 'MT')).'</td>';
print '<td class="nowrap right">'.price(price2num($subtotal, 'MT')).'</td>';
print '<td>&nbsp;</td></tr>';
$i = 0;
$subtotalcoll=0; $subtotalpaye=0; $subtotal=0;
$subtotalcoll = 0; $subtotalpaye = 0; $subtotal = 0;
}
}
print '<tr class="liste_total"><td class="right" colspan="3">'.$langs->trans("TotalToPay").':</td><td class="nowrap right">'.price(price2num($total, 'MT')).'</td>';
@ -579,25 +579,25 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
print load_fiche_titre($langs->transcountry($LTPaid, $mysoc->country_code), '', '');
$sql='';
$sql = '';
$sql.= "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm, 'claimed' as mode";
$sql.= " FROM ".MAIN_DB_PREFIX."localtax as f";
$sql.= " WHERE f.entity = ".$conf->entity;
$sql.= " AND (f.datev >= '".$db->idate($date_start)."' AND f.datev <= '".$db->idate($date_end)."')";
$sql.= " AND localtaxtype=".$localTaxType;
$sql.= " GROUP BY dm";
$sql .= "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm, 'claimed' as mode";
$sql .= " FROM ".MAIN_DB_PREFIX."localtax as f";
$sql .= " WHERE f.entity = ".$conf->entity;
$sql .= " AND (f.datev >= '".$db->idate($date_start)."' AND f.datev <= '".$db->idate($date_end)."')";
$sql .= " AND localtaxtype=".$localTaxType;
$sql .= " GROUP BY dm";
$sql.= " UNION ";
$sql .= " UNION ";
$sql.= "SELECT SUM(amount) as mm, date_format(f.datep,'%Y-%m') as dm, 'paid' as mode";
$sql.= " FROM ".MAIN_DB_PREFIX."localtax as f";
$sql.= " WHERE f.entity = ".$conf->entity;
$sql.= " AND (f.datep >= '".$db->idate($date_start)."' AND f.datep <= '".$db->idate($date_end)."')";
$sql.= " AND localtaxtype=".$localTaxType;
$sql.= " GROUP BY dm";
$sql .= "SELECT SUM(amount) as mm, date_format(f.datep,'%Y-%m') as dm, 'paid' as mode";
$sql .= " FROM ".MAIN_DB_PREFIX."localtax as f";
$sql .= " WHERE f.entity = ".$conf->entity;
$sql .= " AND (f.datep >= '".$db->idate($date_start)."' AND f.datep <= '".$db->idate($date_end)."')";
$sql .= " AND localtaxtype=".$localTaxType;
$sql .= " GROUP BY dm";
$sql.= " ORDER BY dm ASC, mode ASC";
$sql .= " ORDER BY dm ASC, mode ASC";
//print $sql;
pt($db, $sql, $langs->trans("Month"));

View File

@ -29,9 +29,9 @@ $langs->load("compta");
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) $socid=$user->socid;
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'tax', '', '', 'charges');
$ltt=GETPOST("localTaxType");
$ltt = GETPOST("localTaxType");
/*
@ -42,25 +42,25 @@ llxHeader();
$localtax_static = new Localtax($db);
$newcardbutton='';
$newcardbutton = '';
if ($user->rights->tax->charges->creer)
{
$newcardbutton.= dolGetButtonTitle($langs->trans('NewLocalTaxPayment', ($ltt+1)), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/localtax/card.php?action=create&localTaxType='.$ltt);
$newcardbutton .= dolGetButtonTitle($langs->trans('NewLocalTaxPayment', ($ltt + 1)), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/localtax/card.php?action=create&localTaxType='.$ltt);
}
print load_fiche_titre($langs->transcountry($ltt==2?"LT2Payments":"LT1Payments", $mysoc->country_code), $newcardbutton, 'invoicing');
print load_fiche_titre($langs->transcountry($ltt == 2 ? "LT2Payments" : "LT1Payments", $mysoc->country_code), $newcardbutton, 'invoicing');
$sql = "SELECT rowid, amount, label, f.datev, f.datep";
$sql.= " FROM ".MAIN_DB_PREFIX."localtax as f ";
$sql.= " WHERE f.entity = ".$conf->entity." AND localtaxtype=".$db->escape($ltt);
$sql.= " ORDER BY datev DESC";
$sql .= " FROM ".MAIN_DB_PREFIX."localtax as f ";
$sql .= " WHERE f.entity = ".$conf->entity." AND localtaxtype=".$db->escape($ltt);
$sql .= " ORDER BY datev DESC";
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
$total = 0 ;
$total = 0;
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
@ -70,15 +70,15 @@ if ($result)
print '<td class="nowrap" align="left">'.$langs->trans("DatePayment").'</td>';
print "<td align=\"right\">".$langs->trans("PayedByThisPayment")."</td>";
print "</tr>\n";
$var=1;
$var = 1;
while ($i < $num)
{
$obj = $db->fetch_object($result);
print '<tr class="oddeven">';
$localtax_static->id=$obj->rowid;
$localtax_static->ref=$obj->rowid;
$localtax_static->id = $obj->rowid;
$localtax_static->ref = $obj->rowid;
print "<td>".$localtax_static->getNomUrl(1)."</td>\n";
print "<td>".dol_trunc($obj->label, 40)."</td>\n";
print '<td class="left">'.dol_print_date($db->jdate($obj->datev), 'day')."</td>\n";

View File

@ -42,11 +42,11 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php';
// Load translation files required by the page
$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin"));
$langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin"));
$local=GETPOST('localTaxType', 'int');
$local = GETPOST('localTaxType', 'int');
// Date range
$year=GETPOST("year", "int");
$year = GETPOST("year", "int");
if (empty($year))
{
$year_current = strftime("%Y", dol_now());
@ -55,29 +55,29 @@ if (empty($year))
$year_current = $year;
$year_start = $year;
}
$date_start=dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"));
$date_end=dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"));
$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"));
$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"));
// Quarter
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
$q=GETPOST("q", "int");
$q = GETPOST("q", "int");
if (empty($q))
{
if (GETPOST("month", "int")) { $date_start=dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end=dol_get_last_day($year_start, GETPOST("month", "int"), false); }
if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); }
else
{
$date_start=dol_get_first_day($year_start, empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START, false);
if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end=dol_time_plus_duree($date_start, 3, 'm') - 1;
elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end=dol_time_plus_duree($date_start, 1, 'y') - 1;
elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end=dol_time_plus_duree($date_start, 1, 'm') - 1;
$date_start = dol_get_first_day($year_start, empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START, false);
if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1;
elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1;
elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1;
}
}
else
{
if ($q==1) { $date_start=dol_get_first_day($year_start, 1, false); $date_end=dol_get_last_day($year_start, 3, false); }
if ($q==2) { $date_start=dol_get_first_day($year_start, 4, false); $date_end=dol_get_last_day($year_start, 6, false); }
if ($q==3) { $date_start=dol_get_first_day($year_start, 7, false); $date_end=dol_get_last_day($year_start, 9, false); }
if ($q==4) { $date_start=dol_get_first_day($year_start, 10, false); $date_end=dol_get_last_day($year_start, 12, false); }
if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); }
if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); }
if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); }
if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); }
}
}
@ -87,14 +87,14 @@ if (empty($min)) $min = 0;
// Define modetax (0 or 1)
// 0=normal, 1=option vat for services is on debit, 2=option on payments for products
//$modetax = $conf->global->TAX_MODE;
$calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local;
$modetax=$conf->global->$calc;
if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax", 'int');
if (empty($modetax)) $modetax=0;
$calc = $conf->global->MAIN_INFO_LOCALTAX_CALC.$local;
$modetax = $conf->global->$calc;
if (GETPOSTISSET("modetax")) $modetax = GETPOST("modetax", 'int');
if (empty($modetax)) $modetax = 0;
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) $socid=$user->socid;
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'tax', '', '', 'charges');
if (empty($local))
@ -109,56 +109,56 @@ if (empty($local))
* View
*/
$form=new Form($db);
$company_static=new Societe($db);
$invoice_customer=new Facture($db);
$invoice_supplier=new FactureFournisseur($db);
$expensereport=new ExpenseReport($db);
$product_static=new Product($db);
$payment_static=new Paiement($db);
$paymentfourn_static=new PaiementFourn($db);
$paymentexpensereport_static=new PaymentExpenseReport($db);
$form = new Form($db);
$company_static = new Societe($db);
$invoice_customer = new Facture($db);
$invoice_supplier = new FactureFournisseur($db);
$expensereport = new ExpenseReport($db);
$product_static = new Product($db);
$payment_static = new Paiement($db);
$paymentfourn_static = new PaiementFourn($db);
$paymentexpensereport_static = new PaymentExpenseReport($db);
$morequerystring='';
$listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday');
$morequerystring = '';
$listofparams = array('date_startmonth', 'date_startyear', 'date_startday', 'date_endmonth', 'date_endyear', 'date_endday');
foreach ($listofparams as $param)
{
if (GETPOST($param)!='') $morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param);
if (GETPOST($param) != '') $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param);
}
llxHeader('', $langs->trans("LocalTaxReport"), '', '', 0, 0, '', '', $morequerystring);
$fsearch = '<!-- hidden fields for form -->';
$fsearch.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$fsearch.= '<input type="hidden" name="modetax" value="'.$modetax.'">';
$fsearch.= '<input type="hidden" name="localTaxType" value="'.$local.'">';
$fsearch .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$fsearch .= '<input type="hidden" name="modetax" value="'.$modetax.'">';
$fsearch .= '<input type="hidden" name="localTaxType" value="'.$local.'">';
$name=$langs->transcountry($local==1?"LT1ReportByQuarters":"LT2ReportByQuarters", $mysoc->country_code);
$calcmode='';
if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault');
if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption');
if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices');
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')';
$name = $langs->transcountry($local == 1 ? "LT1ReportByQuarters" : "LT2ReportByQuarters", $mysoc->country_code);
$calcmode = '';
if ($modetax == 0) $calcmode = $langs->trans('OptionVATDefault');
if ($modetax == 1) $calcmode = $langs->trans('OptionVATDebitOption');
if ($modetax == 2) $calcmode = $langs->trans('OptionPaymentForProductAndServices');
$calcmode .= '<br>('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')';
// Set period
$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$prevyear=$year_start;
$prevquarter=$q;
$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$prevyear = $year_start;
$prevquarter = $q;
if ($prevquarter > 1) {
$prevquarter--;
} else {
$prevquarter=4;
$prevquarter = 4;
$prevyear--;
}
$nextyear=$year_start;
$nextquarter=$q;
$nextyear = $year_start;
$nextquarter = $q;
if ($nextquarter < 4) {
$nextquarter++;
} else {
$nextquarter=1;
$nextquarter = 1;
$nextyear++;
}
$description.=$fsearch;
$builddate=dol_now();
$description .= $fsearch;
$builddate = dol_now();
/*if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description.=$langs->trans("RulesVATDueProducts");
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description.=$langs->trans("RulesVATInProducts");
@ -168,39 +168,39 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description.='<br>'.$langs->trans("DepositsAreNotIncluded");
}
*/
if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.=$langs->trans("ThisIsAnEstimatedValue");
if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description .= $langs->trans("ThisIsAnEstimatedValue");
// Customers invoices
$elementcust=$langs->trans("CustomersInvoices");
$productcust=$langs->trans("ProductOrService");
$amountcust=$langs->trans("AmountHT");
$vatcust=$langs->trans("VATReceived");
$namecust=$langs->trans("Name");
$elementcust = $langs->trans("CustomersInvoices");
$productcust = $langs->trans("ProductOrService");
$amountcust = $langs->trans("AmountHT");
$vatcust = $langs->trans("VATReceived");
$namecust = $langs->trans("Name");
if ($mysoc->tva_assuj) {
$vatcust.=' ('.$langs->trans("StatusToPay").')';
$vatcust .= ' ('.$langs->trans("StatusToPay").')';
}
// Suppliers invoices
$elementsup=$langs->trans("SuppliersInvoices");
$productsup=$productcust;
$amountsup=$amountcust;
$vatsup=$langs->trans("VATPaid");
$namesup=$namecust;
$elementsup = $langs->trans("SuppliersInvoices");
$productsup = $productcust;
$amountsup = $amountcust;
$vatsup = $langs->trans("VATPaid");
$namesup = $namecust;
if ($mysoc->tva_assuj) {
$vatsup.=' ('.$langs->trans("ToGetBack").')';
$vatsup .= ' ('.$langs->trans("ToGetBack").')';
}
report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
if($local==1){
$vatcust=$langs->transcountry("LT1", $mysoc->country_code);
$vatsup=$langs->transcountry("LT1", $mysoc->country_code);
$vatexpensereport=$langs->transcountry("LT1", $mysoc->country_code);
}else{
$vatcust=$langs->transcountry("LT2", $mysoc->country_code);
$vatsup=$langs->transcountry("LT2", $mysoc->country_code);
$vatexpensereport=$langs->transcountry("LT2", $mysoc->country_code);
if ($local == 1) {
$vatcust = $langs->transcountry("LT1", $mysoc->country_code);
$vatsup = $langs->transcountry("LT1", $mysoc->country_code);
$vatexpensereport = $langs->transcountry("LT1", $mysoc->country_code);
} else {
$vatcust = $langs->transcountry("LT2", $mysoc->country_code);
$vatsup = $langs->transcountry("LT2", $mysoc->country_code);
$vatexpensereport = $langs->transcountry("LT2", $mysoc->country_code);
}
// VAT Received and paid
@ -208,14 +208,14 @@ echo '<table class="noborder centpercent">';
$y = $year_current;
$total = 0;
$i=0;
$i = 0;
$columns = 5;
// Load arrays of datas
$x_coll = tax_by_rate('localtax' . $local, $db, 0, 0, $date_start, $date_end, $modetax, 'sell');
$x_paye = tax_by_rate('localtax' . $local, $db, 0, 0, $date_start, $date_end, $modetax, 'buy');
$x_coll = tax_by_rate('localtax'.$local, $db, 0, 0, $date_start, $date_end, $modetax, 'sell');
$x_paye = tax_by_rate('localtax'.$local, $db, 0, 0, $date_start, $date_end, $modetax, 'buy');
if (! is_array($x_coll) || ! is_array($x_paye))
if (!is_array($x_coll) || !is_array($x_paye))
{
$langs->load("errors");
if ($x_coll == -1)
@ -230,19 +230,19 @@ else
$x_both = array();
//now, from these two arrays, get another array with one rate per line
foreach(array_keys($x_coll) as $my_coll_rate)
foreach (array_keys($x_coll) as $my_coll_rate)
{
$x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht'];
$x_both[$my_coll_rate]['coll']['localtax'.$local] = $x_coll[$my_coll_rate]['localtax'.$local];
$x_both[$my_coll_rate]['coll']['localtax'.$local] = $x_coll[$my_coll_rate]['localtax'.$local];
$x_both[$my_coll_rate]['paye']['totalht'] = 0;
$x_both[$my_coll_rate]['paye']['localtax'.$local] = 0;
$x_both[$my_coll_rate]['coll']['links'] = '';
$x_both[$my_coll_rate]['coll']['detail'] = array();
foreach($x_coll[$my_coll_rate]['facid'] as $id=>$dummy)
foreach ($x_coll[$my_coll_rate]['facid'] as $id=>$dummy)
{
$invoice_customer->id=$x_coll[$my_coll_rate]['facid'][$id];
$invoice_customer->ref=$x_coll[$my_coll_rate]['facnum'][$id];
$invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id];
$invoice_customer->id = $x_coll[$my_coll_rate]['facid'][$id];
$invoice_customer->ref = $x_coll[$my_coll_rate]['facnum'][$id];
$invoice_customer->type = $x_coll[$my_coll_rate]['type'][$id];
$company_static->fetch($x_coll[$my_coll_rate]['company_id'][$id]);
$x_both[$my_coll_rate]['coll']['detail'][] = array(
'id' =>$x_coll[$my_coll_rate]['facid'][$id],
@ -269,21 +269,21 @@ else
}
}
// tva paid
foreach(array_keys($x_paye) as $my_paye_rate) {
foreach (array_keys($x_paye) as $my_paye_rate) {
$x_both[$my_paye_rate]['paye']['totalht'] = $x_paye[$my_paye_rate]['totalht'];
$x_both[$my_paye_rate]['paye']['vat'] = $x_paye[$my_paye_rate]['vat'];
if(!isset($x_both[$my_paye_rate]['coll']['totalht'])) {
if (!isset($x_both[$my_paye_rate]['coll']['totalht'])) {
$x_both[$my_paye_rate]['coll']['totalht'] = 0;
$x_both[$my_paye_rate]['coll']['vat'] = 0;
}
$x_both[$my_paye_rate]['paye']['links'] = '';
$x_both[$my_paye_rate]['paye']['detail'] = array();
foreach($x_paye[$my_paye_rate]['facid'] as $id=>$dummy)
foreach ($x_paye[$my_paye_rate]['facid'] as $id=>$dummy)
{
$invoice_supplier->id=$x_paye[$my_paye_rate]['facid'][$id];
$invoice_supplier->ref=$x_paye[$my_paye_rate]['facnum'][$id];
$invoice_supplier->type=$x_paye[$my_paye_rate]['type'][$id];
$invoice_supplier->id = $x_paye[$my_paye_rate]['facid'][$id];
$invoice_supplier->ref = $x_paye[$my_paye_rate]['facnum'][$id];
$invoice_supplier->type = $x_paye[$my_paye_rate]['type'][$id];
$x_both[$my_paye_rate]['paye']['detail'][] = array(
'id' =>$x_paye[$my_paye_rate]['facid'][$id],
'descr' =>$x_paye[$my_paye_rate]['descr'][$id],
@ -317,8 +317,8 @@ else
$x_paye_sum = 0;
$x_paye_ht = 0;
$span=$columns;
if ($modetax != 1) $span+=2;
$span = $columns;
if ($modetax != 1) $span += 2;
// Customers invoices
print '<tr class="liste_titre">';
@ -331,9 +331,9 @@ else
print '</tr>';
$LT=0;
$sameLT=false;
foreach(array_keys($x_coll) as $rate)
$LT = 0;
$sameLT = false;
foreach (array_keys($x_coll) as $rate)
{
$subtot_coll_total_ht = 0;
$subtot_coll_vat = 0;
@ -341,21 +341,21 @@ else
if (is_array($x_both[$rate]['coll']['detail']))
{
// VAT Rate
if($rate!=0){
if ($rate != 0) {
print "<tr>";
print '<td class="tax_rate">'.$langs->trans("Rate").': '.vatrate($rate).'%</td><td colspan="'.$span.'"></td>';
print '</tr>'."\n";
}
foreach($x_both[$rate]['coll']['detail'] as $index => $fields)
foreach ($x_both[$rate]['coll']['detail'] as $index => $fields)
{
if(($local==1 && $fields['localtax1']!=0) || ($local==2 && $fields['localtax2']!=0))
if (($local == 1 && $fields['localtax1'] != 0) || ($local == 2 && $fields['localtax2'] != 0))
{
// Define type
$type=($fields['dtype']?$fields['dtype']:$fields['ptype']);
$type = ($fields['dtype'] ? $fields['dtype'] : $fields['ptype']);
// Try to enhance type detection using date_start and date_end for free lines where type
// was not saved.
if (! empty($fields['ddate_start'])) $type=1;
if (! empty($fields['ddate_end'])) $type=1;
if (!empty($fields['ddate_start'])) $type = 1;
if (!empty($fields['ddate_end'])) $type = 1;
print '<tr class="oddeven">';
@ -367,9 +367,9 @@ else
print '<td class="left">';
if ($fields['pid'])
{
$product_static->id=$fields['pid'];
$product_static->ref=$fields['pref'];
$product_static->type=$fields['ptype'];
$product_static->id = $fields['pid'];
$product_static->ref = $fields['pref'];
$product_static->type = $fields['ptype'];
print $product_static->getNomUrl(1);
if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16);
}
@ -379,9 +379,9 @@ else
else $text = img_object($langs->trans('Product'), 'product');
if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg))
{
if ($reg[1]=='DEPOSIT') $fields['descr']=$langs->transnoentitiesnoconv('Deposit');
elseif ($reg[1]=='CREDIT_NOTE') $fields['descr']=$langs->transnoentitiesnoconv('CreditNote');
else $fields['descr']=$langs->transnoentitiesnoconv($reg[1]);
if ($reg[1] == 'DEPOSIT') $fields['descr'] = $langs->transnoentitiesnoconv('Deposit');
elseif ($reg[1] == 'CREDIT_NOTE') $fields['descr'] = $langs->transnoentitiesnoconv('CreditNote');
else $fields['descr'] = $langs->transnoentitiesnoconv($reg[1]);
}
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16);
@ -397,20 +397,20 @@ else
print price($fields['totalht']);
if (price2num($fields['ftotal_ttc']))
{
$ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']);
$ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']);
}
print '</td>';
}
// Payment
$ratiopaymentinvoice=1;
$ratiopaymentinvoice = 1;
if ($modetax != 1)
{
if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']);
print '<td class="nowrap right">';
if ($fields['payment_amount'] && $fields['ftotal_ttc'])
{
$payment_static->id=$fields['payment_id'];
$payment_static->id = $fields['payment_id'];
print $payment_static->getNomUrl(2);
}
if ($type == 0)
@ -419,21 +419,21 @@ else
}
else {
print price($fields['payment_amount']);
if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice*100, 2).'%)';
if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice * 100, 2).'%)';
}
print '</td>';
}
// Total collected
print '<td class="nowrap right">';
$temp_ht=$fields['totalht'];
if ($type == 1) $temp_ht=$fields['totalht']*$ratiopaymentinvoice;
$temp_ht = $fields['totalht'];
if ($type == 1) $temp_ht = $fields['totalht'] * $ratiopaymentinvoice;
print price(price2num($temp_ht, 'MT'));
print '</td>';
// Localtax
print '<td class="nowrap right">';
$temp_vat= $local==1?$fields['localtax1']:$fields['localtax2'];
$temp_vat = $local == 1 ? $fields['localtax1'] : $fields['localtax2'];
print price(price2num($temp_vat, 'MT'));
//print price($fields['vat']);
print '</td>';
@ -476,9 +476,9 @@ else
}
// Blank line
print '<tr><td colspan="'.($span+1).'">&nbsp;</td></tr>';
print '<tr><td colspan="'.($span + 1).'">&nbsp;</td></tr>';
print '</table>';
$diff=$x_coll_sum;
$diff = $x_coll_sum;
echo '<table class="noborder centpercent">';
//print table headers for this quadri - expenses now
@ -494,28 +494,28 @@ else
print '<td class="right">'.$vatsup.'</td>';
print '</tr>'."\n";
foreach(array_keys($x_paye) as $rate)
foreach (array_keys($x_paye) as $rate)
{
$subtot_paye_total_ht = 0;
$subtot_paye_vat = 0;
if (is_array($x_both[$rate]['paye']['detail']))
{
if($rate!=0){
if ($rate != 0) {
print "<tr>";
print '<td class="tax_rate">'.$langs->trans("Rate").': '.vatrate($rate).'%</td><td colspan="'.$span.'"></td>';
print '</tr>'."\n";
}
foreach($x_both[$rate]['paye']['detail'] as $index=>$fields)
foreach ($x_both[$rate]['paye']['detail'] as $index=>$fields)
{
if(($local==1 && $fields['localtax1']!=0) || ($local==2 && $fields['localtax2']!=0))
if (($local == 1 && $fields['localtax1'] != 0) || ($local == 2 && $fields['localtax2'] != 0))
{
// Define type
$type=($fields['dtype']?$fields['dtype']:$fields['ptype']);
$type = ($fields['dtype'] ? $fields['dtype'] : $fields['ptype']);
// Try to enhance type detection using date_start and date_end for free lines where type
// was not saved.
if (! empty($fields['ddate_start'])) $type=1;
if (! empty($fields['ddate_end'])) $type=1;
if (!empty($fields['ddate_start'])) $type = 1;
if (!empty($fields['ddate_end'])) $type = 1;
print '<tr class="oddeven">';
@ -527,9 +527,9 @@ else
print '<td class="left">';
if ($fields['pid'])
{
$product_static->id=$fields['pid'];
$product_static->ref=$fields['pref'];
$product_static->type=$fields['ptype'];
$product_static->id = $fields['pid'];
$product_static->ref = $fields['pref'];
$product_static->type = $fields['ptype'];
print $product_static->getNomUrl(1);
if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16);
}
@ -552,21 +552,21 @@ else
if (price2num($fields['ftotal_ttc']))
{
//print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
$ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']);
$ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']);
//print ' ('.round($ratiolineinvoice*100,2).'%)';
}
print '</td>';
}
// Payment
$ratiopaymentinvoice=1;
$ratiopaymentinvoice = 1;
if ($modetax != 1)
{
print '<td class="nowrap right">';
if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']);
if ($fields['payment_amount'] && $fields['ftotal_ttc'])
{
$paymentfourn_static->id=$fields['payment_id'];
$paymentfourn_static->id = $fields['payment_id'];
print $paymentfourn_static->getNomUrl(2);
}
if ($type == 0)
@ -577,7 +577,7 @@ else
{
print price(price2num($fields['payment_amount'], 'MT'));
if (isset($fields['payment_amount'])) {
print ' ('.round($ratiopaymentinvoice*100, 2).'%)';
print ' ('.round($ratiopaymentinvoice * 100, 2).'%)';
}
}
print '</td>';
@ -585,13 +585,13 @@ else
// VAT paid
print '<td class="nowrap right">';
$temp_ht=$fields['totalht']*$ratiopaymentinvoice;
$temp_ht = $fields['totalht'] * $ratiopaymentinvoice;
print price(price2num($temp_ht, 'MT'), 1);
print '</td>';
// Localtax
print '<td class="nowrap right">';
$temp_vat=($local==1?$fields['localtax1']:$fields['localtax2'])*$ratiopaymentinvoice;
$temp_vat = ($local == 1 ? $fields['localtax1'] : $fields['localtax2']) * $ratiopaymentinvoice;
print price(price2num($temp_vat, 'MT'), 1);
//print price($fields['vat']);
print '</td>';
@ -638,7 +638,7 @@ else
print '<table class="noborder centpercent">';
$diff = $x_coll_sum - $x_paye_sum;
print '<tr class="liste_total">';
print '<td class="liste_total" colspan="'.$span.'">'.$langs->trans("TotalToPay").($q?', '.$langs->trans("Quadri").' '.$q:'').'</td>';
print '<td class="liste_total" colspan="'.$span.'">'.$langs->trans("TotalToPay").($q ? ', '.$langs->trans("Quadri").' '.$q : '').'</td>';
print '<td class="liste_total nowrap right"><b>'.price(price2num($diff, 'MT'))."</b></td>\n";
print "</tr>\n";

View File

@ -36,28 +36,28 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
$langs->loadLangs(array('banks', 'categories', 'bills', 'companies', 'compta'));
$id =GETPOST('id', 'int');
$ref=GETPOST('ref', 'alpha');
$action=GETPOST('action', 'alpha');
$confirm=GETPOST('confirm', 'alpha');
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
// Security check
$fieldname = (! empty($ref)?'ref':'rowid');
if ($user->socid) $socid=$user->socid;
$fieldname = (!empty($ref) ? 'ref' : 'rowid');
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'cheque', $id, 'bordereau_cheque', '', 'fk_user_author', $fieldname);
$sortfield=GETPOST('sortfield', 'alpha');
$sortorder=GETPOST('sortorder', 'alpha');
$page=GETPOST('page', 'int');
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="b.dateo,b.rowid";
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "b.dateo,b.rowid";
if (empty($page) || $page == -1) { $page = 0; }
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$offset = $limit * $page ;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$offset = $limit * $page;
$dir=$conf->bank->dir_output.'/checkdeposits/';
$filterdate=dol_mktime(0, 0, 0, GETPOST('fdmonth'), GETPOST('fdday'), GETPOST('fdyear'));
$filteraccountid=GETPOST('accountid');
$dir = $conf->bank->dir_output.'/checkdeposits/';
$filterdate = dol_mktime(0, 0, 0, GETPOST('fdmonth'), GETPOST('fdday'), GETPOST('fdyear'));
$filteraccountid = GETPOST('accountid');
$object = new RemiseCheque($db);
@ -72,9 +72,9 @@ if ($action == 'setdate' && $user->rights->banque->cheque)
if ($result > 0)
{
//print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year'];
$date=dol_mktime(0, 0, 0, $_POST['datecreate_month'], $_POST['datecreate_day'], $_POST['datecreate_year']);
$date = dol_mktime(0, 0, 0, $_POST['datecreate_month'], $_POST['datecreate_day'], $_POST['datecreate_year']);
$result=$object->set_date($user, $date);
$result = $object->set_date($user, $date);
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
@ -93,7 +93,7 @@ if ($action == 'setrefext' && $user->rights->banque->cheque)
{
$ref_ext = GETPOST('ref_ext');
$result=$object->setValueFrom('ref_ext', $ref_ext, '', null, 'text', '', $user, 'CHECKDEPOSIT_MODIFY');
$result = $object->setValueFrom('ref_ext', $ref_ext, '', null, 'text', '', $user, 'CHECKDEPOSIT_MODIFY');
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
@ -110,9 +110,9 @@ if ($action == 'setref' && $user->rights->banque->cheque)
$result = $object->fetch(GETPOST('id', 'int'));
if ($result > 0)
{
$ref=GETPOST('ref');
$ref = GETPOST('ref');
$result=$object->set_number($user, $ref);
$result = $object->set_number($user, $ref);
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
@ -133,13 +133,13 @@ if ($action == 'create' && $_POST["accountid"] > 0 && $user->rights->banque->che
{
if ($object->statut == 1) // If statut is validated, we build doc
{
$object->fetch($object->id); // To force to reload all properties in correct property name
$object->fetch($object->id); // To force to reload all properties in correct property name
// Define output language
$outputlangs = $langs;
$newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id'];
//if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang))
if (!empty($newlang))
{
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
@ -158,7 +158,7 @@ if ($action == 'create' && $_POST["accountid"] > 0 && $user->rights->banque->che
else
{
setEventMessages($langs->trans("ErrorSelectAtLeastOne"), null, 'mesgs');
$action='new';
$action = 'new';
}
}
@ -200,10 +200,10 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->banque->c
{
// Define output language
$outputlangs = $langs;
$newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id'];
//if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang))
if (!empty($newlang))
{
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
@ -231,12 +231,12 @@ if ($action == 'confirm_reject_check' && $confirm == 'yes' && $user->rights->ban
setEventMessages($langs->trans("CheckRejectedAndInvoicesReopened"), null, 'mesgs');
//header("Location: ".DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id);
//exit;
$action='';
$action = '';
}
else
{
setEventMessages($object->error, $object->errors, 'errors');
$action='';
$action = '';
}
}
@ -248,10 +248,10 @@ if ($action == 'builddoc' && $user->rights->banque->cheque)
//if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
$outputlangs = $langs;
$newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id'];
//if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang))
if (!empty($newlang))
{
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
@ -264,7 +264,7 @@ if ($action == 'builddoc' && $user->rights->banque->cheque)
}
else
{
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc'));
exit;
}
}
@ -278,8 +278,8 @@ elseif ($action == 'remove_file' && $user->rights->banque->cheque)
$langs->load("other");
$file=$dir.get_exdir($object->ref, 0, 1, 0, $object, 'cheque') . GETPOST('file');
$ret=dol_delete_file($file, 0, 0, 0, $object);
$file = $dir.get_exdir($object->ref, 0, 1, 0, $object, 'cheque').GETPOST('file');
$ret = dol_delete_file($file, 0, 0, 0, $object);
if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
}
@ -292,12 +292,12 @@ elseif ($action == 'remove_file' && $user->rights->banque->cheque)
if (GETPOST('removefilter'))
{
$filterdate='';
$filteraccountid=0;
$filterdate = '';
$filteraccountid = 0;
}
$title=$langs->trans("Cheques") . " - " . $langs->trans("Card");
$helpurl="";
$title = $langs->trans("Cheques")." - ".$langs->trans("Card");
$helpurl = "";
llxHeader("", $title, $helpurl);
$form = new Form($db);
@ -306,7 +306,7 @@ $formfile = new FormFile($db);
if ($action == 'new')
{
$h=0;
$h = 0;
$head[$h][0] = $_SERVER["PHP_SELF"].'?action=new';
$head[$h][1] = $langs->trans("MenuChequeDeposits");
$hselected = $h;
@ -323,7 +323,7 @@ else
exit;
}
$h=0;
$h = 0;
$head[$h][0] = $_SERVER["PHP_SELF"].'?id='.$object->id;
$head[$h][1] = $langs->trans("CheckReceipt");
$hselected = $h;
@ -356,8 +356,8 @@ else
if ($action == 'reject_check')
{
$formquestion = array(
array('type' => 'hidden','name' => 'bankid','value' => GETPOST('lineid')),
array('type' => 'date','name' => 'rejectdate_','label' => $langs->trans("RejectCheckDate"),'value' => dol_now())
array('type' => 'hidden', 'name' => 'bankid', 'value' => GETPOST('lineid')),
array('type' => 'date', 'name' => 'rejectdate_', 'label' => $langs->trans("RejectCheckDate"), 'value' => dol_now())
);
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("RejectCheck"), $langs->trans("ConfirmRejectCheck"), 'confirm_reject_check', $formquestion, '', 1);
}
@ -367,12 +367,12 @@ $accounts = array();
if ($action == 'new')
{
$paymentstatic=new Paiement($db);
$accountlinestatic=new AccountLine($db);
$paymentstatic = new Paiement($db);
$accountlinestatic = new AccountLine($db);
$lines = array();
$now=dol_now();
$now = dol_now();
print $langs->trans("SelectChequeTransactionAndGenerate").'<br><br>'."\n";
@ -406,24 +406,24 @@ if ($action == 'new')
print '<br>';
$sql = "SELECT ba.rowid as bid, b.datec as datec, b.dateo as date, b.rowid as transactionid, ";
$sql.= " b.amount, ba.label, b.emetteur, b.num_chq, b.banque,";
$sql.= " p.rowid as paymentid";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (b.fk_account = ba.rowid)";
$sql.= " WHERE b.fk_type = 'CHQ'";
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
$sql.= " AND b.fk_bordereau = 0";
$sql.= " AND b.amount > 0";
if ($filterdate) $sql.=" AND b.dateo = '".$db->idate($filterdate)."'";
if ($filteraccountid > 0) $sql.=" AND ba.rowid= '".$filteraccountid."'";
$sql.= $db->order("b.dateo,b.rowid", "ASC");
$sql .= " b.amount, ba.label, b.emetteur, b.num_chq, b.banque,";
$sql .= " p.rowid as paymentid";
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (b.fk_account = ba.rowid)";
$sql .= " WHERE b.fk_type = 'CHQ'";
$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
$sql .= " AND b.fk_bordereau = 0";
$sql .= " AND b.amount > 0";
if ($filterdate) $sql .= " AND b.dateo = '".$db->idate($filterdate)."'";
if ($filteraccountid > 0) $sql .= " AND ba.rowid= '".$filteraccountid."'";
$sql .= $db->order("b.dateo,b.rowid", "ASC");
$resql = $db->query($sql);
if ($resql)
{
$i = 0;
while ( $obj = $db->fetch_object($resql) )
while ($obj = $db->fetch_object($resql))
{
$accounts[$obj->bid] = $obj->label;
$lines[$obj->bid][$i]["date"] = $db->jdate($obj->date);
@ -466,9 +466,9 @@ if ($action == 'new')
print '<input type="hidden" name="action" value="create">';
print '<input type="hidden" name="accountid" value="'.$bid.'">';
$moreforfilter='';
$moreforfilter = '';
print '<div class="div-table-responsive-no-min">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("DateChequeReceived").'</td>'."\n";
@ -503,8 +503,8 @@ if ($action == 'new')
// Link to payment
print '<td align="center">';
$paymentstatic->id=$value["paymentid"];
$paymentstatic->ref=$value["paymentid"];
$paymentstatic->id = $value["paymentid"];
$paymentstatic->ref = $value["paymentid"];
if ($paymentstatic->id)
{
print $paymentstatic->getNomUrl(1);
@ -516,7 +516,7 @@ if ($action == 'new')
print '</td>';
// Link to bank transaction
print '<td align="center">';
$accountlinestatic->rowid=$value["id"];
$accountlinestatic->rowid = $value["id"];
if ($accountlinestatic->rowid)
{
print $accountlinestatic->getNomUrl(1);
@ -529,7 +529,7 @@ if ($action == 'new')
print '<td align="center">';
print '<input id="'.$value["id"].'" class="flat checkforremise_'.$bid.'" checked type="checkbox" name="toRemise[]" value="'.$value["id"].'">';
print '</td>' ;
print '</td>';
print '</tr>';
$i++;
@ -553,14 +553,14 @@ if ($action == 'new')
}
else
{
$paymentstatic=new Paiement($db);
$accountlinestatic=new AccountLine($db);
$accountstatic=new Account($db);
$paymentstatic = new Paiement($db);
$accountlinestatic = new AccountLine($db);
$accountstatic = new Account($db);
$accountstatic->fetch($object->account_id);
$linkback='<a href="'.DOL_URL_ROOT.'/compta/paiement/cheque/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/paiement/cheque/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref='';
$morehtmlref = '';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
@ -647,15 +647,15 @@ else
// List of cheques
$sql = "SELECT b.rowid, b.amount, b.num_chq, b.emetteur,";
$sql.= " b.dateo as date, b.datec as datec, b.banque,";
$sql.= " p.rowid as pid, ba.rowid as bid, p.statut";
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON (b.fk_account = ba.rowid)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid";
$sql.= " WHERE ba.entity IN (".getEntity('bank_account').")";
$sql.= " AND b.fk_type= 'CHQ'";
$sql.= " AND b.fk_bordereau = ".$object->id;
$sql.= $db->order($sortfield, $sortorder);
$sql .= " b.dateo as date, b.datec as datec, b.banque,";
$sql .= " p.rowid as pid, ba.rowid as bid, p.statut";
$sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON (b.fk_account = ba.rowid)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid";
$sql .= " WHERE ba.entity IN (".getEntity('bank_account').")";
$sql .= " AND b.fk_type= 'CHQ'";
$sql .= " AND b.fk_bordereau = ".$object->id;
$sql .= $db->order($sortfield, $sortorder);
$resql = $db->query($sql);
if ($resql)
@ -665,7 +665,7 @@ else
print '<div class="div-table-responsive">';
print '<table class="noborder centpercent">';
$param="&amp;id=".$object->id;
$param = "&amp;id=".$object->id;
print '<tr class="liste_titre">';
print_liste_field_titre("Cheques", '', '', '', '', 'width="30"');
@ -678,7 +678,7 @@ else
print_liste_field_titre("LineRecord", $_SERVER["PHP_SELF"], "b.rowid", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre('');
print "</tr>\n";
$i=1;
$i = 1;
if ($num > 0)
{
@ -693,15 +693,15 @@ else
print '<tr class="oddeven">';
print '<td align="center">'.$i.'</td>';
print '<td align="center">'.dol_print_date($db->jdate($objp->date), 'day').'</td>'; // Date operation
print '<td align="center">'.($objp->num_chq?$objp->num_chq:'&nbsp;').'</td>';
print '<td align="center">'.dol_print_date($db->jdate($objp->date), 'day').'</td>'; // Date operation
print '<td align="center">'.($objp->num_chq ? $objp->num_chq : '&nbsp;').'</td>';
print '<td>'.dol_trunc($objp->emetteur, 24).'</td>';
print '<td>'.dol_trunc($objp->banque, 24).'</td>';
print '<td class="right">'.price($objp->amount).'</td>';
// Link to payment
print '<td align="center">';
$paymentstatic->id=$objp->pid;
$paymentstatic->ref=$objp->pid;
$paymentstatic->id = $objp->pid;
$paymentstatic->ref = $objp->pid;
if ($paymentstatic->id)
{
print $paymentstatic->getNomUrl(1);
@ -713,7 +713,7 @@ else
print '</td>';
// Link to bank transaction
print '<td align="center">';
$accountlinestatic->rowid=$objp->rowid;
$accountlinestatic->rowid = $objp->rowid;
if ($accountlinestatic->rowid)
{
print $accountlinestatic->getNomUrl(1);
@ -770,12 +770,12 @@ else
print '<div class="tabsAction">';
if ($user->socid == 0 && ! empty($object->id) && $object->statut == 0 && $user->rights->banque->cheque)
if ($user->socid == 0 && !empty($object->id) && $object->statut == 0 && $user->rights->banque->cheque)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=valide&amp;sortfield='.$sortfield.'&amp;sortorder='.$sortorder.'">'.$langs->trans('Validate').'</a>';
}
if ($user->socid == 0 && ! empty($object->id) && $user->rights->banque->cheque)
if ($user->socid == 0 && !empty($object->id) && $user->rights->banque->cheque)
{
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete&amp;sortfield='.$sortfield.'&amp;sortorder='.$sortorder.'">'.$langs->trans('Delete').'</a>';
}
@ -787,9 +787,9 @@ if ($action != 'new')
{
if ($object->statut == 1)
{
$filename=dol_sanitizeFileName($object->ref);
$filedir=$dir.get_exdir($object->ref, 0, 1, 0, $object, 'cheque') . dol_sanitizeFileName($object->ref);
$urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id;
$filename = dol_sanitizeFileName($object->ref);
$filedir = $dir.get_exdir($object->ref, 0, 1, 0, $object, 'cheque').dol_sanitizeFileName($object->ref);
$urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
print $formfile->showdocuments('remisecheque', $filename, $filedir, $urlsource, 1, 1);

View File

@ -42,7 +42,7 @@ $prev_id = GETPOST('id', 'int');
$socid = GETPOST('socid', 'int');
$ref = GETPOST('ref', 'alpha');
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int');
@ -50,8 +50,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) $sortfield='p.ref';
if (! $sortorder) $sortorder='DESC';
if (!$sortfield) $sortfield = 'p.ref';
if (!$sortorder) $sortorder = 'DESC';
$object = new BonPrelevement($db, "");
@ -87,7 +87,7 @@ if ($prev_id > 0 || $ref)
// Status
//print '<tr><td>'.$langs->trans('Status').'</td><td>'.$object->getLibStatut(1).'</td></tr>';
if($object->date_trans <> 0)
if ($object->date_trans <> 0)
{
$muser = new User($db);
$muser->fetch($object->user_trans);
@ -99,7 +99,7 @@ if ($prev_id > 0 || $ref)
print $object->methodes_trans[$object->method_trans];
print '</td></tr>';
}
if($object->date_credit <> 0)
if ($object->date_credit <> 0)
{
print '<tr><td>'.$langs->trans('CreditDate').'</td><td>';
print dol_print_date($object->date_credit, 'day');
@ -114,7 +114,7 @@ if ($prev_id > 0 || $ref)
print '<table class="border centpercent">';
$acc = new Account($db);
$result=$acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT);
$result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT);
print '<tr><td class="titlefield">';
print $langs->trans("BankToReceiveWithdraw");
@ -144,21 +144,21 @@ if ($prev_id > 0 || $ref)
// List of invoices
$sql = "SELECT pf.rowid,";
$sql.= " f.rowid as facid, f.ref as ref, f.total_ttc,";
$sql.= " s.rowid as socid, s.nom as name, pl.statut, pl.amount as amount_requested";
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql.= ", ".MAIN_DB_PREFIX."prelevement_lignes as pl";
$sql.= ", ".MAIN_DB_PREFIX."prelevement_facture as pf";
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE pf.fk_prelevement_lignes = pl.rowid";
$sql.= " AND pl.fk_prelevement_bons = p.rowid";
$sql.= " AND f.fk_soc = s.rowid";
$sql.= " AND pf.fk_facture = f.rowid";
$sql.= " AND f.entity IN (".getEntity('invoice').")";
if ($object->id > 0) $sql.= " AND p.rowid=".$object->id;
if ($socid) $sql.= " AND s.rowid = ".$socid;
$sql.= $db->order($sortfield, $sortorder);
$sql .= " f.rowid as facid, f.ref as ref, f.total_ttc,";
$sql .= " s.rowid as socid, s.nom as name, pl.statut, pl.amount as amount_requested";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= ", ".MAIN_DB_PREFIX."prelevement_lignes as pl";
$sql .= ", ".MAIN_DB_PREFIX."prelevement_facture as pf";
$sql .= ", ".MAIN_DB_PREFIX."facture as f";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE pf.fk_prelevement_lignes = pl.rowid";
$sql .= " AND pl.fk_prelevement_bons = p.rowid";
$sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND pf.fk_facture = f.rowid";
$sql .= " AND f.entity IN (".getEntity('invoice').")";
if ($object->id > 0) $sql .= " AND p.rowid=".$object->id;
if ($socid) $sql .= " AND s.rowid = ".$socid;
$sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
@ -173,7 +173,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
}
}
$sql.= $db->plimit($limit + 1, $offset);
$sql .= $db->plimit($limit + 1, $offset);
$result = $db->query($sql);
if ($result)
@ -195,12 +195,12 @@ if ($result)
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">';
$massactionbutton='';
$massactionbutton = '';
print_barre_liste($langs->trans("Invoices"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit);
print"\n<!-- debut table -->\n";
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="liste centpercent">';
print '<tr class="liste_titre">';
print_liste_field_titre("Bill", $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder);

View File

@ -30,22 +30,22 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
// Load translation files required by the page
$langs->load("companies");
if (! empty($conf->facture->enabled)) $langs->load("bills");
if (!empty($conf->facture->enabled)) $langs->load("bills");
$id = GETPOST('id')?GETPOST('id', 'int'):GETPOST('socid', 'int');
$id = GETPOST('id') ?GETPOST('id', 'int') : GETPOST('socid', 'int');
// Security check
if ($user->socid) $id=$user->socid;
if ($user->socid) $id = $user->socid;
$result = restrictedArea($user, 'societe', $id, '&societe');
$object = new Societe($db);
if ($id > 0) $object->fetch($id);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('recapcomptacard','globalcard'));
$hookmanager->initHooks(array('recapcomptacard', 'globalcard'));
// Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -53,17 +53,17 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) $sortfield="f.datef,f.rowid"; // Set here default search field
if (! $sortorder) $sortorder="DESC";
if (!$sortfield) $sortfield = "f.datef,f.rowid"; // Set here default search field
if (!$sortorder) $sortorder = "DESC";
$arrayfields=array(
$arrayfields = array(
'f.datef'=>array('label'=>"Date", 'checked'=>1),
//...
);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('supplierbalencelist','globalcard'));
$hookmanager->initHooks(array('supplierbalencelist', 'globalcard'));
/*
* Actions
@ -80,33 +80,33 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
*/
$form = new Form($db);
$userstatic=new User($db);
$userstatic = new User($db);
$title=$langs->trans("ThirdParty").' - '.$langs->trans("Summary");
if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name.' - '.$langs->trans("Symmary");
$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
$title = $langs->trans("ThirdParty").' - '.$langs->trans("Summary");
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Symmary");
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url);
if ($id > 0)
{
$param='';
if ($id > 0) $param.='&socid='.$id;
$param = '';
if ($id > 0) $param .= '&socid='.$id;
$head = societe_prepare_head($object);
dol_fiche_head($head, 'customer', $langs->trans("ThirdParty"), 0, 'company');
dol_banner_tab($object, 'socid', '', ($user->socid?0:1), 'rowid', 'nom', '', '', 0, '', '', 1);
dol_banner_tab($object, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 1);
dol_fiche_end();
if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
{
// Invoice list
print load_fiche_titre($langs->trans("CustomerPreview"));
print '<table class="noborder tagtable liste centpercent">';
print '<tr class="liste_titre">';
if (! empty($arrayfields['f.datef']['checked'])) print_liste_field_titre($arrayfields['f.datef']['label'], $_SERVER["PHP_SELF"], "f.datef", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
if (!empty($arrayfields['f.datef']['checked'])) print_liste_field_titre($arrayfields['f.datef']['label'], $_SERVER["PHP_SELF"], "f.datef", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
print '<td>'.$langs->trans("Element").'</td>';
print '<td>'.$langs->trans("Status").'</td>';
print '<td class="right">'.$langs->trans("Debit").'</td>';
@ -118,26 +118,26 @@ if ($id > 0)
$TData = array();
$sql = "SELECT s.nom, s.rowid as socid, f.ref, f.amount, f.datef as df,";
$sql.= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,";
$sql.= " u.login, u.rowid as userid";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id;
$sql.= " AND f.entity IN (".getEntity('invoice').")";
$sql.= " AND f.fk_user_valid = u.rowid";
$sql.= $db->order($sortfield, $sortorder);
$sql .= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,";
$sql .= " u.login, u.rowid as userid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id;
$sql .= " AND f.entity IN (".getEntity('invoice').")";
$sql .= " AND f.fk_user_valid = u.rowid";
$sql .= $db->order($sortfield, $sortorder);
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
// Boucle sur chaque facture
for ($i = 0 ; $i < $num ; $i++)
for ($i = 0; $i < $num; $i++)
{
$objf = $db->fetch_object($resql);
$fac = new Facture($db);
$ret=$fac->fetch($objf->facid);
$ret = $fac->fetch($objf->facid);
if ($ret < 0)
{
print $fac->error."<br>";
@ -145,8 +145,8 @@ if ($id > 0)
}
$totalpaye = $fac->getSommePaiement();
$userstatic->id=$objf->userid;
$userstatic->login=$objf->login;
$userstatic->id = $objf->userid;
$userstatic->login = $objf->login;
$values = array(
'fk_facture' => $objf->facid,
@ -166,14 +166,14 @@ if ($id > 0)
// Paiements
$sql = "SELECT p.rowid, p.datep as dp, pf.amount, p.statut,";
$sql.= " p.fk_user_creat, u.login, u.rowid as userid";
$sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf,";
$sql.= " ".MAIN_DB_PREFIX."paiement as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON p.fk_user_creat = u.rowid";
$sql.= " WHERE pf.fk_paiement = p.rowid";
$sql.= " AND p.entity = ".$conf->entity;
$sql.= " AND pf.fk_facture = ".$fac->id;
$sql.= " ORDER BY p.datep ASC, p.rowid ASC";
$sql .= " p.fk_user_creat, u.login, u.rowid as userid";
$sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf,";
$sql .= " ".MAIN_DB_PREFIX."paiement as p";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON p.fk_user_creat = u.rowid";
$sql .= " WHERE pf.fk_paiement = p.rowid";
$sql .= " AND p.entity = ".$conf->entity;
$sql .= " AND pf.fk_facture = ".$fac->id;
$sql .= " ORDER BY p.datep ASC, p.rowid ASC";
$resqlp = $db->query($sql);
if ($resqlp)
@ -188,14 +188,14 @@ if ($id > 0)
$paymentstatic = new Paiement($db);
$paymentstatic->id = $objp->rowid;
$userstatic->id=$objp->userid;
$userstatic->login=$objp->login;
$userstatic->id = $objp->userid;
$userstatic->login = $objp->login;
$values = array(
'fk_paiement' => $objp->rowid,
'date' => $db->jdate($objp->dp),
'datefieldforsort' => $db->jdate($objp->dp).'-'.$fac->ref,
'link' => $langs->trans("Payment") .' '. $paymentstatic->getNomUrl(1),
'link' => $langs->trans("Payment").' '.$paymentstatic->getNomUrl(1),
'status' => '',
'amount' => -$objp->amount,
'author' => $userstatic->getLoginUrl(1)
@ -223,7 +223,7 @@ if ($id > 0)
dol_print_error($db);
}
if(empty($TData)) {
if (empty($TData)) {
print '<tr class="oddeven"><td colspan="7">'.$langs->trans("NoInvoice").'</td></tr>';
} else {
// Sort array by date ASC to calucalte balance
@ -231,7 +231,7 @@ if ($id > 0)
// Balance calculation
$balance = 0;
foreach($TData as &$data1) {
foreach ($TData as &$data1) {
$balance += $data1['amount'];
$data1['balance'] += $balance;
}
@ -243,7 +243,7 @@ if ($id > 0)
$totalCredit = 0;
// Display array
foreach($TData as $data) {
foreach ($TData as $data) {
$html_class = '';
if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture'];
elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement'];

View File

@ -38,23 +38,23 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php';
// Load translation files required by the page
$langs->loadLangs(array('compta','bills','donation','salaries','accountancy'));
$langs->loadLangs(array('compta', 'bills', 'donation', 'salaries', 'accountancy'));
$date_startmonth=GETPOST('date_startmonth', 'int');
$date_startday=GETPOST('date_startday', 'int');
$date_startyear=GETPOST('date_startyear', 'int');
$date_endmonth=GETPOST('date_endmonth', 'int');
$date_endday=GETPOST('date_endday', 'int');
$date_endyear=GETPOST('date_endyear', 'int');
$showaccountdetail = GETPOST('showaccountdetail', 'aZ09')?GETPOST('showaccountdetail', 'aZ09'):'no';
$date_startmonth = GETPOST('date_startmonth', 'int');
$date_startday = GETPOST('date_startday', 'int');
$date_startyear = GETPOST('date_startyear', 'int');
$date_endmonth = GETPOST('date_endmonth', 'int');
$date_endday = GETPOST('date_endday', 'int');
$date_endyear = GETPOST('date_endyear', 'int');
$showaccountdetail = GETPOST('showaccountdetail', 'aZ09') ?GETPOST('showaccountdetail', 'aZ09') : 'no';
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid > 0) $socid = $user->socid;
if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user, 'compta', '', '', 'resultat');
if (! empty($conf->accounting->enabled)) $result=restrictedArea($user, 'accounting', '', '', 'comptarapport');
if (!empty($conf->comptabilite->enabled)) $result = restrictedArea($user, 'compta', '', '', 'resultat');
if (!empty($conf->accounting->enabled)) $result = restrictedArea($user, 'accounting', '', '', 'comptarapport');
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int');
@ -63,10 +63,10 @@ $offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
//if (! $sortfield) $sortfield='s.nom, s.rowid';
if (! $sortorder) $sortorder='ASC';
if (!$sortorder) $sortorder = 'ASC';
// Date range
$year=GETPOST('year', 'int');
$year = GETPOST('year', 'int');
if (empty($year))
{
$year_current = strftime("%Y", dol_now());
@ -77,50 +77,50 @@ if (empty($year))
$month_current = strftime("%m", dol_now());
$year_start = $year;
}
$date_start=dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end=dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
// We define date_start and date_end
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
$q=GETPOST("q")?GETPOST("q"):0;
if ($q==0)
$q = GETPOST("q") ?GETPOST("q") : 0;
if ($q == 0)
{
// We define date_start and date_end
$year_end=$year_start;
$month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
if (! GETPOST('month'))
$year_end = $year_start;
$month_start = GETPOST("month") ?GETPOST("month") : ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (!GETPOST('month'))
{
if (! GETPOST("year") && $month_start > $month_current)
if (!GETPOST("year") && $month_start > $month_current)
{
$year_start--;
$year_end--;
}
$month_end=$month_start-1;
if ($month_end < 1) $month_end=12;
$month_end = $month_start - 1;
if ($month_end < 1) $month_end = 12;
else $year_end++;
}
else $month_end=$month_start;
$date_start=dol_get_first_day($year_start, $month_start, false); $date_end=dol_get_last_day($year_end, $month_end, false);
else $month_end = $month_start;
$date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false);
}
if ($q==1) { $date_start=dol_get_first_day($year_start, 1, false); $date_end=dol_get_last_day($year_start, 3, false); }
if ($q==2) { $date_start=dol_get_first_day($year_start, 4, false); $date_end=dol_get_last_day($year_start, 6, false); }
if ($q==3) { $date_start=dol_get_first_day($year_start, 7, false); $date_end=dol_get_last_day($year_start, 9, false); }
if ($q==4) { $date_start=dol_get_first_day($year_start, 10, false); $date_end=dol_get_last_day($year_start, 12, false); }
if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); }
if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); }
if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); }
if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); }
}
// $date_start and $date_end are defined. We force $year_start and $nbofyear
$tmps=dol_getdate($date_start);
$tmps = dol_getdate($date_start);
$year_start = $tmps['year'];
$tmpe=dol_getdate($date_end);
$tmpe = dol_getdate($date_end);
$year_end = $tmpe['year'];
$nbofyear = ($year_end - $start_year) + 1;
//var_dump("year_start=".$year_start." year_end=".$year_end." nbofyear=".$nbofyear." date_start=".dol_print_date($date_start, 'dayhour')." date_end=".dol_print_date($date_end, 'dayhour'));
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES' or 'BOOKKEEPING')
$modecompta = $conf->global->ACCOUNTING_MODE;
if (! empty($conf->accounting->enabled)) $modecompta='BOOKKEEPING';
if (GETPOST("modecompta", 'alpha')) $modecompta=GETPOST("modecompta", 'alpha');
if (!empty($conf->accounting->enabled)) $modecompta = 'BOOKKEEPING';
if (GETPOST("modecompta", 'alpha')) $modecompta = GETPOST("modecompta", 'alpha');
$AccCat = new AccountancyCategory($db);
@ -132,54 +132,54 @@ $AccCat = new AccountancyCategory($db);
llxHeader();
$form=new Form($db);
$form = new Form($db);
$periodlink='';
$exportlink='';
$periodlink = '';
$exportlink = '';
$total_ht=0;
$total_ttc=0;
$total_ht = 0;
$total_ttc = 0;
// Affiche en-tete de rapport
if ($modecompta=="CREANCES-DETTES")
if ($modecompta == "CREANCES-DETTES")
{
$name = $langs->trans("ReportInOut").', '.$langs->trans("ByPredefinedAccountGroups");
$calcmode=$langs->trans("CalcModeDebt");
$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode", '<a href="'.$_SERVER["PHP_SELF"].'?date_startyear='.$tmps['year'].'&date_startmonth='.$tmps['mon'].'&date_startday='.$tmps['mday'].'&date_endyear='.$tmpe['year'].'&date_endmonth='.$tmpe['mon'].'&date_endday='.$tmpe['mday'].'&modecompta=RECETTES-DEPENSES">', '</a>').')';
if (! empty($conf->accounting->enabled)) $calcmode.='<br>('.$langs->trans("SeeReportInBookkeepingMode", '<a href="'.$_SERVER["PHP_SELF"].'?date_startyear='.$tmps['year'].'&date_startmonth='.$tmps['mon'].'&date_startday='.$tmps['mday'].'&date_endyear='.$tmpe['year'].'&date_endmonth='.$tmpe['mon'].'&date_endday='.$tmpe['mday'].'&modecompta=BOOKKEEPING">', '</a>').')';
$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year']-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year']+1)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
$description=$langs->trans("RulesResultDue");
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
else $description.= $langs->trans("DepositsAreIncluded");
$builddate=dol_now();
$calcmode = $langs->trans("CalcModeDebt");
$calcmode .= '<br>('.$langs->trans("SeeReportInInputOutputMode", '<a href="'.$_SERVER["PHP_SELF"].'?date_startyear='.$tmps['year'].'&date_startmonth='.$tmps['mon'].'&date_startday='.$tmps['mday'].'&date_endyear='.$tmpe['year'].'&date_endmonth='.$tmpe['mon'].'&date_endday='.$tmpe['mday'].'&modecompta=RECETTES-DEPENSES">', '</a>').')';
if (!empty($conf->accounting->enabled)) $calcmode .= '<br>('.$langs->trans("SeeReportInBookkeepingMode", '<a href="'.$_SERVER["PHP_SELF"].'?date_startyear='.$tmps['year'].'&date_startmonth='.$tmps['mon'].'&date_startday='.$tmps['mday'].'&date_endyear='.$tmpe['year'].'&date_endmonth='.$tmpe['mon'].'&date_endday='.$tmpe['mday'].'&modecompta=BOOKKEEPING">', '</a>').')';
$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink = ($year_start ? "<a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year'] - 1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year'] + 1)."&modecompta=".$modecompta."'>".img_next()."</a>" : "");
$description = $langs->trans("RulesResultDue");
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description .= $langs->trans("DepositsAreNotIncluded");
else $description .= $langs->trans("DepositsAreIncluded");
$builddate = dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
}
elseif ($modecompta=="RECETTES-DEPENSES")
elseif ($modecompta == "RECETTES-DEPENSES")
{
$name = $langs->trans("ReportInOut").', '.$langs->trans("ByPredefinedAccountGroups");
$calcmode=$langs->trans("CalcModeEngagement");
$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode", '<a href="'.$_SERVER["PHP_SELF"].'?date_startyear='.$tmps['year'].'&date_startmonth='.$tmps['mon'].'&date_startday='.$tmps['mday'].'&date_endyear='.$tmpe['year'].'&date_endmonth='.$tmpe['mon'].'&date_endday='.$tmpe['mday'].'&modecompta=CREANCES-DETTES">', '</a>').')';
if (! empty($conf->accounting->enabled)) $calcmode.='<br>('.$langs->trans("SeeReportInBookkeepingMode", '<a href="'.$_SERVER["PHP_SELF"].'?date_startyear='.$tmps['year'].'&date_startmonth='.$tmps['mon'].'&date_startday='.$tmps['mday'].'&date_endyear='.$tmpe['year'].'&date_endmonth='.$tmpe['mon'].'&date_endday='.$tmpe['mday'].'&modecompta=BOOKKEEPING">', '</a>').')';
$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year']-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year']+1)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
$description=$langs->trans("RulesResultInOut");
$builddate=dol_now();
$calcmode = $langs->trans("CalcModeEngagement");
$calcmode .= '<br>('.$langs->trans("SeeReportInDueDebtMode", '<a href="'.$_SERVER["PHP_SELF"].'?date_startyear='.$tmps['year'].'&date_startmonth='.$tmps['mon'].'&date_startday='.$tmps['mday'].'&date_endyear='.$tmpe['year'].'&date_endmonth='.$tmpe['mon'].'&date_endday='.$tmpe['mday'].'&modecompta=CREANCES-DETTES">', '</a>').')';
if (!empty($conf->accounting->enabled)) $calcmode .= '<br>('.$langs->trans("SeeReportInBookkeepingMode", '<a href="'.$_SERVER["PHP_SELF"].'?date_startyear='.$tmps['year'].'&date_startmonth='.$tmps['mon'].'&date_startday='.$tmps['mday'].'&date_endyear='.$tmpe['year'].'&date_endmonth='.$tmpe['mon'].'&date_endday='.$tmpe['mday'].'&modecompta=BOOKKEEPING">', '</a>').')';
$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink = ($year_start ? "<a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year'] - 1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year'] + 1)."&modecompta=".$modecompta."'>".img_next()."</a>" : "");
$description = $langs->trans("RulesResultInOut");
$builddate = dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
}
elseif ($modecompta=="BOOKKEEPING")
elseif ($modecompta == "BOOKKEEPING")
{
$name = $langs->trans("ReportInOut").', '.$langs->trans("ByPredefinedAccountGroups");
$calcmode=$langs->trans("CalcModeBookkeeping");
$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode", '<a href="'.$_SERVER["PHP_SELF"].'?date_startyear='.$tmps['year'].'&date_startmonth='.$tmps['mon'].'&date_startday='.$tmps['mday'].'&date_endyear='.$tmpe['year'].'&date_endmonth='.$tmpe['mon'].'&date_endday='.$tmpe['mday'].'&modecompta=RECETTES-DEPENSES">', '</a>').')';
$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode", '<a href="'.$_SERVER["PHP_SELF"].'?date_startyear='.$tmps['year'].'&date_startmonth='.$tmps['mon'].'&date_startday='.$tmps['mday'].'&date_endyear='.$tmpe['year'].'&date_endmonth='.$tmpe['mon'].'&date_endday='.$tmpe['mday'].'&modecompta=CREANCES-DETTES">', '</a>').')';
$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$arraylist=array('no'=>$langs->trans("No"), 'yes'=>$langs->trans("AccountWithNonZeroValues"), 'all'=>$langs->trans("All"));
$period.=' &nbsp; &nbsp; '.$langs->trans("DetailByAccount").' '. $form->selectarray('showaccountdetail', $arraylist, $showaccountdetail, 0);
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year']-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year']+1)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
$description=$langs->trans("RulesResultBookkeepingPredefined");
$description.=' ('.$langs->trans("SeePageForSetup", DOL_URL_ROOT.'/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', $langs->transnoentitiesnoconv("Accountancy").' / '.$langs->transnoentitiesnoconv("Setup").' / '.$langs->transnoentitiesnoconv("Chartofaccounts")).')';
$builddate=dol_now();
$calcmode = $langs->trans("CalcModeBookkeeping");
$calcmode .= '<br>('.$langs->trans("SeeReportInInputOutputMode", '<a href="'.$_SERVER["PHP_SELF"].'?date_startyear='.$tmps['year'].'&date_startmonth='.$tmps['mon'].'&date_startday='.$tmps['mday'].'&date_endyear='.$tmpe['year'].'&date_endmonth='.$tmpe['mon'].'&date_endday='.$tmpe['mday'].'&modecompta=RECETTES-DEPENSES">', '</a>').')';
$calcmode .= '<br>('.$langs->trans("SeeReportInDueDebtMode", '<a href="'.$_SERVER["PHP_SELF"].'?date_startyear='.$tmps['year'].'&date_startmonth='.$tmps['mon'].'&date_startday='.$tmps['mday'].'&date_endyear='.$tmpe['year'].'&date_endmonth='.$tmpe['mon'].'&date_endday='.$tmpe['mday'].'&modecompta=CREANCES-DETTES">', '</a>').')';
$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$arraylist = array('no'=>$langs->trans("No"), 'yes'=>$langs->trans("AccountWithNonZeroValues"), 'all'=>$langs->trans("All"));
$period .= ' &nbsp; &nbsp; '.$langs->trans("DetailByAccount").' '.$form->selectarray('showaccountdetail', $arraylist, $showaccountdetail, 0);
$periodlink = ($year_start ? "<a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year'] - 1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year'] + 1)."&modecompta=".$modecompta."'>".img_next()."</a>" : "");
$description = $langs->trans("RulesResultBookkeepingPredefined");
$description .= ' ('.$langs->trans("SeePageForSetup", DOL_URL_ROOT.'/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', $langs->transnoentitiesnoconv("Accountancy").' / '.$langs->transnoentitiesnoconv("Setup").' / '.$langs->transnoentitiesnoconv("Chartofaccounts")).')';
$builddate = dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
}
@ -187,19 +187,19 @@ $hselected = 'report';
report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array('modecompta'=>$modecompta), $calcmode);
if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING')
if (!empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING')
{
print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1);
}
// Show report array
$param='&modecompta='.$modecompta;
if ($date_startday) $param.='&date_startday='.$date_startday;
if ($date_startmonth) $param.='&date_startmonth='.$date_startmonth;
if ($date_startyear) $param.='&date_startyear='.$date_startyear;
if ($date_endday) $param.='&date_endday='.$date_endday;
if ($date_endmonth) $param.='&date_endmonth='.$date_endmonth;
if ($date_endyear) $param.='&date_endyear='.$date_startyear;
$param = '&modecompta='.$modecompta;
if ($date_startday) $param .= '&date_startday='.$date_startday;
if ($date_startmonth) $param .= '&date_startmonth='.$date_startmonth;
if ($date_startyear) $param .= '&date_startyear='.$date_startyear;
if ($date_endday) $param .= '&date_endday='.$date_endday;
if ($date_endmonth) $param .= '&date_endmonth='.$date_endmonth;
if ($date_endyear) $param .= '&date_endyear='.$date_startyear;
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
@ -225,26 +225,26 @@ if ($modecompta == 'BOOKKEEPING')
{
$predefinedgroupwhere = "(";
//$predefinedgroupwhere.= " (pcg_type = 'EXPENSE' and pcg_subtype in ('PRODUCT','SERVICE'))";
$predefinedgroupwhere.= " (pcg_type = 'EXPENSE')";
$predefinedgroupwhere.= " OR ";
$predefinedgroupwhere .= " (pcg_type = 'EXPENSE')";
$predefinedgroupwhere .= " OR ";
//$predefinedgroupwhere.= " (pcg_type = 'INCOME' and pcg_subtype in ('PRODUCT','SERVICE'))";
$predefinedgroupwhere.= " (pcg_type = 'INCOME')";
$predefinedgroupwhere.= ")";
$predefinedgroupwhere .= " (pcg_type = 'INCOME')";
$predefinedgroupwhere .= ")";
$charofaccountstring = $conf->global->CHARTOFACCOUNTS;
$charofaccountstring=dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version');
$charofaccountstring = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version');
$sql = "SELECT f.thirdparty_code as name, -1 as socid, aa.pcg_type, aa.pcg_subtype, sum(f.credit - f.debit) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as f";
$sql.= ", ".MAIN_DB_PREFIX."accounting_account as aa";
$sql.= " WHERE f.numero_compte = aa.account_number";
$sql.= " AND ".$predefinedgroupwhere;
$sql.= " AND fk_pcg_version = '".$db->escape($charofaccountstring)."'";
$sql.= " AND f.entity = ".$conf->entity;
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND f.doc_date >= '".$db->idate($date_start)."' AND f.doc_date <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY pcg_type, pcg_subtype, name, socid";
$sql.= $db->order($sortfield, $sortorder);
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as f";
$sql .= ", ".MAIN_DB_PREFIX."accounting_account as aa";
$sql .= " WHERE f.numero_compte = aa.account_number";
$sql .= " AND ".$predefinedgroupwhere;
$sql .= " AND fk_pcg_version = '".$db->escape($charofaccountstring)."'";
$sql .= " AND f.entity = ".$conf->entity;
if (!empty($date_start) && !empty($date_end))
$sql .= " AND f.doc_date >= '".$db->idate($date_start)."' AND f.doc_date <= '".$db->idate($date_end)."'";
$sql .= " GROUP BY pcg_type, pcg_subtype, name, socid";
$sql .= $db->order($sortfield, $sortorder);
$oldpcgtype = '';
$oldpcgsubtype = '';
@ -268,32 +268,32 @@ if ($modecompta == 'BOOKKEEPING')
print '<tr class="oddeven">';
print '<td>&nbsp;</td>';
print '<td>'.$objp->pcg_type.($objp->pcg_subtype != 'XXXXXX'?' - '.$objp->pcg_subtype:'').($objp->name?' ('.$objp->name.')':'')."</td>\n";
print '<td>'.$objp->pcg_type.($objp->pcg_subtype != 'XXXXXX' ? ' - '.$objp->pcg_subtype : '').($objp->name ? ' ('.$objp->name.')' : '')."</td>\n";
print '<td class="right">'.price($objp->amount)."</td>\n";
print "</tr>\n";
$total_ht += (isset($objp->amount)?$objp->amount:0);
$total_ttc += (isset($objp->amount)?$objp->amount:0);
$total_ht += (isset($objp->amount) ? $objp->amount : 0);
$total_ttc += (isset($objp->amount) ? $objp->amount : 0);
// Loop on detail of all accounts
// This make 14 calls for each detail of account (NP, N and month m)
if ($showaccountdetail != 'no')
{
$tmppredefinedgroupwhere="pcg_type = '".$db->escape($objp->pcg_type)."' AND pcg_subtype = '".$db->escape($objp->pcg_subtype)."'";
$tmppredefinedgroupwhere.= " AND fk_pcg_version = '".$db->escape($charofaccountstring)."'";
$tmppredefinedgroupwhere = "pcg_type = '".$db->escape($objp->pcg_type)."' AND pcg_subtype = '".$db->escape($objp->pcg_subtype)."'";
$tmppredefinedgroupwhere .= " AND fk_pcg_version = '".$db->escape($charofaccountstring)."'";
//$tmppredefinedgroupwhere.= " AND thirdparty_code = '".$db->escape($objp->name)."'";
// Get cpts of category/group
$cpts = $AccCat->getCptsCat(0, $tmppredefinedgroupwhere);
foreach($cpts as $j => $cpt)
foreach ($cpts as $j => $cpt)
{
$return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, $cpt['dc']);
if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors');
$resultN=0;
$resultN = 0;
} else {
$resultN=$AccCat->sdc;
$resultN = $AccCat->sdc;
}
@ -301,8 +301,8 @@ if ($modecompta == 'BOOKKEEPING')
{
print '<tr>';
print '<td></td>';
print '<td class="tdoverflowmax200"> &nbsp; &nbsp; ' . length_accountg($cpt['account_number']) . ' - ' . $cpt['account_label'] . '</td>';
print '<td class="right">' . price($resultN) . '</td>';
print '<td class="tdoverflowmax200"> &nbsp; &nbsp; '.length_accountg($cpt['account_number']).' - '.$cpt['account_label'].'</td>';
print '<td class="right">'.price($resultN).'</td>';
print "</tr>\n";
}
}
@ -328,16 +328,16 @@ else
if ($modecompta == 'CREANCES-DETTES')
{
$sql = "SELECT s.nom as name, s.rowid as socid, sum(f.total) as amount_ht, sum(f.total_ttc) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= " AND f.fk_statut IN (1,2)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$sql.= " AND f.type IN (0,1,2,5)";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE f.fk_soc = s.rowid";
$sql .= " AND f.fk_statut IN (1,2)";
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$sql .= " AND f.type IN (0,1,2,5)";
else
$sql.= " AND f.type IN (0,1,2,3,5)";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql .= " AND f.type IN (0,1,2,3,5)";
if (!empty($date_start) && !empty($date_end))
$sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
}
elseif ($modecompta == 'RECETTES-DEPENSES')
{
@ -346,20 +346,20 @@ else
* vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin)
*/
$sql = "SELECT s.nom as name, s.rowid as socid, sum(pf.amount) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
$sql.= ", ".MAIN_DB_PREFIX."paiement_facture as pf";
$sql.= ", ".MAIN_DB_PREFIX."paiement as p";
$sql.= " WHERE p.rowid = pf.fk_paiement";
$sql.= " AND pf.fk_facture = f.rowid";
$sql.= " AND f.fk_soc = s.rowid";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."facture as f";
$sql .= ", ".MAIN_DB_PREFIX."paiement_facture as pf";
$sql .= ", ".MAIN_DB_PREFIX."paiement as p";
$sql .= " WHERE p.rowid = pf.fk_paiement";
$sql .= " AND pf.fk_facture = f.rowid";
$sql .= " AND f.fk_soc = s.rowid";
if (!empty($date_start) && !empty($date_end))
$sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
}
$sql.= " AND f.entity IN (".getEntity('invoice').")";
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
$sql.= " GROUP BY name, socid";
$sql.= $db->order($sortfield, $sortorder);
$sql .= " AND f.entity IN (".getEntity('invoice').")";
if ($socid) $sql .= " AND f.fk_soc = ".$socid;
$sql .= " GROUP BY name, socid";
$sql .= $db->order($sortfield, $sortorder);
dol_syslog("get customer invoices", LOG_DEBUG);
$result = $db->query($sql);
@ -377,7 +377,7 @@ else
print '<td class="right">'.price($objp->amount_ht)."</td>\n";
print '<td class="right">'.price($objp->amount_ttc)."</td>\n";
$total_ht += (isset($objp->amount_ht)?$objp->amount_ht:0);
$total_ht += (isset($objp->amount_ht) ? $objp->amount_ht : 0);
$total_ttc += $objp->amount_ttc;
print "</tr>\n";
$i++;
@ -391,18 +391,18 @@ else
if ($modecompta == 'RECETTES-DEPENSES')
{
$sql = "SELECT 'Autres' as name, '0' as idp, sum(p.amount) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= ", ".MAIN_DB_PREFIX."paiement as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
$sql.= " WHERE pf.rowid IS NULL";
$sql.= " AND p.fk_bank = b.rowid";
$sql.= " AND b.fk_account = ba.rowid";
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY name, idp";
$sql.= " ORDER BY name";
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql .= ", ".MAIN_DB_PREFIX."paiement as p";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
$sql .= " WHERE pf.rowid IS NULL";
$sql .= " AND p.fk_bank = b.rowid";
$sql .= " AND b.fk_account = ba.rowid";
$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
if (!empty($date_start) && !empty($date_end))
$sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql .= " GROUP BY name, idp";
$sql .= " ORDER BY name";
dol_syslog("get old customer payments not linked to invoices", LOG_DEBUG);
$result = $db->query($sql);
@ -422,7 +422,7 @@ else
print '<td class="right">'.price($objp->amount_ht)."</td>\n";
print '<td class="right">'.price($objp->amount_ttc)."</td>\n";
$total_ht += (isset($objp->amount_ht)?$objp->amount_ht:0);
$total_ht += (isset($objp->amount_ht) ? $objp->amount_ht : 0);
$total_ttc += $objp->amount_ttc;
print "</tr>\n";
@ -455,35 +455,35 @@ else
if ($modecompta == 'CREANCES-DETTES')
{
$sql = "SELECT s.nom as name, s.rowid as socid, sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f";
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= " AND f.fk_statut IN (1,2)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$sql.= " AND f.type IN (0,1,2)";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= " WHERE f.fk_soc = s.rowid";
$sql .= " AND f.fk_statut IN (1,2)";
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$sql .= " AND f.type IN (0,1,2)";
else
$sql.= " AND f.type IN (0,1,2,3)";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql .= " AND f.type IN (0,1,2,3)";
if (!empty($date_start) && !empty($date_end))
$sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
}
elseif ($modecompta == 'RECETTES-DEPENSES')
{
$sql = "SELECT s.nom as name, s.rowid as socid, sum(pf.amount) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
$sql.= ", ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as f";
$sql.= " ON pf.fk_facturefourn = f.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s";
$sql.= " ON f.fk_soc = s.rowid";
$sql.= " WHERE p.rowid = pf.fk_paiementfourn ";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
$sql .= ", ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= " ON pf.fk_facturefourn = f.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s";
$sql .= " ON f.fk_soc = s.rowid";
$sql .= " WHERE p.rowid = pf.fk_paiementfourn ";
if (!empty($date_start) && !empty($date_end))
$sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
}
$sql.= " AND f.entity = ".$conf->entity;
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
$sql .= " AND f.entity = ".$conf->entity;
if ($socid) $sql .= " AND f.fk_soc = ".$socid;
$sql .= " GROUP BY name, socid";
$sql.= $db->order($sortfield, $sortorder);
$sql .= $db->order($sortfield, $sortorder);
print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("SuppliersInvoices").'</td></tr>';
@ -507,9 +507,9 @@ else
print '<td class="right">'.price(-$objp->amount_ht)."</td>\n";
print '<td class="right">'.price(-$objp->amount_ttc)."</td>\n";
$total_ht -= (isset($objp->amount_ht)?$objp->amount_ht:0);
$total_ht -= (isset($objp->amount_ht) ? $objp->amount_ht : 0);
$total_ttc -= $objp->amount_ttc;
$subtotal_ht += (isset($objp->amount_ht)?$objp->amount_ht:0);
$subtotal_ht += (isset($objp->amount_ht) ? $objp->amount_ht : 0);
$subtotal_ttc += $objp->amount_ttc;
print "</tr>\n";
@ -544,36 +544,36 @@ else
if ($modecompta == 'CREANCES-DETTES')
{
$sql = "SELECT c.id, c.libelle as label, sum(cs.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql.= " WHERE cs.fk_type = c.id";
$sql.= " AND c.deductible = 0";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
$sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql .= " WHERE cs.fk_type = c.id";
$sql .= " AND c.deductible = 0";
if (!empty($date_start) && !empty($date_end))
$sql .= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
}
elseif ($modecompta == 'RECETTES-DEPENSES')
{
$sql = "SELECT c.id, c.libelle as label, sum(p.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql.= ", ".MAIN_DB_PREFIX."paiementcharge as p";
$sql.= " WHERE p.fk_charge = cs.rowid";
$sql.= " AND cs.fk_type = c.id";
$sql.= " AND c.deductible = 0";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql .= ", ".MAIN_DB_PREFIX."paiementcharge as p";
$sql .= " WHERE p.fk_charge = cs.rowid";
$sql .= " AND cs.fk_type = c.id";
$sql .= " AND c.deductible = 0";
if (!empty($date_start) && !empty($date_end))
$sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
}
$sql.= " AND cs.entity = ".$conf->entity;
$sql.= " GROUP BY c.libelle, c.id";
$sql .= " AND cs.entity = ".$conf->entity;
$sql .= " GROUP BY c.libelle, c.id";
$newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'c.libelle, c.id';
if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
$sql.= $db->order($newsortfield, $sortorder);
$sql .= $db->order($newsortfield, $sortorder);
dol_syslog("get social contributions deductible=0", LOG_DEBUG);
$result=$db->query($sql);
$result = $db->query($sql);
$subtotal_ht = 0;
$subtotal_ttc = 0;
if ($result) {
@ -620,36 +620,36 @@ else
if ($modecompta == 'CREANCES-DETTES')
{
$sql = "SELECT c.id, c.libelle as label, sum(cs.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql.= " WHERE cs.fk_type = c.id";
$sql.= " AND c.deductible = 1";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
$sql.= " AND cs.entity = ".$conf->entity;
$sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql .= " WHERE cs.fk_type = c.id";
$sql .= " AND c.deductible = 1";
if (!empty($date_start) && !empty($date_end))
$sql .= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
$sql .= " AND cs.entity = ".$conf->entity;
}
elseif ($modecompta == 'RECETTES-DEPENSES')
{
$sql = "SELECT c.id, c.libelle as label, sum(p.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql.= ", ".MAIN_DB_PREFIX."paiementcharge as p";
$sql.= " WHERE p.fk_charge = cs.rowid";
$sql.= " AND cs.fk_type = c.id";
$sql.= " AND c.deductible = 1";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql.= " AND cs.entity = ".$conf->entity;
$sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql .= ", ".MAIN_DB_PREFIX."paiementcharge as p";
$sql .= " WHERE p.fk_charge = cs.rowid";
$sql .= " AND cs.fk_type = c.id";
$sql .= " AND c.deductible = 1";
if (!empty($date_start) && !empty($date_end))
$sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql .= " AND cs.entity = ".$conf->entity;
}
$sql.= " GROUP BY c.libelle, c.id";
$sql .= " GROUP BY c.libelle, c.id";
$newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'c.libelle, c.id';
if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
$sql.= $db->order($newsortfield, $sortorder);
$sql .= $db->order($newsortfield, $sortorder);
dol_syslog("get social contributions deductible=1", LOG_DEBUG);
$result=$db->query($sql);
$result = $db->query($sql);
$subtotal_ht = 0;
$subtotal_ttc = 0;
if ($result) {
@ -710,7 +710,7 @@ else
* Salaries
*/
if (! empty($conf->salaries->enabled))
if (!empty($conf->salaries->enabled))
{
print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("Salaries").'</td></tr>';
@ -723,22 +723,22 @@ else
}
$sql = "SELECT u.rowid, u.firstname, u.lastname, p.fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as p";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user";
$sql.= " WHERE p.entity IN (".getEntity('payment_salary').")";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'";
$sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user";
$sql .= " WHERE p.entity IN (".getEntity('payment_salary').")";
if (!empty($date_start) && !empty($date_end))
$sql .= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY u.rowid, u.firstname, u.lastname, p.fk_user, p.label, dm";
$sql .= " GROUP BY u.rowid, u.firstname, u.lastname, p.fk_user, p.label, dm";
$newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'u.firstname, u.lastname';
if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
$sql.= $db->order($newsortfield, $sortorder);
$sql .= $db->order($newsortfield, $sortorder);
}
dol_syslog("get payment salaries");
$result=$db->query($sql);
$result = $db->query($sql);
$subtotal_ht = 0;
$subtotal_ttc = 0;
if ($result)
@ -789,46 +789,46 @@ else
* Expense
*/
if (! empty($conf->expensereport->enabled))
if (!empty($conf->expensereport->enabled))
{
if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES')
{
$langs->load('trips');
if ($modecompta == 'CREANCES-DETTES') {
$sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(date_valid,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
$sql.= " WHERE p.entity IN (".getEntity('expensereport').")";
$sql.= " AND p.fk_statut>=5";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as p";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
$sql .= " WHERE p.entity IN (".getEntity('expensereport').")";
$sql .= " AND p.fk_statut>=5";
$column='p.date_valid';
$column = 'p.date_valid';
} else {
$sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(pe.datep,'%Y-%m') as dm, sum(p.total_ht) as amount_ht, sum(p.total_ttc) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
$sql.= " WHERE p.entity IN (".getEntity('expensereport').")";
$sql.= " AND p.fk_statut>=5";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as p";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
$sql .= " WHERE p.entity IN (".getEntity('expensereport').")";
$sql .= " AND p.fk_statut>=5";
$column='pe.datep';
$column = 'pe.datep';
}
if (! empty($date_start) && ! empty($date_end))
if (!empty($date_start) && !empty($date_end))
{
$sql.= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'";
$sql .= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'";
}
$sql.= " GROUP BY u.rowid, p.rowid, p.ref, u.firstname, u.lastname, dm";
$sql .= " GROUP BY u.rowid, p.rowid, p.ref, u.firstname, u.lastname, dm";
$newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'p.ref';
$sql.= $db->order($newsortfield, $sortorder);
$sql .= $db->order($newsortfield, $sortorder);
}
print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("ExpenseReport").'</td></tr>';
dol_syslog("get expense report outcome");
$result=$db->query($sql);
$result = $db->query($sql);
$subtotal_ht = 0;
$subtotal_ttc = 0;
if ($result)
@ -873,7 +873,7 @@ else
* Donations
*/
if (! empty($conf->don->enabled))
if (!empty($conf->don->enabled))
{
print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("Donations").'</td></tr>';
@ -882,31 +882,31 @@ else
if ($modecompta == 'CREANCES-DETTES')
{
$sql = "SELECT p.societe as name, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."don as p";
$sql.= " WHERE p.entity IN (".getEntity('donation').")";
$sql.= " AND fk_statut in (1,2)";
$sql .= " FROM ".MAIN_DB_PREFIX."don as p";
$sql .= " WHERE p.entity IN (".getEntity('donation').")";
$sql .= " AND fk_statut in (1,2)";
}
else
{
$sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."don as p";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
$sql.= " WHERE p.entity IN (".getEntity('donation').")";
$sql.= " AND fk_statut >= 2";
$sql .= " FROM ".MAIN_DB_PREFIX."don as p";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
$sql .= " WHERE p.entity IN (".getEntity('donation').")";
$sql .= " AND fk_statut >= 2";
}
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'";
if (!empty($date_start) && !empty($date_end))
$sql .= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'";
}
$sql.= " GROUP BY p.societe, p.firstname, p.lastname, dm";
$sql .= " GROUP BY p.societe, p.firstname, p.lastname, dm";
$newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'p.societe, p.firstname, p.lastname, dm';
if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
$sql.= $db->order($newsortfield, $sortorder);
$sql .= $db->order($newsortfield, $sortorder);
dol_syslog("get dunning");
$result=$db->query($sql);
$result = $db->query($sql);
$subtotal_ht = 0;
$subtotal_ttc = 0;
if ($result)
@ -926,7 +926,7 @@ else
print '<tr class="oddeven"><td>&nbsp;</td>';
print "<td>".$langs->trans("Donation")." <a href=\"".DOL_URL_ROOT."/don/list.php?search_company=".$obj->name."&search_name=".$obj->firstname." ".$obj->lastname."\">".$obj->name. " ".$obj->firstname." ".$obj->lastname."</a></td>\n";
print "<td>".$langs->trans("Donation")." <a href=\"".DOL_URL_ROOT."/don/list.php?search_company=".$obj->name."&search_name=".$obj->firstname." ".$obj->lastname."\">".$obj->name." ".$obj->firstname." ".$obj->lastname."</a></td>\n";
if ($modecompta == 'CREANCES-DETTES') print '<td class="right">'.price($obj->amount).'</td>';
print '<td class="right">'.price($obj->amount).'</td>';
@ -966,26 +966,26 @@ else
if ($modecompta == 'CREANCES-DETTES')
{
// TVA a payer
$amount=0;
$amount = 0;
$sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.tva) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql.= " WHERE f.fk_statut IN (1,2)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$sql.= " AND f.type IN (0,1,2,5)";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE f.fk_statut IN (1,2)";
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$sql .= " AND f.type IN (0,1,2,5)";
else
$sql.= " AND f.type IN (0,1,2,3,5)";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql.= " AND f.entity IN (".getEntity('invoice').")";
$sql.= " GROUP BY dm";
$sql .= " AND f.type IN (0,1,2,3,5)";
if (!empty($date_start) && !empty($date_end))
$sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql .= " AND f.entity IN (".getEntity('invoice').")";
$sql .= " GROUP BY dm";
$newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'dm';
if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
$sql.= $db->order($newsortfield, $sortorder);
$sql .= $db->order($newsortfield, $sortorder);
dol_syslog("get vat to pay", LOG_DEBUG);
$result=$db->query($sql);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
@ -1014,26 +1014,26 @@ else
print "</tr>\n";
// TVA a recuperer
$amount=0;
$amount = 0;
$sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total_tva) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
$sql.= " WHERE f.fk_statut IN (1,2)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$sql.= " AND f.type IN (0,1,2)";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= " WHERE f.fk_statut IN (1,2)";
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$sql .= " AND f.type IN (0,1,2)";
else
$sql.= " AND f.type IN (0,1,2,3)";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql.= " AND f.entity = ".$conf->entity;
$sql.= " GROUP BY dm";
$sql .= " AND f.type IN (0,1,2,3)";
if (!empty($date_start) && !empty($date_end))
$sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql .= " AND f.entity = ".$conf->entity;
$sql .= " GROUP BY dm";
$newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'dm';
if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
$sql.= $db->order($newsortfield, $sortorder);
$sql .= $db->order($newsortfield, $sortorder);
dol_syslog("get vat received back", LOG_DEBUG);
$result=$db->query($sql);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
@ -1065,22 +1065,22 @@ else
else
{
// VAT really already paid
$amount=0;
$amount = 0;
$sql = "SELECT date_format(t.datev,'%Y-%m') as dm, sum(t.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
$sql.= " WHERE amount > 0";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'";
$sql.= " AND t.entity = ".$conf->entity;
$sql.= " GROUP BY dm";
$sql .= " FROM ".MAIN_DB_PREFIX."tva as t";
$sql .= " WHERE amount > 0";
if (!empty($date_start) && !empty($date_end))
$sql .= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'";
$sql .= " AND t.entity = ".$conf->entity;
$sql .= " GROUP BY dm";
$newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'dm';
if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
$sql.= $db->order($newsortfield, $sortorder);
$sql .= $db->order($newsortfield, $sortorder);
dol_syslog("get vat really paid", LOG_DEBUG);
$result=$db->query($sql);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
$i = 0;
@ -1109,22 +1109,22 @@ else
print "</tr>\n";
// VAT really received
$amount=0;
$amount = 0;
$sql = "SELECT date_format(t.datev,'%Y-%m') as dm, sum(t.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
$sql.= " WHERE amount < 0";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'";
$sql.= " AND t.entity = ".$conf->entity;
$sql.= " GROUP BY dm";
$sql .= " FROM ".MAIN_DB_PREFIX."tva as t";
$sql .= " WHERE amount < 0";
if (!empty($date_start) && !empty($date_end))
$sql .= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'";
$sql .= " AND t.entity = ".$conf->entity;
$sql .= " GROUP BY dm";
$newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'dm';
if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
$sql.= $db->order($newsortfield, $sortorder);
$sql .= $db->order($newsortfield, $sortorder);
dol_syslog("get vat really received back", LOG_DEBUG);
$result=$db->query($sql);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
$i = 0;
@ -1174,7 +1174,7 @@ $parameters["date_end"] = $date_end;
$parameters["bc"] = $bc;
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('externalbalance'));
$reshook=$hookmanager->executeHooks('addBalanceLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$reshook = $hookmanager->executeHooks('addBalanceLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
print $hookmanager->resPrint;
if ($mysoc->tva_assuj != 'franchise') // Assujetti

View File

@ -41,10 +41,10 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php';
// Load translation files required by the page
$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin"));
$langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin"));
// Date range
$year=GETPOST("year", "int");
$year = GETPOST("year", "int");
if (empty($year))
{
$year_current = strftime("%Y", dol_now());
@ -53,29 +53,29 @@ if (empty($year))
$year_current = $year;
$year_start = $year;
}
$date_start=dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"));
$date_end=dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"));
$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"));
$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"));
// Quarter
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
$q=GETPOST("q");
$q = GETPOST("q");
if (empty($q))
{
if (GETPOST("month", 'int')) { $date_start=dol_get_first_day($year_start, GETPOST("month", 'int'), false); $date_end=dol_get_last_day($year_start, GETPOST("month", 'int'), false); }
if (GETPOST("month", 'int')) { $date_start = dol_get_first_day($year_start, GETPOST("month", 'int'), false); $date_end = dol_get_last_day($year_start, GETPOST("month", 'int'), false); }
else
{
$date_start=dol_get_first_day($year_start, empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START, false);
if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end=dol_time_plus_duree($date_start, 3, 'm') - 1;
elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end=dol_time_plus_duree($date_start, 1, 'y') - 1;
elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end=dol_time_plus_duree($date_start, 1, 'm') - 1;
$date_start = dol_get_first_day($year_start, empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START, false);
if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1;
elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1;
elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1;
}
}
else
{
if ($q==1) { $date_start=dol_get_first_day($year_start, 1, false); $date_end=dol_get_last_day($year_start, 3, false); }
if ($q==2) { $date_start=dol_get_first_day($year_start, 4, false); $date_end=dol_get_last_day($year_start, 6, false); }
if ($q==3) { $date_start=dol_get_first_day($year_start, 7, false); $date_end=dol_get_last_day($year_start, 9, false); }
if ($q==4) { $date_start=dol_get_first_day($year_start, 10, false); $date_end=dol_get_last_day($year_start, 12, false); }
if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); }
if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); }
if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); }
if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); }
}
}
@ -85,12 +85,12 @@ if (empty($min)) $min = 0;
// Define modetax (0 or 1)
// 0=normal, 1=option vat for services is on debit, 2=option on payments for products
$modetax = $conf->global->TAX_MODE;
if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax", 'int');
if (empty($modetax)) $modetax=0;
if (GETPOSTISSET("modetax")) $modetax = GETPOST("modetax", 'int');
if (empty($modetax)) $modetax = 0;
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) $socid=$user->socid;
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'tax', '', '', 'charges');
@ -99,21 +99,21 @@ $result = restrictedArea($user, 'tax', '', '', 'charges');
* View
*/
$form=new Form($db);
$company_static=new Societe($db);
$invoice_customer=new Facture($db);
$invoice_supplier=new FactureFournisseur($db);
$expensereport=new ExpenseReport($db);
$product_static=new Product($db);
$payment_static=new Paiement($db);
$paymentfourn_static=new PaiementFourn($db);
$paymentexpensereport_static=new PaymentExpenseReport($db);
$form = new Form($db);
$company_static = new Societe($db);
$invoice_customer = new Facture($db);
$invoice_supplier = new FactureFournisseur($db);
$expensereport = new ExpenseReport($db);
$product_static = new Product($db);
$payment_static = new Paiement($db);
$paymentfourn_static = new PaiementFourn($db);
$paymentexpensereport_static = new PaymentExpenseReport($db);
$morequerystring='';
$listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday');
$morequerystring = '';
$listofparams = array('date_startmonth', 'date_startyear', 'date_startday', 'date_endmonth', 'date_endyear', 'date_endday');
foreach ($listofparams as $param)
{
if (GETPOST($param)!='') $morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param);
if (GETPOST($param) != '') $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param);
}
$special_report = false;
@ -123,80 +123,80 @@ if (isset($_REQUEST['extra_report']) && $_REQUEST['extra_report'] == 1) {
llxHeader('', $langs->trans("VATReport"), '', '', 0, 0, '', '', $morequerystring);
$fsearch ='<!-- hidden fields for form -->';
$fsearch.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$fsearch.='<input type="hidden" name="modetax" value="'.$modetax.'">';
$fsearch.=$langs->trans("SalesTurnoverMinimum").': ';
$fsearch.='<input type="text" name="min" id="min" value="'.$min.'" size="6">';
$fsearch = '<!-- hidden fields for form -->';
$fsearch .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$fsearch .= '<input type="hidden" name="modetax" value="'.$modetax.'">';
$fsearch .= $langs->trans("SalesTurnoverMinimum").': ';
$fsearch .= '<input type="text" name="min" id="min" value="'.$min.'" size="6">';
// Show report header
$name=$langs->trans("VATReportByThirdParties");
$calcmode='';
if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault');
if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption');
if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices');
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')';
$name = $langs->trans("VATReportByThirdParties");
$calcmode = '';
if ($modetax == 0) $calcmode = $langs->trans('OptionVATDefault');
if ($modetax == 1) $calcmode = $langs->trans('OptionVATDebitOption');
if ($modetax == 2) $calcmode = $langs->trans('OptionPaymentForProductAndServices');
$calcmode .= '<br>('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')';
// Set period
$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$prevyear=$year_start;
$prevquarter=$q;
$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$prevyear = $year_start;
$prevquarter = $q;
if ($prevquarter > 1) {
$prevquarter--;
} else {
$prevquarter=4;
$prevquarter = 4;
$prevyear--;
}
$nextyear=$year_start;
$nextquarter=$q;
$nextyear = $year_start;
$nextquarter = $q;
if ($nextquarter < 4) {
$nextquarter++;
} else {
$nextquarter=1;
$nextquarter = 1;
$nextyear++;
}
$builddate=dol_now();
$builddate = dol_now();
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description.=$langs->trans("RulesVATDueProducts");
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description.=$langs->trans("RulesVATInProducts");
if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description.='<br>'.$langs->trans("RulesVATDueServices");
if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description.='<br>'.$langs->trans("RulesVATInServices");
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description.='<br>'.$langs->trans("DepositsAreNotIncluded");
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description .= $langs->trans("RulesVATDueProducts");
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description .= $langs->trans("RulesVATInProducts");
if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description .= '<br>'.$langs->trans("RulesVATDueServices");
if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description .= '<br>'.$langs->trans("RulesVATInServices");
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description .= '<br>'.$langs->trans("DepositsAreNotIncluded");
}
if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='<br>'.$langs->trans("ThisIsAnEstimatedValue");
if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description .= '<br>'.$langs->trans("ThisIsAnEstimatedValue");
//$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start-1)."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+1)."&modetax=".$modetax."'>".img_next()."</a>":"");
$description.=$fsearch;
if (! empty($conf->global->TAX_REPORT_EXTRA_REPORT))
$description .= $fsearch;
if (!empty($conf->global->TAX_REPORT_EXTRA_REPORT))
{
$description.='<br>'
. '<input type="radio" name="extra_report" value="0" '.($special_report?'':'checked="checked"').'> '
$description .= '<br>'
. '<input type="radio" name="extra_report" value="0" '.($special_report ? '' : 'checked="checked"').'> '
. $langs->trans('SimpleReport')
. '</input>'
. '<br>'
. '<input type="radio" name="extra_report" value="1" '.($special_report?'checked="checked"':'').'> '
. '<input type="radio" name="extra_report" value="1" '.($special_report ? 'checked="checked"' : '').'> '
. $langs->trans('AddExtraReport')
. '</input>'
. '<br>';
}
$elementcust=$langs->trans("CustomersInvoices");
$productcust=$langs->trans("Description");
$namerate=$langs->trans("VATRate");
$amountcust=$langs->trans("AmountHT");
$elementcust = $langs->trans("CustomersInvoices");
$productcust = $langs->trans("Description");
$namerate = $langs->trans("VATRate");
$amountcust = $langs->trans("AmountHT");
if ($mysoc->tva_assuj) {
$vatcust.=' ('.$langs->trans("StatusToPay").')';
$vatcust .= ' ('.$langs->trans("StatusToPay").')';
}
$elementsup=$langs->trans("SuppliersInvoices");
$productsup=$langs->trans("Description");
$amountsup=$langs->trans("AmountHT");
$elementsup = $langs->trans("SuppliersInvoices");
$productsup = $langs->trans("Description");
$amountsup = $langs->trans("AmountHT");
if ($mysoc->tva_assuj) {
$vatsup.=' ('.$langs->trans("ToGetBack").')';
$vatsup .= ' ('.$langs->trans("ToGetBack").')';
}
report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
$vatcust=$langs->trans("VATReceived");
$vatsup=$langs->trans("VATPaid");
$vatcust = $langs->trans("VATReceived");
$vatsup = $langs->trans("VATPaid");
// VAT Received
@ -205,38 +205,38 @@ print "<table class=\"noborder\" width=\"100%\">";
$y = $year_current;
$total = 0;
$i=0;
$i = 0;
$columns = 5;
// Load arrays of datas
$x_coll = tax_by_thirdparty('vat', $db, 0, $date_start, $date_end, $modetax, 'sell');
$x_paye = tax_by_thirdparty('vat', $db, 0, $date_start, $date_end, $modetax, 'buy');
if (! is_array($x_coll) || ! is_array($x_paye))
if (!is_array($x_coll) || !is_array($x_paye))
{
$langs->load("errors");
if ($x_coll == -1) {
print '<tr><td colspan="' . $columns . '">' . $langs->trans("ErrorNoAccountancyModuleLoaded") . '</td></tr>';
print '<tr><td colspan="'.$columns.'">'.$langs->trans("ErrorNoAccountancyModuleLoaded").'</td></tr>';
} elseif ($x_coll == -2) {
print '<tr><td colspan="' . $columns . '">' . $langs->trans("FeatureNotYetAvailable") . '</td></tr>';
print '<tr><td colspan="'.$columns.'">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
} else {
print '<tr><td colspan="' . $columns . '">' . $langs->trans("Error") . '</td></tr>';
print '<tr><td colspan="'.$columns.'">'.$langs->trans("Error").'</td></tr>';
}
} else {
$x_both = array();
//now, from these two arrays, get another array with one rate per line
foreach(array_keys($x_coll) as $my_coll_thirdpartyid)
foreach (array_keys($x_coll) as $my_coll_thirdpartyid)
{
$x_both[$my_coll_thirdpartyid]['coll']['totalht'] = $x_coll[$my_coll_thirdpartyid]['totalht'];
$x_both[$my_coll_thirdpartyid]['coll']['vat'] = $x_coll[$my_coll_thirdpartyid]['vat'];
$x_both[$my_coll_thirdpartyid]['coll']['vat'] = $x_coll[$my_coll_thirdpartyid]['vat'];
$x_both[$my_coll_thirdpartyid]['paye']['totalht'] = 0;
$x_both[$my_coll_thirdpartyid]['paye']['vat'] = 0;
$x_both[$my_coll_thirdpartyid]['coll']['links'] = '';
$x_both[$my_coll_thirdpartyid]['coll']['detail'] = array();
foreach($x_coll[$my_coll_thirdpartyid]['facid'] as $id=>$dummy) {
$invoice_customer->id=$x_coll[$my_coll_thirdpartyid]['facid'][$id];
$invoice_customer->ref=$x_coll[$my_coll_thirdpartyid]['facnum'][$id];
$invoice_customer->type=$x_coll[$my_coll_thirdpartyid]['type'][$id];
foreach ($x_coll[$my_coll_thirdpartyid]['facid'] as $id=>$dummy) {
$invoice_customer->id = $x_coll[$my_coll_thirdpartyid]['facid'][$id];
$invoice_customer->ref = $x_coll[$my_coll_thirdpartyid]['facnum'][$id];
$invoice_customer->type = $x_coll[$my_coll_thirdpartyid]['type'][$id];
$company_static->fetch($x_coll[$my_coll_thirdpartyid]['company_id'][$id]);
$x_both[$my_coll_thirdpartyid]['coll']['detail'][] = array(
'id' =>$x_coll[$my_coll_thirdpartyid]['facid'][$id],
@ -277,9 +277,9 @@ if (! is_array($x_coll) || ! is_array($x_paye))
// ExpenseReport
if ($x_paye[$my_paye_thirdpartyid]['ptype'][$id] == 'ExpenseReportPayment')
{
$expensereport->id=$x_paye[$my_paye_thirdpartyid]['facid'][$id];
$expensereport->ref=$x_paye[$my_paye_thirdpartyid]['facnum'][$id];
$expensereport->type=$x_paye[$my_paye_thirdpartyid]['type'][$id];
$expensereport->id = $x_paye[$my_paye_thirdpartyid]['facid'][$id];
$expensereport->ref = $x_paye[$my_paye_thirdpartyid]['facnum'][$id];
$expensereport->type = $x_paye[$my_paye_thirdpartyid]['type'][$id];
$x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array(
'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id],
@ -302,9 +302,9 @@ if (! is_array($x_coll) || ! is_array($x_paye))
}
else
{
$invoice_supplier->id=$x_paye[$my_paye_thirdpartyid]['facid'][$id];
$invoice_supplier->ref=$x_paye[$my_paye_thirdpartyid]['facnum'][$id];
$invoice_supplier->type=$x_paye[$my_paye_thirdpartyid]['type'][$id];
$invoice_supplier->id = $x_paye[$my_paye_thirdpartyid]['facid'][$id];
$invoice_supplier->ref = $x_paye[$my_paye_thirdpartyid]['facnum'][$id];
$invoice_supplier->type = $x_paye[$my_paye_thirdpartyid]['type'][$id];
$company_static->fetch($x_paye[$my_paye_thirdpartyid]['company_id'][$id]);
$x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array(
'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id],
@ -340,8 +340,8 @@ if (! is_array($x_coll) || ! is_array($x_paye))
$x_paye_sum = 0;
$x_paye_ht = 0;
$span=$columns;
if ($modetax != 1) $span+=2;
$span = $columns;
if ($modetax != 1) $span += 2;
//print '<tr><td colspan="'.($span+1).'">'..')</td></tr>';
@ -371,7 +371,7 @@ if (! is_array($x_coll) || ! is_array($x_paye))
$object = array(&$x_coll, &$x_paye, &$x_both);
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('externalbalance'));
$reshook=$hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
foreach (array_keys($x_coll) as $thirdparty_id) {
$subtot_coll_total_ht = 0;
@ -386,14 +386,14 @@ if (! is_array($x_coll) || ! is_array($x_paye))
print '<td class="tax_rate">';
if (is_numeric($thirdparty_id)) {
$company_static->fetch($thirdparty_id);
print $langs->trans("ThirdParty") . ': ' . $company_static->getNomUrl(1);
print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1);
} else {
$tmpid = preg_replace('/userid_/', '', $thirdparty_id);
$user_static->fetch($tmpid);
print $langs->trans("User") . ': ' . $user_static->getNomUrl(1);
print $langs->trans("User").': '.$user_static->getNomUrl(1);
}
print '</td><td colspan="' . ($span + 1) . '"></td>';
print '</tr>' . "\n";
print '</td><td colspan="'.($span + 1).'"></td>';
print '</tr>'."\n";
foreach ($x_both[$thirdparty_id]['coll']['detail'] as $index => $fields) {
// Define type
@ -411,30 +411,30 @@ if (! is_array($x_coll) || ! is_array($x_paye))
print '<tr class="oddeven">';
// Ref
print '<td class="nowrap left">' . $fields['link'] . '</td>';
print '<td class="nowrap left">'.$fields['link'].'</td>';
// Invoice date
print '<td class="left">' . dol_print_date($fields['datef'], 'day') . '</td>';
print '<td class="left">'.dol_print_date($fields['datef'], 'day').'</td>';
// Payment date
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') {
print '<td class="left">' . dol_print_date($fields['datep'], 'day') . '</td>';
print '<td class="left">'.dol_print_date($fields['datep'], 'day').'</td>';
} else {
print '<td></td>';
}
// Rate
print '<td class="right">' . $fields['drate'] . '</td>';
print '<td class="right">'.$fields['drate'].'</td>';
// Description
print '<td class="left">';
if ($fields['pid']) {
$product_static->id = $fields['pid'];
$product_static->ref = $fields['pref'];
$product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered
$product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered
print $product_static->getNomUrl(1);
if (dol_string_nohtmltag($fields['descr'])) {
print ' - ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 24);
print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24);
}
} else {
if ($type) {
@ -451,7 +451,7 @@ if (! is_array($x_coll) || ! is_array($x_paye))
$fields['descr'] = $langs->transnoentitiesnoconv($reg[1]);
}
}
print $text . ' ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 24);
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24);
// Show range
print_date_range($fields['ddate_start'], $fields['ddate_end']);
@ -488,7 +488,7 @@ if (! is_array($x_coll) || ! is_array($x_paye))
}
print price(price2num($fields['payment_amount'], 'MT'));
if (isset($fields['payment_amount'])) {
print ' (' . round($ratiopaymentinvoice * 100, 2) . '%)';
print ' ('.round($ratiopaymentinvoice * 100, 2).'%)';
}
}
print '</td>';
@ -516,13 +516,13 @@ if (! is_array($x_coll) || ! is_array($x_paye))
// Total customers for this vat rate
print '<tr class="liste_total">';
print '<td colspan="4"></td>';
print '<td class="right">' . $langs->trans("Total") . ':</td>';
print '<td class="right">'.$langs->trans("Total").':</td>';
if ($modetax != 1) {
print '<td class="nowrap right">&nbsp;</td>';
print '<td class="right">&nbsp;</td>';
}
print '<td class="right">' . price(price2num($subtot_coll_total_ht, 'MT')) . '</td>';
print '<td class="nowrap right">' . price(price2num($subtot_coll_vat, 'MT')) . '</td>';
print '<td class="right">'.price(price2num($subtot_coll_total_ht, 'MT')).'</td>';
print '<td class="nowrap right">'.price(price2num($subtot_coll_vat, 'MT')).'</td>';
print '</tr>';
}
}
@ -542,7 +542,7 @@ if (! is_array($x_coll) || ! is_array($x_paye))
}
// Blank line
print '<tr><td colspan="'.($span+1).'">&nbsp;</td></tr>';
print '<tr><td colspan="'.($span + 1).'">&nbsp;</td></tr>';
// Print table headers for this quadri - expenses now
print '<tr class="liste_titre liste_titre_topborder">';
@ -571,14 +571,14 @@ if (! is_array($x_coll) || ! is_array($x_paye))
print '<td class="tax_rate">';
if (is_numeric($thirdparty_id)) {
$company_static->fetch($thirdparty_id);
print $langs->trans("ThirdParty") . ': ' . $company_static->getNomUrl(1);
print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1);
} else {
$tmpid = preg_replace('/userid_/', '', $thirdparty_id);
$user_static->fetch($tmpid);
print $langs->trans("User") . ': ' . $user_static->getNomUrl(1);
print $langs->trans("User").': '.$user_static->getNomUrl(1);
}
print '<td colspan="' . ($span + 1) . '"></td>';
print '</tr>' . "\n";
print '<td colspan="'.($span + 1).'"></td>';
print '</tr>'."\n";
foreach ($x_both[$thirdparty_id]['paye']['detail'] as $index => $fields) {
// Define type
@ -597,30 +597,30 @@ if (! is_array($x_coll) || ! is_array($x_paye))
print '<tr class="oddeven">';
// Ref
print '<td class="nowrap left">' . $fields['link'] . '</td>';
print '<td class="nowrap left">'.$fields['link'].'</td>';
// Invoice date
print '<td class="left">' . dol_print_date($fields['datef'], 'day') . '</td>';
print '<td class="left">'.dol_print_date($fields['datef'], 'day').'</td>';
// Payment date
if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') {
print '<td class="left">' . dol_print_date($fields['datep'], 'day') . '</td>';
print '<td class="left">'.dol_print_date($fields['datep'], 'day').'</td>';
} else {
print '<td></td>';
}
// Company name
print '<td class="left">' . $fields['company_link'] . '</td>';
print '<td class="left">'.$fields['company_link'].'</td>';
// Description
print '<td class="left">';
if ($fields['pid']) {
$product_static->id = $fields['pid'];
$product_static->ref = $fields['pref'];
$product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered
$product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered
print $product_static->getNomUrl(1);
if (dol_string_nohtmltag($fields['descr'])) {
print ' - ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 24);
print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24);
}
} else {
if ($type) {
@ -637,7 +637,7 @@ if (! is_array($x_coll) || ! is_array($x_paye))
$fields['descr'] = $langs->transnoentitiesnoconv($reg[1]);
}
}
print $text . ' ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 24);
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24);
// Show range
print_date_range($fields['ddate_start'], $fields['ddate_end']);
@ -679,7 +679,7 @@ if (! is_array($x_coll) || ! is_array($x_paye))
}
print price(price2num($fields['payment_amount'], 'MT'));
if (isset($fields['payment_amount'])) {
print ' (' . round($ratiopaymentinvoice * 100, 2) . '%)';
print ' ('.round($ratiopaymentinvoice * 100, 2).'%)';
}
}
print '</td>';
@ -707,13 +707,13 @@ if (! is_array($x_coll) || ! is_array($x_paye))
// Total suppliers for this vat rate
print '<tr class="liste_total">';
print '<td colspan="4"></td>';
print '<td class="right">' . $langs->trans("Total") . ':</td>';
print '<td class="right">'.$langs->trans("Total").':</td>';
if ($modetax != 1) {
print '<td class="nowrap right">&nbsp;</td>';
print '<td class="right">&nbsp;</td>';
}
print '<td class="right">' . price(price2num($subtot_paye_total_ht, 'MT')) . '</td>';
print '<td class="nowrap right">' . price(price2num($subtot_paye_vat, 'MT')) . '</td>';
print '<td class="right">'.price(price2num($subtot_paye_total_ht, 'MT')).'</td>';
print '<td class="nowrap right">'.price(price2num($subtot_paye_vat, 'MT')).'</td>';
print '</tr>';
}
}
@ -738,7 +738,7 @@ if (! is_array($x_coll) || ! is_array($x_paye))
print '<table class="noborder centpercent">';
$diff = $x_coll_sum - $x_paye_sum;
print '<tr class="liste_total">';
print '<td class="liste_total" colspan="'.$span.'">'.$langs->trans("TotalToPay").($q?', '.$langs->trans("Quadri").' '.$q:'').'</td>';
print '<td class="liste_total" colspan="'.$span.'">'.$langs->trans("TotalToPay").($q ? ', '.$langs->trans("Quadri").' '.$q : '').'</td>';
print '<td class="liste_total nowrap right"><b>'.price(price2num($diff, 'MT'))."</b></td>\n";
print "</tr>\n";

View File

@ -33,10 +33,10 @@ require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php';
// Load translation files required by the page
$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin"));
$langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin"));
// Date range
$year=GETPOST("year", "int");
$year = GETPOST("year", "int");
if (empty($year))
{
$year_current = strftime("%Y", dol_now());
@ -45,38 +45,38 @@ if (empty($year))
$year_current = $year;
$year_start = $year;
}
$date_start=dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"));
$date_end=dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"));
$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"));
$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"));
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
$q=GETPOST("q", "int");
$q = GETPOST("q", "int");
if (empty($q))
{
if (GETPOST("month", "int")) { $date_start=dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end=dol_get_last_day($year_start, GETPOST("month", "int"), false); }
if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); }
else
{
$date_start=dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START, false);
$date_end=dol_time_plus_duree($date_start, 1, 'y') - 1;
$date_start = dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START, false);
$date_end = dol_time_plus_duree($date_start, 1, 'y') - 1;
}
}
else
{
if ($q==1) { $date_start=dol_get_first_day($year_start, 1, false); $date_end=dol_get_last_day($year_start, 3, false); }
if ($q==2) { $date_start=dol_get_first_day($year_start, 4, false); $date_end=dol_get_last_day($year_start, 6, false); }
if ($q==3) { $date_start=dol_get_first_day($year_start, 7, false); $date_end=dol_get_last_day($year_start, 9, false); }
if ($q==4) { $date_start=dol_get_first_day($year_start, 10, false); $date_end=dol_get_last_day($year_start, 12, false); }
if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); }
if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); }
if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); }
if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); }
}
}
// Define modetax (0 or 1)
// 0=normal, 1=option vat for services is on debit, 2=option on payments for products
$modetax = $conf->global->TAX_MODE;
if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax", 'int');
if (empty($modetax)) $modetax=0;
if (GETPOSTISSET("modetax")) $modetax = GETPOST("modetax", 'int');
if (empty($modetax)) $modetax = 0;
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) $socid=$user->socid;
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'tax', '', '', 'charges');
@ -90,7 +90,7 @@ $result = restrictedArea($user, 'tax', '', '', 'charges');
*/
function pt($db, $sql, $date)
{
global $conf, $bc,$langs;
global $conf, $bc, $langs;
$result = $db->query($sql);
if ($result) {
@ -118,7 +118,7 @@ function pt($db, $sql, $date)
$mode = $obj->mode;
//print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode;
if ($obj->mode == 'claimed' && ! empty($previousmode))
if ($obj->mode == 'claimed' && !empty($previousmode))
{
print '<tr class="oddeven">';
print '<td class="nowrap">'.$previousmonth."</td>\n";
@ -162,7 +162,7 @@ function pt($db, $sql, $date)
$i++;
}
if ($mode == 'claimed' && ! empty($previousmode))
if ($mode == 'claimed' && !empty($previousmode))
{
print '<tr class="oddeven">';
print '<td class="nowrap">'.$previousmonth."</td>\n";
@ -194,37 +194,37 @@ function pt($db, $sql, $date)
* View
*/
$form=new Form($db);
$company_static=new Societe($db);
$form = new Form($db);
$company_static = new Societe($db);
$tva = new Tva($db);
$fsearch ='<!-- hidden fields for form -->';
$fsearch.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$fsearch.='<input type="hidden" name="modetax" value="'.$modetax.'">';
$fsearch = '<!-- hidden fields for form -->';
$fsearch .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$fsearch .= '<input type="hidden" name="modetax" value="'.$modetax.'">';
$description = $fsearch;
// Show report header
$name = $langs->trans("ReportByMonth");
$calcmode='';
if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault');
if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption');
if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices');
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')';
$calcmode = '';
if ($modetax == 0) $calcmode = $langs->trans('OptionVATDefault');
if ($modetax == 1) $calcmode = $langs->trans('OptionVATDebitOption');
if ($modetax == 2) $calcmode = $langs->trans('OptionPaymentForProductAndServices');
$calcmode .= '<br>('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')';
$description .= $langs->trans("VATSummary").'<br>';
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description.=$langs->trans("RulesVATDueProducts");
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description.=$langs->trans("RulesVATInProducts");
if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description.='<br>'.$langs->trans("RulesVATDueServices");
if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description.='<br>'.$langs->trans("RulesVATInServices");
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description.='<br>'.$langs->trans("DepositsAreNotIncluded");
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description .= $langs->trans("RulesVATDueProducts");
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description .= $langs->trans("RulesVATInProducts");
if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description .= '<br>'.$langs->trans("RulesVATDueServices");
if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description .= '<br>'.$langs->trans("RulesVATInServices");
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description .= '<br>'.$langs->trans("DepositsAreNotIncluded");
}
if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='<br>'.$langs->trans("ThisIsAnEstimatedValue");
if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description .= '<br>'.$langs->trans("ThisIsAnEstimatedValue");
$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$builddate=dol_now();
$builddate = dol_now();
llxHeader('', $name);
@ -252,15 +252,15 @@ print '<td class="right">'.$langs->trans("Balance").'</td>';
print '<td>&nbsp;</td>'."\n";
print '</tr>'."\n";
$tmp=dol_getdate($date_start);
$tmp = dol_getdate($date_start);
$y = $tmp['year'];
$m = $tmp['mon'];
$tmp=dol_getdate($date_end);
$tmp = dol_getdate($date_end);
$yend = $tmp['year'];
$mend = $tmp['mon'];
//var_dump($m);
$total=0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0;
$i=0; $mcursor=0;
$total = 0; $subtotalcoll = 0; $subtotalpaye = 0; $subtotal = 0;
$i = 0; $mcursor = 0;
while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mcursor is to avoid too large loop
{
@ -274,15 +274,15 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc
$x_both = array();
//now, from these two arrays, get another array with one rate per line
foreach(array_keys($x_coll) as $my_coll_rate)
foreach (array_keys($x_coll) as $my_coll_rate)
{
$x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht'];
$x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat'];
$x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat'];
$x_both[$my_coll_rate]['paye']['totalht'] = 0;
$x_both[$my_coll_rate]['paye']['vat'] = 0;
$x_both[$my_coll_rate]['coll']['links'] = '';
$x_both[$my_coll_rate]['coll']['detail'] = array();
foreach($x_coll[$my_coll_rate]['facid'] as $id=>$dummy) {
foreach ($x_coll[$my_coll_rate]['facid'] as $id=>$dummy) {
//$invoice_customer->id=$x_coll[$my_coll_rate]['facid'][$id];
//$invoice_customer->ref=$x_coll[$my_coll_rate]['facnum'][$id];
//$invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id];
@ -388,15 +388,15 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('externalbalance'));
$reshook=$hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if (! is_array($x_coll) && $coll_listbuy == -1)
if (!is_array($x_coll) && $coll_listbuy == -1)
{
$langs->load("errors");
print '<tr><td colspan="5">'.$langs->trans("ErrorNoAccountancyModuleLoaded").'</td></tr>';
break;
}
if (! is_array($x_paye) && $coll_listbuy == -2)
if (!is_array($x_paye) && $coll_listbuy == -2)
{
print '<tr><td colspan="5">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
break;
@ -415,19 +415,19 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc
foreach ($x_both[$rate]['coll']['detail'] as $index => $fields)
{
// Payment
$ratiopaymentinvoice=1;
$ratiopaymentinvoice = 1;
if ($modetax != 1)
{
// Define type
// We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
$type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']);
$type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']);
// Try to enhance type detection using date_start and date_end for free lines where type
// was not saved.
if (!empty($fields['ddate_start'])) {
$type=1;
$type = 1;
}
if (!empty($fields['ddate_end'])) {
$type=1;
$type = 1;
}
if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice')
@ -436,13 +436,13 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc
//print $langs->trans("NA");
} else {
if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) {
$ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
$ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']);
}
}
}
//var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice);
$temp_ht=$fields['totalht']*$ratiopaymentinvoice;
$temp_vat=$fields['vat']*$ratiopaymentinvoice;
$temp_ht = $fields['totalht'] * $ratiopaymentinvoice;
$temp_vat = $fields['vat'] * $ratiopaymentinvoice;
$subtot_coll_total_ht += $temp_ht;
$subtot_coll_vat += $temp_vat;
$x_coll_sum += $temp_vat;
@ -459,19 +459,19 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc
foreach ($x_both[$rate]['paye']['detail'] as $index => $fields)
{
// Payment
$ratiopaymentinvoice=1;
$ratiopaymentinvoice = 1;
if ($modetax != 1)
{
// Define type
// We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
$type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']);
$type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']);
// Try to enhance type detection using date_start and date_end for free lines where type
// was not saved.
if (!empty($fields['ddate_start'])) {
$type=1;
$type = 1;
}
if (!empty($fields['ddate_end'])) {
$type=1;
$type = 1;
}
if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice')
@ -480,13 +480,13 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc
//print $langs->trans("NA");
} else {
if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) {
$ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
$ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']);
}
}
}
//var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice);
$temp_ht=$fields['totalht']*$ratiopaymentinvoice;
$temp_vat=$fields['vat']*$ratiopaymentinvoice;
$temp_ht = $fields['totalht'] * $ratiopaymentinvoice;
$temp_vat = $fields['vat'] * $ratiopaymentinvoice;
$subtot_paye_total_ht += $temp_ht;
$subtot_paye_vat += $temp_vat;
$x_paye_sum += $temp_vat;
@ -509,13 +509,13 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc
if ($i > 2)
{
print '<tr class="liste_total">';
print '<td class="right"><a href="quadri_detail.php?leftmenu=tax_vat&q='.round($m/3).'&year='.$y.'">'.$langs->trans("SubTotal").'</a>:</td>';
print '<td class="right"><a href="quadri_detail.php?leftmenu=tax_vat&q='.round($m / 3).'&year='.$y.'">'.$langs->trans("SubTotal").'</a>:</td>';
print '<td class="nowrap right">'.price(price2num($subtotalcoll, 'MT')).'</td>';
print '<td class="nowrap right">'.price(price2num($subtotalpaye, 'MT')).'</td>';
print '<td class="nowrap right">'.price(price2num($subtotal, 'MT')).'</td>';
print '<td>&nbsp;</td></tr>';
$i = 0;
$subtotalcoll=0; $subtotalpaye=0; $subtotal=0;
$subtotalcoll = 0; $subtotalpaye = 0; $subtotal = 0;
}
}
print '<tr class="liste_total"><td class="right" colspan="3">'.$langs->trans("TotalToPay").':</td><td class="nowrap right">'.price(price2num($total, 'MT')).'</td>';
@ -535,29 +535,29 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
print load_fiche_titre($langs->trans("VATPaid"), '', '');
$sql='';
$sql = '';
$sql.= "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm, 'claimed' as mode";
$sql.= " FROM ".MAIN_DB_PREFIX."tva as f";
$sql.= " WHERE f.entity = ".$conf->entity;
$sql.= " AND (f.datev >= '".$db->idate($date_start)."' AND f.datev <= '".$db->idate($date_end)."')";
$sql.= " GROUP BY dm";
$sql .= "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm, 'claimed' as mode";
$sql .= " FROM ".MAIN_DB_PREFIX."tva as f";
$sql .= " WHERE f.entity = ".$conf->entity;
$sql .= " AND (f.datev >= '".$db->idate($date_start)."' AND f.datev <= '".$db->idate($date_end)."')";
$sql .= " GROUP BY dm";
$sql.= " UNION ";
$sql .= " UNION ";
$sql.= "SELECT SUM(amount) as mm, date_format(f.datep,'%Y-%m') as dm, 'paid' as mode";
$sql.= " FROM ".MAIN_DB_PREFIX."tva as f";
$sql.= " WHERE f.entity = ".$conf->entity;
$sql.= " AND (f.datep >= '".$db->idate($date_start)."' AND f.datep <= '".$db->idate($date_end)."')";
$sql.= " GROUP BY dm";
$sql .= "SELECT SUM(amount) as mm, date_format(f.datep,'%Y-%m') as dm, 'paid' as mode";
$sql .= " FROM ".MAIN_DB_PREFIX."tva as f";
$sql .= " WHERE f.entity = ".$conf->entity;
$sql .= " AND (f.datep >= '".$db->idate($date_start)."' AND f.datep <= '".$db->idate($date_end)."')";
$sql .= " GROUP BY dm";
$sql.= " ORDER BY dm ASC, mode ASC";
$sql .= " ORDER BY dm ASC, mode ASC";
//print $sql;
pt($db, $sql, $langs->trans("Month"));
if (! empty($conf->global->MAIN_FEATURES_LEVEL))
if (!empty($conf->global->MAIN_FEATURES_LEVEL))
{
print '<br>';
@ -568,10 +568,10 @@ if (! empty($conf->global->MAIN_FEATURES_LEVEL))
print load_fiche_titre($langs->trans("VATBalance"), '', ''); // need to add translation
$sql1 = "SELECT SUM(amount) as mm";
$sql1 .= " FROM " . MAIN_DB_PREFIX . "tva as f";
$sql1 .= " WHERE f.entity = " . $conf->entity;
$sql1 .= " AND f.datev >= '" . $db->idate($date_start) . "'";
$sql1 .= " AND f.datev <= '" . $db->idate($date_end) . "'";
$sql1 .= " FROM ".MAIN_DB_PREFIX."tva as f";
$sql1 .= " WHERE f.entity = ".$conf->entity;
$sql1 .= " AND f.datev >= '".$db->idate($date_start)."'";
$sql1 .= " AND f.datev <= '".$db->idate($date_end)."'";
$result = $db->query($sql1);
if ($result) {
@ -579,19 +579,19 @@ if (! empty($conf->global->MAIN_FEATURES_LEVEL))
print '<table class="noborder centpercent">';
print "<tr>";
print '<td class="right">' . $langs->trans("VATDue") . '</td>';
print '<td class="nowrap right">' . price(price2num($total, 'MT')) . '</td>';
print '<td class="right">'.$langs->trans("VATDue").'</td>';
print '<td class="nowrap right">'.price(price2num($total, 'MT')).'</td>';
print "</tr>\n";
print "<tr>";
print '<td class="right">' . $langs->trans("VATPaid") . '</td>';
print '<td class="nowrap right">' . price(price2num($obj->mm, 'MT')) . "</td>\n";
print '<td class="right">'.$langs->trans("VATPaid").'</td>';
print '<td class="nowrap right">'.price(price2num($obj->mm, 'MT'))."</td>\n";
print "</tr>\n";
$restopay = $total - $obj->mm;
print "<tr>";
print '<td class="right">' . $langs->trans("RemainToPay") . '</td>';
print '<td class="nowrap right">' . price(price2num($restopay, 'MT')) . '</td>';
print '<td class="right">'.$langs->trans("RemainToPay").'</td>';
print '<td class="nowrap right">'.price(price2num($restopay, 'MT')).'</td>';
print "</tr>\n";
print '</table>';

View File

@ -36,7 +36,7 @@ $langs->loadLangs(array('compta', 'bills'));
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) $socid=$user->socid;
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'tax', '', '', 'charges');
$search_ref = GETPOST('search_ref', 'int');
@ -50,7 +50,7 @@ $search_amount = GETPOST('search_amount', 'alpha');
$month = GETPOST("month", "int");
$year = GETPOST("year", "int");
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int');
@ -58,39 +58,39 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) $sortfield="t.datev";
if (! $sortorder) $sortorder="DESC";
if (!$sortfield) $sortfield = "t.datev";
if (!$sortorder) $sortorder = "DESC";
$filtre=$_GET["filtre"];
$filtre = $_GET["filtre"];
if (empty($_REQUEST['typeid']))
{
$newfiltre=str_replace('filtre=', '', $filtre);
$filterarray=explode('-', $newfiltre);
foreach($filterarray as $val)
$newfiltre = str_replace('filtre=', '', $filtre);
$filterarray = explode('-', $newfiltre);
foreach ($filterarray as $val)
{
$part=explode(':', $val);
if ($part[0] == 't.fk_typepayment') $typeid=$part[1];
$part = explode(':', $val);
if ($part[0] == 't.fk_typepayment') $typeid = $part[1];
}
}
else
{
$typeid=$_REQUEST['typeid'];
$typeid = $_REQUEST['typeid'];
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers
{
$search_ref="";
$search_label="";
$search_dateend_start='';
$search_dateend_end='';
$search_datepayment_start='';
$search_datepayment_end='';
$search_account='';
$search_amount="";
$year="";
$month="";
$typeid="";
$search_ref = "";
$search_label = "";
$search_dateend_start = '';
$search_dateend_end = '';
$search_datepayment_start = '';
$search_datepayment_end = '';
$search_account = '';
$search_amount = "";
$year = "";
$month = "";
$typeid = "";
}
@ -101,57 +101,57 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
llxHeader('', $langs->trans("VATPayments"));
$form = new Form($db);
$formother=new FormOther($db);
$formother = new FormOther($db);
$tva_static = new Tva($db);
$bankstatic = new Account($db);
$sql = "SELECT t.rowid, t.amount, t.label, t.datev, t.datep, t.fk_typepayment as type, t.num_payment, t.fk_bank, pst.code as payment_code,";
$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
$sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON t.fk_typepayment = pst.id";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
$sql.= " WHERE t.entity IN (".getEntity('tax').")";
if ($search_ref) $sql.= natural_search("t.rowid", $search_ref);
if ($search_label) $sql.= natural_search("t.label", $search_label);
if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account;
if ($search_amount) $sql.= natural_search("t.amount", price2num(trim($search_amount)), 1);
if ($search_dateend_start) $sql.= " AND t.datev >= '" . $db->idate($search_dateend_start) . "'";
if ($search_dateend_end) $sql.= " AND t.datev <= '" . $db->idate($search_dateend_end) . "'";
if ($search_datepayment_start) $sql.= " AND t.datep >= '" . $db->idate($search_datepayment_start) . "'";
if ($search_datepayment_end) $sql.= " AND t.datep <= '" . $db->idate($search_datepayment_end) . "'";
$sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
$sql .= " FROM ".MAIN_DB_PREFIX."tva as t";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON t.fk_typepayment = pst.id";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
$sql .= " WHERE t.entity IN (".getEntity('tax').")";
if ($search_ref) $sql .= natural_search("t.rowid", $search_ref);
if ($search_label) $sql .= natural_search("t.label", $search_label);
if ($search_account > 0) $sql .= " AND b.fk_account=".$search_account;
if ($search_amount) $sql .= natural_search("t.amount", price2num(trim($search_amount)), 1);
if ($search_dateend_start) $sql .= " AND t.datev >= '".$db->idate($search_dateend_start)."'";
if ($search_dateend_end) $sql .= " AND t.datev <= '".$db->idate($search_dateend_end)."'";
if ($search_datepayment_start) $sql .= " AND t.datep >= '".$db->idate($search_datepayment_start)."'";
if ($search_datepayment_end) $sql .= " AND t.datep <= '".$db->idate($search_datepayment_end)."'";
if ($filtre) {
$filtre=str_replace(":", "=", $filtre);
$filtre = str_replace(":", "=", $filtre);
$sql .= " AND ".$filtre;
}
if ($typeid) {
$sql .= " AND t.fk_typepayment=".$typeid;
}
$sql.= $db->order($sortfield, $sortorder);
$totalnboflines=0;
$result=$db->query($sql);
$sql .= $db->order($sortfield, $sortorder);
$totalnboflines = 0;
$result = $db->query($sql);
if ($result)
{
$totalnboflines = $db->num_rows($result);
}
$sql.= $db->plimit($limit+1, $offset);
$sql .= $db->plimit($limit + 1, $offset);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
$total = 0 ;
$total = 0;
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($typeid) $param.='&amp;typeid='.$typeid;
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
if ($typeid) $param .= '&amp;typeid='.$typeid;
$newcardbutton='';
$newcardbutton = '';
if ($user->rights->tax->charges->creer)
{
$newcardbutton.= dolGetButtonTitle($langs->trans('NewVATPayment', ($ltt+1)), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/tva/card.php?action=create');
$newcardbutton .= dolGetButtonTitle($langs->trans('NewVATPayment', ($ltt + 1)), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/tva/card.php?action=create');
}
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
@ -165,7 +165,7 @@ if ($result)
print_barre_liste($langs->trans("VATPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy', 0, $newcardbutton, '', $limit);
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
print '<tr class="liste_titre_filter">';
// Ref
@ -175,29 +175,29 @@ if ($result)
// Date end period
print '<td class="liste_titre center">';
print '<div class="nowrap">';
print $langs->trans('From') . ' ';
print $form->selectDate($search_dateend_start?$search_dateend_start:-1, 'search_dateend_start', 0, 0, 1);
print $langs->trans('From').' ';
print $form->selectDate($search_dateend_start ? $search_dateend_start : -1, 'search_dateend_start', 0, 0, 1);
print '</div>';
print '<div class="nowrap">';
print $langs->trans('to') . ' ';
print $form->selectDate($search_dateend_end?$search_dateend_end:-1, 'search_dateend_end', 0, 0, 1);
print $langs->trans('to').' ';
print $form->selectDate($search_dateend_end ? $search_dateend_end : -1, 'search_dateend_end', 0, 0, 1);
print '</div>';
// Date payment
print '<td class="liste_titre center">';
print '<div class="nowrap">';
print $langs->trans('From') . ' ';
print $form->selectDate($search_datepayment_start?$search_datepayment_start:-1, 'search_datepayment_start', 0, 0, 1);
print $langs->trans('From').' ';
print $form->selectDate($search_datepayment_start ? $search_datepayment_start : -1, 'search_datepayment_start', 0, 0, 1);
print '</div>';
print '<div class="nowrap">';
print $langs->trans('to') . ' ';
print $form->selectDate($search_datepayment_end?$search_datepayment_end:-1, 'search_datepayment_end', 0, 0, 1);
print $langs->trans('to').' ';
print $form->selectDate($search_datepayment_end ? $search_datepayment_end : -1, 'search_datepayment_end', 0, 0, 1);
print '</div>';
// Type
print '<td class="liste_titre left">';
$form->select_types_paiements($typeid, 'typeid', '', 0, 1, 1, 16);
print '</td>';
// Account
if (! empty($conf->banque->enabled))
if (!empty($conf->banque->enabled))
{
print '<td class="liste_titre">';
$form->select_comptes($search_account, 'search_account', 0, '', 1);
@ -206,7 +206,7 @@ if ($result)
// Amount
print '<td class="liste_titre right"><input name="search_amount" class="flat" type="text" size="8" value="'.$search_amount.'"></td>';
print '<td class="liste_titre maxwidthsearch">';
$searchpicto=$form->showFilterAndCheckAddButtons(0);
$searchpicto = $form->showFilterAndCheckAddButtons(0);
print $searchpicto;
print '</td>';
print "</tr>\n";
@ -217,7 +217,7 @@ if ($result)
print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "t.datev", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "t.datep", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'left ');
if (! empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
if (!empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "t.amount", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
print "</tr>\n";
@ -237,8 +237,8 @@ if ($result)
print '<tr class="oddeven">';
$tva_static->id=$obj->rowid;
$tva_static->ref=$obj->rowid;
$tva_static->id = $obj->rowid;
$tva_static->ref = $obj->rowid;
// Ref
print "<td>".$tva_static->getNomUrl(1)."</td>\n";
@ -251,21 +251,21 @@ if ($result)
// Type
print $type;
// Account
if (! empty($conf->banque->enabled))
if (!empty($conf->banque->enabled))
{
print '<td>';
if ($obj->fk_bank > 0)
{
$bankstatic->id=$obj->bid;
$bankstatic->ref=$obj->bref;
$bankstatic->number=$obj->bnumber;
$bankstatic->account_number=$obj->account_number;
$bankstatic->id = $obj->bid;
$bankstatic->ref = $obj->bref;
$bankstatic->number = $obj->bnumber;
$bankstatic->account_number = $obj->account_number;
$accountingjournal = new AccountingJournal($db);
$accountingjournal->fetch($obj->fk_accountancy_journal);
$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
$bankstatic->label=$obj->blabel;
$bankstatic->label = $obj->blabel;
print $bankstatic->getNomUrl(1);
}
else print '&nbsp;';
@ -280,8 +280,8 @@ if ($result)
$i++;
}
$colspan=5;
if (! empty($conf->banque->enabled)) $colspan++;
$colspan = 5;
if (!empty($conf->banque->enabled)) $colspan++;
print '<tr class="liste_total"><td colspan="'.$colspan.'">'.$langs->trans("Total").'</td>';
print '<td class="right">'.price($total).'</td>';
print "<td>&nbsp;</td></tr>";

View File

@ -42,10 +42,10 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php';
// Load translation files required by the page
$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin"));
$langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin"));
// Date range
$year=GETPOST("year", "int");
$year = GETPOST("year", "int");
if (empty($year))
{
$year_current = strftime("%Y", dol_now());
@ -54,29 +54,29 @@ if (empty($year))
$year_current = $year;
$year_start = $year;
}
$date_start=dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"));
$date_end=dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"));
$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"));
$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"));
// Quarter
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
$q=GETPOST("q", "int");
$q = GETPOST("q", "int");
if (empty($q))
{
if (GETPOST("month", "int")) { $date_start=dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end=dol_get_last_day($year_start, GETPOST("month", "int"), false); }
if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); }
else
{
$date_start=dol_get_first_day($year_start, empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START, false);
if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end=dol_time_plus_duree($date_start, 3, 'm') - 1;
elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end=dol_time_plus_duree($date_start, 1, 'y') - 1;
elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end=dol_time_plus_duree($date_start, 1, 'm') - 1;
$date_start = dol_get_first_day($year_start, empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START, false);
if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1;
elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1;
elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1;
}
}
else
{
if ($q==1) { $date_start=dol_get_first_day($year_start, 1, false); $date_end=dol_get_last_day($year_start, 3, false); }
if ($q==2) { $date_start=dol_get_first_day($year_start, 4, false); $date_end=dol_get_last_day($year_start, 6, false); }
if ($q==3) { $date_start=dol_get_first_day($year_start, 7, false); $date_end=dol_get_last_day($year_start, 9, false); }
if ($q==4) { $date_start=dol_get_first_day($year_start, 10, false); $date_end=dol_get_last_day($year_start, 12, false); }
if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); }
if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); }
if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); }
if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); }
}
}
@ -86,12 +86,12 @@ if (empty($min)) $min = 0;
// Define modetax (0 or 1)
// 0=normal, 1=option vat for services is on debit, 2=option on payments for products
$modetax = $conf->global->TAX_MODE;
if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax", 'int');
if (empty($modetax)) $modetax=0;
if (GETPOSTISSET("modetax")) $modetax = GETPOST("modetax", 'int');
if (empty($modetax)) $modetax = 0;
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) $socid=$user->socid;
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'tax', '', '', 'charges');
@ -100,101 +100,101 @@ $result = restrictedArea($user, 'tax', '', '', 'charges');
* View
*/
$form=new Form($db);
$company_static=new Societe($db);
$invoice_customer=new Facture($db);
$invoice_supplier=new FactureFournisseur($db);
$expensereport=new ExpenseReport($db);
$product_static=new Product($db);
$payment_static=new Paiement($db);
$paymentfourn_static=new PaiementFourn($db);
$paymentexpensereport_static=new PaymentExpenseReport($db);
$form = new Form($db);
$company_static = new Societe($db);
$invoice_customer = new Facture($db);
$invoice_supplier = new FactureFournisseur($db);
$expensereport = new ExpenseReport($db);
$product_static = new Product($db);
$payment_static = new Paiement($db);
$paymentfourn_static = new PaiementFourn($db);
$paymentexpensereport_static = new PaymentExpenseReport($db);
$morequerystring='';
$listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday');
$morequerystring = '';
$listofparams = array('date_startmonth', 'date_startyear', 'date_startday', 'date_endmonth', 'date_endyear', 'date_endday');
foreach ($listofparams as $param)
{
if (GETPOST($param)!='') $morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param);
if (GETPOST($param) != '') $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param);
}
$title = $langs->trans("VATReport") . " " . dol_print_date($date_start) . " -> " . dol_print_date($date_end);
$title = $langs->trans("VATReport")." ".dol_print_date($date_start)." -> ".dol_print_date($date_end);
llxHeader('', $title, '', '', 0, 0, '', '', $morequerystring);
//print load_fiche_titre($langs->trans("VAT"),"");
//$fsearch.='<br>';
$fsearch ='<!-- hidden fields for form -->';
$fsearch.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$fsearch.='<input type="hidden" name="modetax" value="'.$modetax.'">';
$fsearch = '<!-- hidden fields for form -->';
$fsearch .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$fsearch .= '<input type="hidden" name="modetax" value="'.$modetax.'">';
//$fsearch.=' '.$langs->trans("SalesTurnoverMinimum").': ';
//$fsearch.=' <input type="text" name="min" value="'.$min.'">';
// Show report header
$name=$langs->trans("VATReportByRates");
$calcmode='';
if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault');
if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption');
if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices');
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')';
$name = $langs->trans("VATReportByRates");
$calcmode = '';
if ($modetax == 0) $calcmode = $langs->trans('OptionVATDefault');
if ($modetax == 1) $calcmode = $langs->trans('OptionVATDebitOption');
if ($modetax == 2) $calcmode = $langs->trans('OptionPaymentForProductAndServices');
$calcmode .= '<br>('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')';
// Set period
$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$prevyear=$year_start; $prevquarter=$q;
$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$prevyear = $year_start; $prevquarter = $q;
if ($prevquarter > 1) {
$prevquarter--;
} else {
$prevquarter=4;
$prevquarter = 4;
$prevyear--;
}
$nextyear=$year_start;
$nextquarter=$q;
$nextyear = $year_start;
$nextquarter = $q;
if ($nextquarter < 4) {
$nextquarter++;
} else {
$nextquarter=1;
$nextquarter = 1;
$nextyear++;
}
$description.=$fsearch;
$builddate=dol_now();
$description .= $fsearch;
$builddate = dol_now();
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description.=$langs->trans("RulesVATDueProducts");
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description.=$langs->trans("RulesVATInProducts");
if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description.='<br>'.$langs->trans("RulesVATDueServices");
if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description.='<br>'.$langs->trans("RulesVATInServices");
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description.='<br>'.$langs->trans("DepositsAreNotIncluded");
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description .= $langs->trans("RulesVATDueProducts");
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description .= $langs->trans("RulesVATInProducts");
if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description .= '<br>'.$langs->trans("RulesVATDueServices");
if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description .= '<br>'.$langs->trans("RulesVATInServices");
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description .= '<br>'.$langs->trans("DepositsAreNotIncluded");
}
if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='<br>'.$langs->trans("ThisIsAnEstimatedValue");
if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description .= '<br>'.$langs->trans("ThisIsAnEstimatedValue");
// Customers invoices
$elementcust=$langs->trans("CustomersInvoices");
$productcust=$langs->trans("ProductOrService");
$amountcust=$langs->trans("AmountHT");
$vatcust=$langs->trans("VATReceived");
$namecust=$langs->trans("Name");
$elementcust = $langs->trans("CustomersInvoices");
$productcust = $langs->trans("ProductOrService");
$amountcust = $langs->trans("AmountHT");
$vatcust = $langs->trans("VATReceived");
$namecust = $langs->trans("Name");
if ($mysoc->tva_assuj) {
$vatcust.=' ('.$langs->trans("VATToPay").')';
$vatcust .= ' ('.$langs->trans("VATToPay").')';
}
// Suppliers invoices
$elementsup=$langs->trans("SuppliersInvoices");
$productsup=$productcust;
$amountsup=$amountcust;
$vatsup=$langs->trans("VATPaid");
$namesup=$namecust;
$elementsup = $langs->trans("SuppliersInvoices");
$productsup = $productcust;
$amountsup = $amountcust;
$vatsup = $langs->trans("VATPaid");
$namesup = $namecust;
if ($mysoc->tva_assuj) {
$vatsup.=' ('.$langs->trans("ToGetBack").')';
$vatsup .= ' ('.$langs->trans("ToGetBack").')';
}
$optioncss = GETPOST('optioncss');
if($optioncss != "print") {
if ($optioncss != "print") {
report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
}
$vatcust=$langs->trans("VATReceived");
$vatsup=$langs->trans("VATPaid");
$vatexpensereport=$langs->trans("VATPaid");
$vatcust = $langs->trans("VATReceived");
$vatsup = $langs->trans("VATPaid");
$vatexpensereport = $langs->trans("VATPaid");
// VAT Received and paid
@ -202,38 +202,38 @@ print '<table class="noborder centpercent">';
$y = $year_current;
$total = 0;
$i=0;
$i = 0;
$columns = 5;
// Load arrays of datas
$x_coll = tax_by_rate('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'sell');
$x_paye = tax_by_rate('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'buy');
if (! is_array($x_coll) || ! is_array($x_paye))
if (!is_array($x_coll) || !is_array($x_paye))
{
$langs->load("errors");
if ($x_coll == -1) {
print '<tr><td colspan="' . $columns . '">' . $langs->trans("ErrorNoAccountancyModuleLoaded") . '</td></tr>';
print '<tr><td colspan="'.$columns.'">'.$langs->trans("ErrorNoAccountancyModuleLoaded").'</td></tr>';
} elseif ($x_coll == -2) {
print '<tr><td colspan="' . $columns . '">' . $langs->trans("FeatureNotYetAvailable") . '</td></tr>';
print '<tr><td colspan="'.$columns.'">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
} else {
print '<tr><td colspan="' . $columns . '">' . $langs->trans("Error") . '</td></tr>';
print '<tr><td colspan="'.$columns.'">'.$langs->trans("Error").'</td></tr>';
}
} else {
$x_both = array();
//now, from these two arrays, get another array with one rate per line
foreach(array_keys($x_coll) as $my_coll_rate)
foreach (array_keys($x_coll) as $my_coll_rate)
{
$x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht'];
$x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat'];
$x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat'];
$x_both[$my_coll_rate]['paye']['totalht'] = 0;
$x_both[$my_coll_rate]['paye']['vat'] = 0;
$x_both[$my_coll_rate]['coll']['links'] = '';
$x_both[$my_coll_rate]['coll']['detail'] = array();
foreach($x_coll[$my_coll_rate]['facid'] as $id=>$dummy) {
$invoice_customer->id=$x_coll[$my_coll_rate]['facid'][$id];
$invoice_customer->ref=$x_coll[$my_coll_rate]['facnum'][$id];
$invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id];
foreach ($x_coll[$my_coll_rate]['facid'] as $id=>$dummy) {
$invoice_customer->id = $x_coll[$my_coll_rate]['facid'][$id];
$invoice_customer->ref = $x_coll[$my_coll_rate]['facnum'][$id];
$invoice_customer->type = $x_coll[$my_coll_rate]['type'][$id];
$company_static->fetch($x_coll[$my_coll_rate]['company_id'][$id]);
$x_both[$my_coll_rate]['coll']['detail'][] = array(
'id' =>$x_coll[$my_coll_rate]['facid'][$id],
@ -273,9 +273,9 @@ if (! is_array($x_coll) || ! is_array($x_paye))
// ExpenseReport
if ($x_paye[$my_paye_rate]['ptype'][$id] == 'ExpenseReportPayment')
{
$expensereport->id=$x_paye[$my_paye_rate]['facid'][$id];
$expensereport->ref=$x_paye[$my_paye_rate]['facnum'][$id];
$expensereport->type=$x_paye[$my_paye_rate]['type'][$id];
$expensereport->id = $x_paye[$my_paye_rate]['facid'][$id];
$expensereport->ref = $x_paye[$my_paye_rate]['facnum'][$id];
$expensereport->type = $x_paye[$my_paye_rate]['type'][$id];
$x_both[$my_paye_rate]['paye']['detail'][] = array(
'id' =>$x_paye[$my_paye_rate]['facid'][$id],
@ -297,9 +297,9 @@ if (! is_array($x_coll) || ! is_array($x_paye))
}
else
{
$invoice_supplier->id=$x_paye[$my_paye_rate]['facid'][$id];
$invoice_supplier->ref=$x_paye[$my_paye_rate]['facnum'][$id];
$invoice_supplier->type=$x_paye[$my_paye_rate]['type'][$id];
$invoice_supplier->id = $x_paye[$my_paye_rate]['facid'][$id];
$invoice_supplier->ref = $x_paye[$my_paye_rate]['facnum'][$id];
$invoice_supplier->type = $x_paye[$my_paye_rate]['type'][$id];
$company_static->fetch($x_paye[$my_paye_rate]['company_id'][$id]);
$x_both[$my_paye_rate]['paye']['detail'][] = array(
'id' =>$x_paye[$my_paye_rate]['facid'][$id],
@ -334,8 +334,8 @@ if (! is_array($x_coll) || ! is_array($x_paye))
$x_paye_sum = 0;
$x_paye_ht = 0;
$span=$columns;
if ($modetax != 1) $span+=2;
$span = $columns;
if ($modetax != 1) $span += 2;
//print '<tr><td colspan="'.($span+1).'">'..')</td></tr>';
@ -365,7 +365,7 @@ if (! is_array($x_coll) || ! is_array($x_paye))
$object = array(&$x_coll, &$x_paye, &$x_both);
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('externalbalance'));
$reshook=$hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
foreach (array_keys($x_coll) as $rate) {
$subtot_coll_total_ht = 0;
@ -375,20 +375,20 @@ if (! is_array($x_coll) || ! is_array($x_paye))
{
// VAT Rate
print "<tr>";
print '<td class="tax_rate">'.$langs->trans("Rate").': '.vatrate($rate).'%</td><td colspan="'.($span+1).'"></td>';
print '<td class="tax_rate">'.$langs->trans("Rate").': '.vatrate($rate).'%</td><td colspan="'.($span + 1).'"></td>';
print '</tr>'."\n";
foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) {
// Define type
// We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
$type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']);
$type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']);
// Try to enhance type detection using date_start and date_end for free lines where type
// was not saved.
if (!empty($fields['ddate_start'])) {
$type=1;
$type = 1;
}
if (!empty($fields['ddate_end'])) {
$type=1;
$type = 1;
}
@ -398,22 +398,22 @@ if (! is_array($x_coll) || ! is_array($x_paye))
print '<td class="nowrap left">'.$fields['link'].'</td>';
// Invoice date
print '<td class="left">' . dol_print_date($fields['datef'], 'day') . '</td>';
print '<td class="left">'.dol_print_date($fields['datef'], 'day').'</td>';
// Payment date
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print '<td class="left">' . dol_print_date($fields['datep'], 'day') . '</td>';
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print '<td class="left">'.dol_print_date($fields['datep'], 'day').'</td>';
else print '<td></td>';
// Company name
print '<td class="left">' . $fields['company_link'] . '</td>';
print '<td class="left">'.$fields['company_link'].'</td>';
// Description
print '<td class="left">';
if ($fields['pid'])
{
$product_static->id=$fields['pid'];
$product_static->ref=$fields['pref'];
$product_static->type=$fields['dtype']; // We force with the type of line to have type how line is registered
$product_static->id = $fields['pid'];
$product_static->ref = $fields['pref'];
$product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered
print $product_static->getNomUrl(1);
if (dol_string_nohtmltag($fields['descr'])) {
print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24);
@ -427,12 +427,12 @@ if (! is_array($x_coll) || ! is_array($x_paye))
$text = img_object($langs->trans('Product'), 'product');
}
if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) {
if ($reg[1]=='DEPOSIT') {
$fields['descr']=$langs->transnoentitiesnoconv('Deposit');
} elseif ($reg[1]=='CREDIT_NOTE') {
$fields['descr']=$langs->transnoentitiesnoconv('CreditNote');
if ($reg[1] == 'DEPOSIT') {
$fields['descr'] = $langs->transnoentitiesnoconv('Deposit');
} elseif ($reg[1] == 'CREDIT_NOTE') {
$fields['descr'] = $langs->transnoentitiesnoconv('CreditNote');
} else {
$fields['descr']=$langs->transnoentitiesnoconv($reg[1]);
$fields['descr'] = $langs->transnoentitiesnoconv($reg[1]);
}
}
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24);
@ -450,21 +450,21 @@ if (! is_array($x_coll) || ! is_array($x_paye))
if (price2num($fields['ftotal_ttc']))
{
//print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
$ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']);
$ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']);
//print ' ('.round($ratiolineinvoice*100,2).'%)';
}
print '</td>';
}
// Payment
$ratiopaymentinvoice=1;
$ratiopaymentinvoice = 1;
if ($modetax != 1)
{
print '<td class="nowrap right">';
//print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc'];
if ($fields['payment_amount'] && $fields['ftotal_ttc'])
{
$payment_static->id=$fields['payment_id'];
$payment_static->id = $fields['payment_id'];
print $payment_static->getNomUrl(2);
}
if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice')
@ -473,11 +473,11 @@ if (! is_array($x_coll) || ! is_array($x_paye))
print $langs->trans("NA");
} else {
if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) {
$ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
$ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']);
}
print price(price2num($fields['payment_amount'], 'MT'));
if (isset($fields['payment_amount'])) {
print ' ('.round($ratiopaymentinvoice*100, 2).'%)';
print ' ('.round($ratiopaymentinvoice * 100, 2).'%)';
}
}
print '</td>';
@ -485,13 +485,13 @@ if (! is_array($x_coll) || ! is_array($x_paye))
// Total collected
print '<td class="nowrap right">';
$temp_ht=$fields['totalht']*$ratiopaymentinvoice;
$temp_ht = $fields['totalht'] * $ratiopaymentinvoice;
print price(price2num($temp_ht, 'MT'), 1);
print '</td>';
// VAT
print '<td class="nowrap right">';
$temp_vat=$fields['vat']*$ratiopaymentinvoice;
$temp_vat = $fields['vat'] * $ratiopaymentinvoice;
print price(price2num($temp_vat, 'MT'), 1);
//print price($fields['vat']);
print '</td>';
@ -530,7 +530,7 @@ if (! is_array($x_coll) || ! is_array($x_paye))
}
// Blank line
print '<tr><td colspan="'.($span+2).'">&nbsp;</td></tr>';
print '<tr><td colspan="'.($span + 2).'">&nbsp;</td></tr>';
// Print table headers for this quadri - expenses now
print '<tr class="liste_titre liste_titre_topborder">';
@ -556,20 +556,20 @@ if (! is_array($x_coll) || ! is_array($x_paye))
if (is_array($x_both[$rate]['paye']['detail']))
{
print "<tr>";
print '<td class="tax_rate">'.$langs->trans("Rate").': '.vatrate($rate).'%</td><td colspan="'.($span+1).'"></td>';
print '<td class="tax_rate">'.$langs->trans("Rate").': '.vatrate($rate).'%</td><td colspan="'.($span + 1).'"></td>';
print '</tr>'."\n";
foreach ($x_both[$rate]['paye']['detail'] as $index=>$fields) {
// Define type
// We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
$type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']);
$type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']);
// Try to enhance type detection using date_start and date_end for free lines where type
// was not saved.
if (!empty($fields['ddate_start'])) {
$type=1;
$type = 1;
}
if (!empty($fields['ddate_end'])) {
$type=1;
$type = 1;
}
@ -579,22 +579,22 @@ if (! is_array($x_coll) || ! is_array($x_paye))
print '<td class="nowrap left">'.$fields['link'].'</td>';
// Invoice date
print '<td class="left">' . dol_print_date($fields['datef'], 'day') . '</td>';
print '<td class="left">'.dol_print_date($fields['datef'], 'day').'</td>';
// Payment date
if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print '<td class="left">' . dol_print_date($fields['datep'], 'day') . '</td>';
if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print '<td class="left">'.dol_print_date($fields['datep'], 'day').'</td>';
else print '<td></td>';
// Company name
print '<td class="left">' . $fields['company_link'] . '</td>';
print '<td class="left">'.$fields['company_link'].'</td>';
// Description
print '<td class="left">';
if ($fields['pid'])
{
$product_static->id=$fields['pid'];
$product_static->ref=$fields['pref'];
$product_static->type=$fields['dtype']; // We force with the type of line to have type how line is registered
$product_static->id = $fields['pid'];
$product_static->ref = $fields['pref'];
$product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered
print $product_static->getNomUrl(1);
if (dol_string_nohtmltag($fields['descr'])) {
print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24);
@ -608,12 +608,12 @@ if (! is_array($x_coll) || ! is_array($x_paye))
$text = img_object($langs->trans('Product'), 'product');
}
if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) {
if ($reg[1]=='DEPOSIT') {
$fields['descr']=$langs->transnoentitiesnoconv('Deposit');
} elseif ($reg[1]=='CREDIT_NOTE') {
$fields['descr']=$langs->transnoentitiesnoconv('CreditNote');
if ($reg[1] == 'DEPOSIT') {
$fields['descr'] = $langs->transnoentitiesnoconv('Deposit');
} elseif ($reg[1] == 'CREDIT_NOTE') {
$fields['descr'] = $langs->transnoentitiesnoconv('CreditNote');
} else {
$fields['descr']=$langs->transnoentitiesnoconv($reg[1]);
$fields['descr'] = $langs->transnoentitiesnoconv($reg[1]);
}
}
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24);
@ -631,20 +631,20 @@ if (! is_array($x_coll) || ! is_array($x_paye))
if (price2num($fields['ftotal_ttc']))
{
//print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
$ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']);
$ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']);
//print ' ('.round($ratiolineinvoice*100,2).'%)';
}
print '</td>';
}
// Payment
$ratiopaymentinvoice=1;
$ratiopaymentinvoice = 1;
if ($modetax != 1)
{
print '<td class="nowrap right">';
if ($fields['payment_amount'] && $fields['ftotal_ttc'])
{
$paymentfourn_static->id=$fields['payment_id'];
$paymentfourn_static->id = $fields['payment_id'];
print $paymentfourn_static->getNomUrl(2);
}
@ -656,11 +656,11 @@ if (! is_array($x_coll) || ! is_array($x_paye))
else
{
if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) {
$ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
$ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']);
}
print price(price2num($fields['payment_amount'], 'MT'));
if (isset($fields['payment_amount'])) {
print ' ('.round($ratiopaymentinvoice*100, 2).'%)';
print ' ('.round($ratiopaymentinvoice * 100, 2).'%)';
}
}
print '</td>';
@ -668,21 +668,21 @@ if (! is_array($x_coll) || ! is_array($x_paye))
// VAT paid
print '<td class="nowrap right">';
$temp_ht=$fields['totalht']*$ratiopaymentinvoice;
$temp_ht = $fields['totalht'] * $ratiopaymentinvoice;
print price(price2num($temp_ht, 'MT'), 1);
print '</td>';
// VAT
print '<td class="nowrap right">';
$temp_vat=$fields['vat']*$ratiopaymentinvoice;
$temp_vat = $fields['vat'] * $ratiopaymentinvoice;
print price(price2num($temp_vat, 'MT'), 1);
//print price($fields['vat']);
print '</td>';
print '</tr>';
$subtot_paye_total_ht += $temp_ht;
$subtot_paye_vat += $temp_vat;
$x_paye_sum += $temp_vat;
$subtot_paye_vat += $temp_vat;
$x_paye_sum += $temp_vat;
}
}
// Total suppliers for this vat rate
@ -718,7 +718,7 @@ if (! is_array($x_coll) || ! is_array($x_paye))
print '<table class="noborder centpercent">';
$diff = $x_coll_sum - $x_paye_sum;
print '<tr class="liste_total">';
print '<td class="liste_total" colspan="'.$span.'">'.$langs->trans("TotalToPay").($q?', '.$langs->trans("Quadri").' '.$q:'').'</td>';
print '<td class="liste_total" colspan="'.$span.'">'.$langs->trans("TotalToPay").($q ? ', '.$langs->trans("Quadri").' '.$q : '').'</td>';
print '<td class="liste_total nowrap right"><b>'.price(price2num($diff, 'MT'))."</b></td>\n";
print "</tr>\n";

View File

@ -37,22 +37,22 @@ $hookmanager->initHooks(array('contractindex'));
// Load translation files required by the page
$langs->loadLangs(array('products', 'companies', 'contracts'));
$sortfield=GETPOST('sortfield', 'alpha');
$sortorder=GETPOST('sortorder', 'alpha');
$page=GETPOST('page', 'int');
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
$statut=GETPOST('statut')?GETPOST('statut'):1;
$statut = GETPOST('statut') ?GETPOST('statut') : 1;
// Security check
$socid=0;
$socid = 0;
$id = GETPOST('id', 'int');
if (! empty($user->socid)) $socid=$user->socid;
if (!empty($user->socid)) $socid = $user->socid;
$result = restrictedArea($user, 'contrat', $id);
$staticcompany=new Societe($db);
$staticcontrat=new Contrat($db);
$staticcontratligne=new ContratLigne($db);
$productstatic=new Product($db);
$staticcompany = new Societe($db);
$staticcontrat = new Contrat($db);
$staticcontratligne = new ContratLigne($db);
$productstatic = new Product($db);
/*
@ -78,10 +78,10 @@ print load_fiche_titre($langs->trans("ContractsArea"), '', 'commercial');
print '<div class="fichecenter"><div class="fichethirdleft">';
if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
{
// Search contract
if (! empty($conf->contrat->enabled))
if (!empty($conf->contrat->enabled))
{
print '<form method="post" action="'.DOL_URL_ROOT.'/contrat/list.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -102,23 +102,23 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele
* Statistics
*/
$nb=array();
$total=0;
$totalinprocess=0;
$dataseries=array();
$vals=array();
$nb = array();
$total = 0;
$totalinprocess = 0;
$dataseries = array();
$vals = array();
// Search by status (except expired)
$sql = "SELECT count(cd.rowid), cd.statut";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid";
$sql.= " AND (cd.statut != 4 OR (cd.statut = 4 AND (cd.date_fin_validite is null or cd.date_fin_validite >= '".$db->idate($now)."')))";
$sql.= " AND c.entity IN (".getEntity('contract', 0).")";
if ($user->socid) $sql.=' AND c.fk_soc = '.$user->socid;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " GROUP BY cd.statut";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid";
$sql .= " AND (cd.statut != 4 OR (cd.statut = 4 AND (cd.date_fin_validite is null or cd.date_fin_validite >= '".$db->idate($now)."')))";
$sql .= " AND c.entity IN (".getEntity('contract', 0).")";
if ($user->socid) $sql .= ' AND c.fk_soc = '.$user->socid;
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
$sql .= " GROUP BY cd.statut";
$resql = $db->query($sql);
if ($resql)
{
@ -129,13 +129,13 @@ if ($resql)
$row = $db->fetch_row($resql);
if ($row)
{
$nb[$row[1]]=$row[0];
if ($row[1]!=5)
$nb[$row[1]] = $row[0];
if ($row[1] != 5)
{
$vals[$row[1]]=$row[0];
$totalinprocess+=$row[0];
$vals[$row[1]] = $row[0];
$totalinprocess += $row[0];
}
$total+=$row[0];
$total += $row[0];
}
$i++;
}
@ -147,15 +147,15 @@ else
}
// Search by status (only expired)
$sql = "SELECT count(cd.rowid), cd.statut";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid";
$sql.= " AND (cd.statut = 4 AND cd.date_fin_validite < '".$db->idate($now)."')";
$sql.= " AND c.entity IN (".getEntity('contract', 0).")";
if ($user->socid) $sql.=' AND c.fk_soc = '.$user->socid;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " GROUP BY cd.statut";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid";
$sql .= " AND (cd.statut = 4 AND cd.date_fin_validite < '".$db->idate($now)."')";
$sql .= " AND c.entity IN (".getEntity('contract', 0).")";
if ($user->socid) $sql .= ' AND c.fk_soc = '.$user->socid;
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
$sql .= " GROUP BY cd.statut";
$resql = $db->query($sql);
if ($resql)
{
@ -168,13 +168,13 @@ if ($resql)
$row = $db->fetch_row($resql);
if ($row)
{
$nb[$row[1].true]=$row[0];
if ($row[1]!=5)
$nb[$row[1].true] = $row[0];
if ($row[1] != 5)
{
$vals[$row[1]]=$row[0];
$totalinprocess+=$row[0];
$vals[$row[1]] = $row[0];
$totalinprocess += $row[0];
}
$total+=$row[0];
$total += $row[0];
}
$i++;
}
@ -188,21 +188,21 @@ else
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder nohover centpercent">';
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("Services").'</th></tr>'."\n";
$listofstatus=array(0,4,4,5); $bool=false;
foreach($listofstatus as $status)
$listofstatus = array(0, 4, 4, 5); $bool = false;
foreach ($listofstatus as $status)
{
$dataseries[]=array($staticcontratligne->LibStatut($status, 1, ($bool?1:0)),(isset($nb[$status.$bool])?(int) $nb[$status.$bool]:0));
$dataseries[] = array($staticcontratligne->LibStatut($status, 1, ($bool ? 1 : 0)), (isset($nb[$status.$bool]) ? (int) $nb[$status.$bool] : 0));
if (empty($conf->use_javascript_ajax))
{
print '<tr class="oddeven">';
print '<td>'.$staticcontratligne->LibStatut($status, 0, ($bool?1:0)).'</td>';
print '<td class="right"><a href="services_list.php?mode='.$status.($bool?'&filter=expired':'').'">'.($nb[$status.$bool]?$nb[$status.$bool]:0).' '.$staticcontratligne->LibStatut($status, 3, ($bool?1:0)).'</a></td>';
print '<td>'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).'</td>';
print '<td class="right"><a href="services_list.php?mode='.$status.($bool ? '&filter=expired' : '').'">'.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'</a></td>';
print "</tr>\n";
}
if ($status==4 && ! $bool) $bool=true;
else $bool=false;
if ($status == 4 && !$bool) $bool = true;
else $bool = false;
}
if (! empty($conf->use_javascript_ajax))
if (!empty($conf->use_javascript_ajax))
{
print '<tr class="impair"><td class="center" colspan="2">';
@ -214,20 +214,20 @@ if (! empty($conf->use_javascript_ajax))
$dolgraph->SetType(array('pie'));
$dolgraph->setWidth('100%');
$dolgraph->draw('idgraphstatus');
print $dolgraph->show($total?0:1);
print $dolgraph->show($total ? 0 : 1);
print '</td></tr>';
}
$listofstatus=array(0,4,4,5); $bool=false;
foreach($listofstatus as $status)
$listofstatus = array(0, 4, 4, 5); $bool = false;
foreach ($listofstatus as $status)
{
if (empty($conf->use_javascript_ajax))
{
print '<tr class="oddeven">';
print '<td>'.$staticcontratligne->LibStatut($status, 0, ($bool?1:0)).'</td>';
print '<td class="right"><a href="services_list.php?mode='.$status.($bool?'&filter=expired':'').'">'.($nb[$status.$bool]?$nb[$status.$bool]:0).' '.$staticcontratligne->LibStatut($status, 3, ($bool?1:0)).'</a></td>';
if ($status==4 && ! $bool) $bool=true;
else $bool=false;
print '<td>'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).'</td>';
print '<td class="right"><a href="services_list.php?mode='.$status.($bool ? '&filter=expired' : '').'">'.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'</a></td>';
if ($status == 4 && !$bool) $bool = true;
else $bool = false;
print "</tr>\n";
}
}
@ -239,31 +239,31 @@ print "</table></div><br>";
// Draft contracts
if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire)
if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire)
{
$sql = "SELECT c.rowid, c.ref,";
$sql.= " s.nom as name, s.rowid as socid";
$sql.= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.rowid = c.fk_soc";
$sql.= " AND c.entity IN (".getEntity('contract', 0).")";
$sql.= " AND c.statut = 0";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
$sql = "SELECT c.rowid, c.ref,";
$sql .= " s.nom as name, s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE s.rowid = c.fk_soc";
$sql .= " AND c.entity IN (".getEntity('contract', 0).")";
$sql .= " AND c.statut = 0";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) $sql .= " AND c.fk_soc = ".$socid;
$resql = $db->query($sql);
if ( $resql )
if ($resql)
{
$num = $db->num_rows($resql);
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="3">'.$langs->trans("DraftContracts").($num?' <span class="badge">'.$num.'</span>':'').'</th></tr>';
print '<th colspan="3">'.$langs->trans("DraftContracts").($num ? ' <span class="badge">'.$num.'</span>' : '').'</th></tr>';
if ($num)
{
$companystatic=new Societe($db);
$companystatic = new Societe($db);
$i = 0;
//$tot_ttc = 0;
@ -271,12 +271,12 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire)
{
$obj = $db->fetch_object($resql);
$staticcontrat->ref=$obj->ref;
$staticcontrat->id=$obj->rowid;
$staticcontrat->ref = $obj->ref;
$staticcontrat->id = $obj->rowid;
$companystatic->id=$obj->socid;
$companystatic->name=$obj->name;
$companystatic->client=1;
$companystatic->id = $obj->socid;
$companystatic->name = $obj->name;
$companystatic->client = 1;
print '<tr class="oddeven"><td class="nowrap">';
print $staticcontrat->getNomUrl(1, '');
@ -308,29 +308,29 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
// Last modified contracts
$max=5;
$max = 5;
$sql = 'SELECT ';
$sql.= ' sum('.$db->ifsql("cd.statut=0", 1, 0).') as nb_initial,';
$sql.= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= '".$db->idate($now)."')", 1, 0).') as nb_running,';
$sql.= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now)."')", 1, 0).') as nb_expired,';
$sql.= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now - $conf->contrat->services->expires->warning_delay)."')", 1, 0).') as nb_late,';
$sql.= ' sum('.$db->ifsql("cd.statut=5", 1, 0).') as nb_closed,';
$sql.= " c.rowid as cid, c.ref, c.datec, c.tms, c.statut, s.nom as name, s.rowid as socid";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,";
$sql.= " ".MAIN_DB_PREFIX."contrat as c";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat";
$sql.= " WHERE c.fk_soc = s.rowid";
$sql.= " AND c.entity IN (".getEntity('contract', 0).")";
$sql.= " AND c.statut > 0";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND s.rowid = ".$socid;
$sql.= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.statut, s.nom, s.rowid";
$sql.= " ORDER BY c.tms DESC";
$sql.= " LIMIT ".$max;
$sql .= ' sum('.$db->ifsql("cd.statut=0", 1, 0).') as nb_initial,';
$sql .= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= '".$db->idate($now)."')", 1, 0).') as nb_running,';
$sql .= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now)."')", 1, 0).') as nb_expired,';
$sql .= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now - $conf->contrat->services->expires->warning_delay)."')", 1, 0).') as nb_late,';
$sql .= ' sum('.$db->ifsql("cd.statut=5", 1, 0).') as nb_closed,';
$sql .= " c.rowid as cid, c.ref, c.datec, c.tms, c.statut, s.nom as name, s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,";
$sql .= " ".MAIN_DB_PREFIX."contrat as c";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat";
$sql .= " WHERE c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity('contract', 0).")";
$sql .= " AND c.statut > 0";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) $sql .= " AND s.rowid = ".$socid;
$sql .= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.statut, s.nom, s.rowid";
$sql .= " ORDER BY c.tms DESC";
$sql .= " LIMIT ".$max;
dol_syslog("contrat/index.php", LOG_DEBUG);
$result=$db->query($sql);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
@ -351,22 +351,22 @@ if ($result)
print '<tr class="oddeven">';
print '<td width="110" class="nowrap">';
$staticcontrat->ref=($obj->ref?$obj->ref:$obj->cid);
$staticcontrat->id=$obj->cid;
$staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->cid);
$staticcontrat->id = $obj->cid;
print $staticcontrat->getNomUrl(1, 16);
if ($obj->nb_late) print img_warning($langs->trans("Late"));
print '</td>';
print '<td>';
$staticcompany->id=$obj->socid;
$staticcompany->name=$obj->name;
$staticcompany->id = $obj->socid;
$staticcompany->name = $obj->name;
print $staticcompany->getNomUrl(1, '', 20);
print '</td>';
print '<td class="center">'.dol_print_date($db->jdate($obj->tms), 'dayhour').'</td>';
//print '<td class="left">'.$staticcontrat->LibStatut($obj->statut,2).'</td>';
print '<td class="right" width="32">'.($obj->nb_initial>0 ? $obj->nb_initial.$staticcontratligne->LibStatut(0, 3):'').'</td>';
print '<td class="right" width="32">'.($obj->nb_running>0 ? $obj->nb_running.$staticcontratligne->LibStatut(4, 3, 0):'').'</td>';
print '<td class="right" width="32">'.($obj->nb_expired>0 ? $obj->nb_expired.$staticcontratligne->LibStatut(4, 3, 1):'').'</td>';
print '<td class="right" width="32">'.($obj->nb_closed>0 ? $obj->nb_closed.$staticcontratligne->LibStatut(5, 3):'').'</td>';
print '<td class="right" width="32">'.($obj->nb_initial > 0 ? $obj->nb_initial.$staticcontratligne->LibStatut(0, 3) : '').'</td>';
print '<td class="right" width="32">'.($obj->nb_running > 0 ? $obj->nb_running.$staticcontratligne->LibStatut(4, 3, 0) : '').'</td>';
print '<td class="right" width="32">'.($obj->nb_expired > 0 ? $obj->nb_expired.$staticcontratligne->LibStatut(4, 3, 1) : '').'</td>';
print '<td class="right" width="32">'.($obj->nb_closed > 0 ? $obj->nb_closed.$staticcontratligne->LibStatut(5, 3) : '').'</td>';
print "</tr>\n";
$i++;
}
@ -383,22 +383,22 @@ print '<br>';
// Last modified services
$sql = "SELECT c.ref, c.fk_soc, ";
$sql.= " cd.rowid as cid, cd.statut, cd.label, cd.fk_product, cd.description as note, cd.fk_contrat, cd.date_fin_validite,";
$sql.= " s.nom as name,";
$sql.= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity";
$sql.= " FROM (".MAIN_DB_PREFIX."contrat as c";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ", ".MAIN_DB_PREFIX."contratdet as cd";
$sql.= ") LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
$sql.= " WHERE c.entity IN (".getEntity('contract', 0).")";
$sql.= " AND cd.fk_contrat = c.rowid";
$sql.= " AND c.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND s.rowid = ".$socid;
$sql.= " ORDER BY cd.tms DESC";
$sql .= " cd.rowid as cid, cd.statut, cd.label, cd.fk_product, cd.description as note, cd.fk_contrat, cd.date_fin_validite,";
$sql .= " s.nom as name,";
$sql .= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity";
$sql .= " FROM (".MAIN_DB_PREFIX."contrat as c";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= ", ".MAIN_DB_PREFIX."contratdet as cd";
$sql .= ") LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
$sql .= " WHERE c.entity IN (".getEntity('contract', 0).")";
$sql .= " AND cd.fk_contrat = c.rowid";
$sql .= " AND c.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) $sql .= " AND s.rowid = ".$socid;
$sql .= " ORDER BY cd.tms DESC";
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
@ -416,18 +416,18 @@ if ($resql)
print '<tr class="oddeven">';
print '<td width="110" class="nowrap">';
$staticcontrat->ref=($obj->ref?$obj->ref:$obj->fk_contrat);
$staticcontrat->id=$obj->fk_contrat;
$staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat);
$staticcontrat->id = $obj->fk_contrat;
print $staticcontrat->getNomUrl(1, 16);
//if (1 == 1) print img_warning($langs->trans("Late"));
print '</td>';
print '<td>';
if ($obj->fk_product > 0)
{
$productstatic->id=$obj->fk_product;
$productstatic->type=$obj->ptype;
$productstatic->ref=$obj->pref;
$productstatic->entity=$obj->pentity;
$productstatic->id = $obj->fk_product;
$productstatic->type = $obj->ptype;
$productstatic->ref = $obj->pref;
$productstatic->entity = $obj->pentity;
print $productstatic->getNomUrl(1, '', 20);
}
else
@ -438,13 +438,13 @@ if ($resql)
}
print '</td>';
print '<td>';
$staticcompany->id=$obj->fk_soc;
$staticcompany->name=$obj->name;
$staticcompany->id = $obj->fk_soc;
$staticcompany->name = $obj->name;
print $staticcompany->getNomUrl(1, '', 20);
print '</td>';
print '<td class="nowrap right"><a href="'.DOL_URL_ROOT.'/contrat/card.php?id='.$obj->fk_contrat.'&ligne='.$obj->cid.'">';
$dateend=$db->jdate($obj->date_fin_validite);
print $staticcontratligne->LibStatut($obj->statut, 3, ($dateend && $dateend < $now)?1:0);
$dateend = $db->jdate($obj->date_fin_validite);
print $staticcontratligne->LibStatut($obj->statut, 3, ($dateend && $dateend < $now) ? 1 : 0);
print '</a></td>';
print "</tr>\n";
$i++;
@ -462,23 +462,23 @@ print '<br>';
// Not activated services
$sql = "SELECT c.ref, c.fk_soc, cd.rowid as cid, cd.statut, cd.label, cd.fk_product, cd.description as note, cd.fk_contrat,";
$sql.= " s.nom as name,";
$sql.= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity";
$sql.= " FROM (".MAIN_DB_PREFIX."contrat as c";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ", ".MAIN_DB_PREFIX."contratdet as cd";
$sql.= " ) LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
$sql.= " WHERE c.entity IN (".getEntity('contract', 0).")";
$sql.= " AND c.statut = 1";
$sql.= " AND cd.statut = 0";
$sql.= " AND cd.fk_contrat = c.rowid";
$sql.= " AND c.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND s.rowid = ".$socid;
$sql.= " ORDER BY cd.tms DESC";
$sql .= " s.nom as name,";
$sql .= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity";
$sql .= " FROM (".MAIN_DB_PREFIX."contrat as c";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= ", ".MAIN_DB_PREFIX."contratdet as cd";
$sql .= " ) LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
$sql .= " WHERE c.entity IN (".getEntity('contract', 0).")";
$sql .= " AND c.statut = 1";
$sql .= " AND cd.statut = 0";
$sql .= " AND cd.fk_contrat = c.rowid";
$sql .= " AND c.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) $sql .= " AND s.rowid = ".$socid;
$sql .= " ORDER BY cd.tms DESC";
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
@ -497,17 +497,17 @@ if ($resql)
print '<tr class="oddeven">';
print '<td width="110" class="nowrap">';
$staticcontrat->ref=($obj->ref?$obj->ref:$obj->fk_contrat);
$staticcontrat->id=$obj->fk_contrat;
$staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat);
$staticcontrat->id = $obj->fk_contrat;
print $staticcontrat->getNomUrl(1, 16);
print '</td>';
print '<td class="nowrap">';
if ($obj->fk_product > 0)
{
$productstatic->id=$obj->fk_product;
$productstatic->type=$obj->ptype;
$productstatic->ref=$obj->pref;
$productstatic->entity=$obj->pentity;
$productstatic->id = $obj->fk_product;
$productstatic->type = $obj->ptype;
$productstatic->ref = $obj->pref;
$productstatic->entity = $obj->pentity;
print $productstatic->getNomUrl(1, '', 20);
}
else
@ -518,8 +518,8 @@ if ($resql)
}
print '</td>';
print '<td>';
$staticcompany->id=$obj->fk_soc;
$staticcompany->name=$obj->name;
$staticcompany->id = $obj->fk_soc;
$staticcompany->name = $obj->name;
print $staticcompany->getNomUrl(1, '', 20);
print '</td>';
print '<td width="16" class="right"><a href="line.php?id='.$obj->fk_contrat.'&ligne='.$obj->cid.'">';
@ -541,24 +541,24 @@ print '<br>';
// Expired services
$sql = "SELECT c.ref, c.fk_soc, cd.rowid as cid, cd.statut, cd.label, cd.fk_product, cd.description as note, cd.fk_contrat,";
$sql.= " s.nom as name,";
$sql.= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity";
$sql.= " FROM (".MAIN_DB_PREFIX."contrat as c";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ", ".MAIN_DB_PREFIX."contratdet as cd";
$sql.= " ) LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
$sql.= " WHERE c.entity IN (".getEntity('contract', 0).")";
$sql.= " AND c.statut = 1";
$sql.= " AND cd.statut = 4";
$sql.= " AND cd.date_fin_validite < '".$db->idate($now)."'";
$sql.= " AND cd.fk_contrat = c.rowid";
$sql.= " AND c.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND s.rowid = ".$socid;
$sql.= " ORDER BY cd.tms DESC";
$sql .= " s.nom as name,";
$sql .= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity";
$sql .= " FROM (".MAIN_DB_PREFIX."contrat as c";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= ", ".MAIN_DB_PREFIX."contratdet as cd";
$sql .= " ) LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
$sql .= " WHERE c.entity IN (".getEntity('contract', 0).")";
$sql .= " AND c.statut = 1";
$sql .= " AND cd.statut = 4";
$sql .= " AND cd.date_fin_validite < '".$db->idate($now)."'";
$sql .= " AND cd.fk_contrat = c.rowid";
$sql .= " AND c.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) $sql .= " AND s.rowid = ".$socid;
$sql .= " ORDER BY cd.tms DESC";
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
@ -577,17 +577,17 @@ if ($resql)
print '<tr class="oddeven">';
print '<td width="110" class="nowrap">';
$staticcontrat->ref=($obj->ref?$obj->ref:$obj->fk_contrat);
$staticcontrat->id=$obj->fk_contrat;
$staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat);
$staticcontrat->id = $obj->fk_contrat;
print $staticcontrat->getNomUrl(1, 16);
print '</td>';
print '<td class="nowrap">';
if ($obj->fk_product > 0)
{
$productstatic->id=$obj->fk_product;
$productstatic->type=$obj->ptype;
$productstatic->ref=$obj->pref;
$productstatic->entity=$obj->pentity;
$productstatic->id = $obj->fk_product;
$productstatic->type = $obj->ptype;
$productstatic->ref = $obj->pref;
$productstatic->entity = $obj->pentity;
print $productstatic->getNomUrl(1, '', 20);
}
else
@ -598,8 +598,8 @@ if ($resql)
}
print '</td>';
print '<td>';
$staticcompany->id=$obj->fk_soc;
$staticcompany->name=$obj->name;
$staticcompany->id = $obj->fk_soc;
$staticcompany->name = $obj->name;
print $staticcompany->getNomUrl(1, '', 20);
print '</td>';
print '<td width="16" class="right"><a href="line.php?id='.$obj->fk_contrat.'&ligne='.$obj->cid.'">';

View File

@ -37,7 +37,7 @@ $langs->load("donations");
// Security check
$result = restrictedArea($user, 'don');
$donation_static=new Don($db);
$donation_static = new Don($db);
/*
@ -51,19 +51,19 @@ $donation_static=new Don($db);
* View
*/
$donstatic=new Don($db);
$donstatic = new Don($db);
$help_url='EN:Module_Donations|FR:Module_Dons|ES:M&oacute;dulo_Donaciones';
$help_url = 'EN:Module_Donations|FR:Module_Dons|ES:M&oacute;dulo_Donaciones';
llxHeader('', $langs->trans("Donations"), $help_url);
$nb=array();
$somme=array();
$nb = array();
$somme = array();
$total = 0;
$sql = "SELECT count(d.rowid) as nb, sum(d.amount) as somme , d.fk_statut";
$sql.= " FROM ".MAIN_DB_PREFIX."don as d WHERE d.entity IN (".getEntity('donation').")";
$sql.= " GROUP BY d.fk_statut";
$sql.= " ORDER BY d.fk_statut";
$sql .= " FROM ".MAIN_DB_PREFIX."don as d WHERE d.entity IN (".getEntity('donation').")";
$sql .= " GROUP BY d.fk_statut";
$sql .= " ORDER BY d.fk_statut";
$result = $db->query($sql);
if ($result)
@ -90,11 +90,11 @@ print load_fiche_titre($langs->trans("DonationsArea"), '', 'invoicing');
print '<div class="fichecenter"><div class="fichethirdleft">';
if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
{
if (! empty($conf->don->enabled) && $user->rights->don->lire)
if (!empty($conf->don->enabled) && $user->rights->don->lire)
{
$listofsearchfields['search_donation']=array('text'=>'Donation');
$listofsearchfields['search_donation'] = array('text'=>'Donation');
}
if (count($listofsearchfields))
@ -102,8 +102,8 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele
print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder nohover centpercent">';
$i=0;
foreach($listofsearchfields as $key => $value)
$i = 0;
foreach ($listofsearchfields as $key => $value)
{
if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
print '<tr '.$bc[false].'>';
@ -124,10 +124,10 @@ print '<tr class="liste_titre">';
print '<th colspan="4">'.$langs->trans("Statistics").'</th>';
print "</tr>\n";
$listofstatus=array(0,1,-1,2);
$listofstatus = array(0, 1, -1, 2);
foreach ($listofstatus as $status)
{
$dataseries[]=array($donstatic->LibStatut($status, 1), (isset($nb[$status])?(int) $nb[$status]:0));
$dataseries[] = array($donstatic->LibStatut($status, 1), (isset($nb[$status]) ? (int) $nb[$status] : 0));
}
if ($conf->use_javascript_ajax)
@ -142,7 +142,7 @@ if ($conf->use_javascript_ajax)
$dolgraph->SetType(array('pie'));
$dolgraph->setWidth('100%');
$dolgraph->draw('idgraphstatus');
print $dolgraph->show($total?0:1);
print $dolgraph->show($total ? 0 : 1);
print '</td></tr>';
}
@ -154,17 +154,17 @@ print '<td class="right">'.$langs->trans("Total").'</td>';
print '<td class="right">'.$langs->trans("Average").'</td>';
print '</tr>';
$total=0;
$totalnb=0;
$total = 0;
$totalnb = 0;
foreach ($listofstatus as $status)
{
print '<tr class="oddeven">';
print '<td><a href="list.php?statut='.$status.'">'.$donstatic->LibStatut($status, 4).'</a></td>';
print '<td class="right">'.(! empty($nb[$status])?$nb[$status]:'&nbsp;').'</td>';
print '<td class="right">'.(! empty($nb[$status])?price($somme[$status], 'MT'):'&nbsp;').'</td>';
print '<td class="right">'.(! empty($nb[$status])?price(price2num($somme[$status]/$nb[$status], 'MT')):'&nbsp;').'</td>';
$totalnb += (! empty($nb[$status])?$nb[$status]:0);
$total += (! empty($somme[$status])?$somme[$status]:0);
print '<td class="right">'.(!empty($nb[$status]) ? $nb[$status] : '&nbsp;').'</td>';
print '<td class="right">'.(!empty($nb[$status]) ?price($somme[$status], 'MT') : '&nbsp;').'</td>';
print '<td class="right">'.(!empty($nb[$status]) ?price(price2num($somme[$status] / $nb[$status], 'MT')) : '&nbsp;').'</td>';
$totalnb += (!empty($nb[$status]) ? $nb[$status] : 0);
$total += (!empty($somme[$status]) ? $somme[$status] : 0);
print "</tr>";
}
@ -172,7 +172,7 @@ print '<tr class="liste_total">';
print '<td>'.$langs->trans("Total").'</td>';
print '<td class="right">'.$totalnb.'</td>';
print '<td class="right">'.price($total, 'MT').'</td>';
print '<td class="right">'.($totalnb?price(price2num($total/$totalnb, 'MT')):'&nbsp;').'</td>';
print '<td class="right">'.($totalnb ?price(price2num($total / $totalnb, 'MT')) : '&nbsp;').'</td>';
print '</tr>';
print "</table>";
@ -180,20 +180,20 @@ print "</table>";
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
$max=10;
$max = 10;
/*
* Last modified donations
*/
$sql = "SELECT c.rowid, c.ref, c.fk_statut, c.societe, c.lastname, c.firstname, c.tms as datem, c.amount";
$sql.= " FROM ".MAIN_DB_PREFIX."don as c";
$sql.= " WHERE c.entity = ".$conf->entity;
$sql .= " FROM ".MAIN_DB_PREFIX."don as c";
$sql .= " WHERE c.entity = ".$conf->entity;
//$sql.= " AND c.fk_statut > 2";
$sql.= " ORDER BY c.tms DESC";
$sql.= $db->plimit($max, 0);
$sql .= " ORDER BY c.tms DESC";
$sql .= $db->plimit($max, 0);
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
print '<table class="noborder centpercent">';
@ -210,8 +210,8 @@ if ($resql)
print '<tr class="oddeven">';
$donation_static->id=$obj->rowid;
$donation_static->ref=$obj->ref?$obj->ref:$obj->rowid;
$donation_static->id = $obj->rowid;
$donation_static->ref = $obj->ref ? $obj->ref : $obj->rowid;
print '<td width="96" class="nobordernopadding nowrap">';
print $donation_static->getNomUrl(1);
@ -219,7 +219,7 @@ if ($resql)
print '<td class="nobordernopadding">';
print $obj->societe;
print ($obj->societe && ($obj->lastname || $obj->firstname)?' / ':'');
print ($obj->societe && ($obj->lastname || $obj->firstname) ? ' / ' : '');
print dolGetFirstLastname($obj->lastname, $obj->firstname);
print '</td>';

View File

@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
// Security check
$orderid = GETPOST('orderid');
if ($user->socid) $socid=$user->socid;
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande');
$hookmanager = new HookManager($db);
@ -51,7 +51,7 @@ $langs->loadLangs(array("suppliers", "orders"));
llxHeader('', $langs->trans("SuppliersOrdersArea"));
$commandestatic = new CommandeFournisseur($db);
$userstatic=new User($db);
$userstatic = new User($db);
$formfile = new FormFile($db);
print load_fiche_titre($langs->trans("SuppliersOrdersArea"), '', 'commercial');
@ -59,7 +59,7 @@ print load_fiche_titre($langs->trans("SuppliersOrdersArea"), '', 'commercial');
print '<div class="fichecenter"><div class="fichethirdleft">';
if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
{
print '<form method="post" action="list.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -77,14 +77,14 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele
*/
$sql = "SELECT count(cf.rowid), fk_statut";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE cf.fk_soc = s.rowid";
$sql.= " AND cf.entity = ".$conf->entity;
if ($user->socid) $sql.=' AND cf.fk_soc = '.$user->socid;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " GROUP BY cf.fk_statut";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE cf.fk_soc = s.rowid";
$sql .= " AND cf.entity = ".$conf->entity;
if ($user->socid) $sql .= ' AND cf.fk_soc = '.$user->socid;
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
$sql .= " GROUP BY cf.fk_statut";
$resql = $db->query($sql);
if ($resql)
@ -92,10 +92,10 @@ if ($resql)
$num = $db->num_rows($resql);
$i = 0;
$total=0;
$totalinprocess=0;
$dataseries=array();
$vals=array();
$total = 0;
$totalinprocess = 0;
$dataseries = array();
$vals = array();
// 0=Draft -> 1=Validated -> 2=Approved -> 3=Process runing -> 4=Received partially -> 5=Received totally -> (reopen) 4=Received partially
// -> 7=Canceled/Never received -> (reopen) 3=Process runing
// -> 6=Canceled -> (reopen) 2=Approved
@ -104,12 +104,12 @@ if ($resql)
$row = $db->fetch_row($resql);
if ($row)
{
if ($row[1]!=7 && $row[1]!=6 && $row[1]!=5)
if ($row[1] != 7 && $row[1] != 6 && $row[1] != 5)
{
$vals[$row[1]]=$row[0];
$totalinprocess+=$row[0];
$vals[$row[1]] = $row[0];
$totalinprocess += $row[0];
}
$total+=$row[0];
$total += $row[0];
}
$i++;
}
@ -119,14 +119,14 @@ if ($resql)
print '<table class="noborder nohover centpercent">';
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("SuppliersOrders").'</th></tr>';
print "</tr>\n";
foreach (array(0,1,2,3,4,5,6) as $status)
foreach (array(0, 1, 2, 3, 4, 5, 6) as $status)
{
$dataseries[]=array($commandestatic->LibStatut($status, 1), (isset($vals[$status])?(int) $vals[$status]:0));
if (! $conf->use_javascript_ajax)
$dataseries[] = array($commandestatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0));
if (!$conf->use_javascript_ajax)
{
print '<tr class="oddeven">';
print '<td>'.$commandestatic->LibStatut($status, 0).'</td>';
print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status])?$vals[$status]:0).'</a></td>';
print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
print "</tr>\n";
}
}
@ -142,7 +142,7 @@ if ($resql)
$dolgraph->SetType(array('pie'));
$dolgraph->setWidth('100%');
$dolgraph->draw('idgraphstatus');
print $dolgraph->show($total?0:1);
print $dolgraph->show($total ? 0 : 1);
print '</td></tr>';
}
@ -165,14 +165,14 @@ else
*/
$sql = "SELECT count(cf.rowid), fk_statut";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE cf.fk_soc = s.rowid";
$sql.= " AND s.entity = ".$conf->entity;
if ($user->socid) $sql.=' AND cf.fk_soc = '.$user->socid;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " GROUP BY cf.fk_statut";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE cf.fk_soc = s.rowid";
$sql .= " AND s.entity = ".$conf->entity;
if ($user->socid) $sql .= ' AND cf.fk_soc = '.$user->socid;
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
$sql .= " GROUP BY cf.fk_statut";
$resql = $db->query($sql);
if ($resql)
@ -211,19 +211,19 @@ else
* Draft orders
*/
if (! empty($conf->fournisseur->enabled))
if (!empty($conf->fournisseur->enabled))
{
$sql = "SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.rowid";
$sql.= " AND c.entity = ".$conf->entity;
$sql.= " AND c.fk_statut = 0";
if (! empty($socid)) $sql.= " AND c.fk_soc = ".$socid;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE c.fk_soc = s.rowid";
$sql .= " AND c.entity = ".$conf->entity;
$sql .= " AND c.fk_statut = 0";
if (!empty($socid)) $sql .= " AND c.fk_soc = ".$socid;
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
print '<div class="div-table-responsive-no-min">';
@ -255,16 +255,16 @@ if (! empty($conf->fournisseur->enabled))
* List of users allowed
*/
$sql = "SELECT u.rowid, u.lastname, u.firstname, u.email";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u,";
$sql.= " ".MAIN_DB_PREFIX."user_rights as ur";
$sql.= ", ".MAIN_DB_PREFIX."rights_def as rd";
$sql.= " WHERE u.rowid = ur.fk_user";
$sql.= " AND (u.entity IN (0,".$conf->entity.")";
$sql.= " AND rd.entity = ".$conf->entity.")";
$sql.= " AND ur.fk_id = rd.id";
$sql.= " AND module = 'fournisseur'";
$sql.= " AND perms = 'commande'";
$sql.= " AND subperms = 'approuver'";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u,";
$sql .= " ".MAIN_DB_PREFIX."user_rights as ur";
$sql .= ", ".MAIN_DB_PREFIX."rights_def as rd";
$sql .= " WHERE u.rowid = ur.fk_user";
$sql .= " AND (u.entity IN (0,".$conf->entity.")";
$sql .= " AND rd.entity = ".$conf->entity.")";
$sql .= " AND ur.fk_id = rd.id";
$sql .= " AND module = 'fournisseur'";
$sql .= " AND perms = 'commande'";
$sql .= " AND subperms = 'approuver'";
$resql = $db->query($sql);
if ($resql)
@ -283,10 +283,10 @@ if ($resql)
print '<tr class="oddeven">';
print '<td>';
$userstatic->id=$obj->rowid;
$userstatic->lastname=$obj->lastname;
$userstatic->firstname=$obj->firstname;
$userstatic->email=$obj->email;
$userstatic->id = $obj->rowid;
$userstatic->lastname = $obj->lastname;
$userstatic->firstname = $obj->firstname;
$userstatic->email = $obj->email;
print $userstatic->getNomUrl(1);
print '</td>';
print "</tr>\n";
@ -307,21 +307,21 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
/*
* Last modified orders
*/
$max=5;
$max = 5;
$sql = "SELECT c.rowid, c.ref, c.fk_statut, c.tms, s.nom as name, s.rowid as socid";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.rowid";
$sql.= " AND c.entity = ".$conf->entity;
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE c.fk_soc = s.rowid";
$sql .= " AND c.entity = ".$conf->entity;
//$sql.= " AND c.fk_statut > 2";
if (! empty($socid)) $sql .= " AND c.fk_soc = ".$socid;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " ORDER BY c.tms DESC";
$sql.= $db->plimit($max, 0);
if (!empty($socid)) $sql .= " AND c.fk_soc = ".$socid;
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
$sql .= " ORDER BY c.tms DESC";
$sql .= $db->plimit($max, 0);
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
print '<div class="div-table-responsive-no-min">';
@ -340,8 +340,8 @@ if ($resql)
print '<tr class="oddeven">';
print '<td width="20%" class="nowrap">';
$commandestatic->id=$obj->rowid;
$commandestatic->ref=$obj->ref;
$commandestatic->id = $obj->rowid;
$commandestatic->ref = $obj->ref;
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td width="96" class="nobordernopadding nowrap">';
@ -353,9 +353,9 @@ if ($resql)
print '</td>';
print '<td width="16" class="right nobordernopadding hideonsmartphone">';
$filename=dol_sanitizeFileName($obj->ref);
$filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
$filename = dol_sanitizeFileName($obj->ref);
$filedir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
print '</td></tr></table>';

View File

@ -48,9 +48,9 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="p.name";
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "p.name";
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
/*
@ -58,14 +58,14 @@ $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
*/
$sql = "SELECT s.rowid as socid, s.nom as name, st.libelle as stcomm, p.rowid as cidp, p.lastname, p.firstname, p.email, p.phone";
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."socpeople as p, ".MAIN_DB_PREFIX."c_stcomm as st";
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.fk_stcomm = st.id";
$sql.= " AND s.fournisseur = 1";
$sql.= " AND s.rowid = p.fk_soc";
$sql.= " AND s.entity IN (".getEntity('societe').")";
if (! $user->rights->societe->client->voir && ! $socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."socpeople as p, ".MAIN_DB_PREFIX."c_stcomm as st";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE s.fk_stcomm = st.id";
$sql .= " AND s.fournisseur = 1";
$sql .= " AND s.rowid = p.fk_soc";
$sql .= " AND s.entity IN (".getEntity('societe').")";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if (dol_strlen($stcomm)) {
$sql .= " AND s.fk_stcomm=$stcomm";
@ -93,7 +93,7 @@ if ($result)
{
$num = $db->num_rows($result);
$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses"));
$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses"));
print_barre_liste($title." (".$langs->trans("Suppliers").")", $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num);
print '<table class="liste centpercent">';

View File

@ -40,14 +40,14 @@ if ($user->socid > 0)
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('supplierbalencelist','globalcard'));
$hookmanager->initHooks(array('supplierbalencelist', 'globalcard'));
/*
* View
*/
$form = new Form($db);
$userstatic=new User($db);
$userstatic = new User($db);
llxHeader();
@ -62,10 +62,10 @@ if ($socid > 0)
$head = societe_prepare_head($societe);
dol_fiche_head($head, 'supplier', $langs->trans("ThirdParty"), 0, 'company');
dol_banner_tab($societe, 'socid', '', ($user->socid?0:1), 'rowid', 'nom');
dol_banner_tab($societe, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom');
dol_fiche_end();
if (! empty($conf->fournisseur->enabled) && $user->rights->facture->lire)
if (!empty($conf->fournisseur->enabled) && $user->rights->facture->lire)
{
// Invoice list
print load_fiche_titre($langs->trans("SupplierPreview"));
@ -73,15 +73,15 @@ if ($socid > 0)
print '<table class="noborder tagtable liste centpercent">';
$sql = "SELECT s.nom, s.rowid as socid, f.ref_supplier, f.amount, f.datef as df,";
$sql.= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,";
$sql.= " u.login, u.rowid as userid";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$societe->id;
$sql.= " AND f.entity IN (".getEntity("facture_fourn").")"; // Reconaissance de l'entité attribuée à cette facture pour Multicompany
$sql.= " AND f.fk_user_valid = u.rowid";
$sql.= " ORDER BY f.datef DESC";
$sql .= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,";
$sql .= " u.login, u.rowid as userid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$societe->id;
$sql .= " AND f.entity IN (".getEntity("facture_fourn").")"; // Reconaissance de l'entité attribuée à cette facture pour Multicompany
$sql .= " AND f.fk_user_valid = u.rowid";
$sql .= " ORDER BY f.datef DESC";
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
@ -96,7 +96,7 @@ if ($socid > 0)
print '<td>&nbsp;</td>';
print '</tr>';
if (! $num > 0)
if (!$num > 0)
{
print '<tr><td colspan="7">'.$langs->trans("NoInvoice").'</td></tr>';
}
@ -104,12 +104,12 @@ if ($socid > 0)
$solde = 0;
// Boucle sur chaque facture
for ($i = 0 ; $i < $num ; $i++)
for ($i = 0; $i < $num; $i++)
{
$objf = $db->fetch_object($resql);
$fac = new FactureFournisseur($db);
$ret=$fac->fetch($objf->facid);
$ret = $fac->fetch($objf->facid);
if ($ret < 0)
{
print $fac->error."<br>";
@ -136,12 +136,12 @@ if ($socid > 0)
// Payments
$sql = "SELECT p.rowid, p.datep as dp, pf.amount, p.statut,";
$sql.= " p.fk_user_author, u.login, u.rowid as userid";
$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
$sql.= " ".MAIN_DB_PREFIX."paiementfourn as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON p.fk_user_author = u.rowid";
$sql.= " WHERE pf.fk_paiementfourn = p.rowid";
$sql.= " AND pf.fk_facturefourn = ".$fac->id;
$sql .= " p.fk_user_author, u.login, u.rowid as userid";
$sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
$sql .= " ".MAIN_DB_PREFIX."paiementfourn as p";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON p.fk_user_author = u.rowid";
$sql .= " WHERE pf.fk_paiementfourn = p.rowid";
$sql .= " AND pf.fk_facturefourn = ".$fac->id;
$resqlp = $db->query($sql);
if ($resqlp)

View File

@ -35,12 +35,12 @@ $object = new Loan($db);
$object->fetch($loanid);
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","loan"));
$langs->loadLangs(array("compta", "bills", "loan"));
if ($action == 'createecheancier') {
$i=1;
while($i <$object->nbterm+1){
$date = GETPOST('hi_date'.$i, 'int');
$i = 1;
while ($i < $object->nbterm + 1) {
$date = GETPOST('hi_date'.$i, 'int');
$mens = GETPOST('mens'.$i);
$int = GETPOST('hi_interets'.$i);
$insurance = GETPOST('hi_insurance'.$i);
@ -51,15 +51,15 @@ if ($action == 'createecheancier') {
$echeance->datec = dol_now();
$echeance->tms = dol_now();
$echeance->datep = $date;
$echeance->amount_capital = $mens-$int;
$echeance->amount_capital = $mens - $int;
$echeance->amount_insurance = $insurance;
$echeance->amount_interest = $int;
$echeance->fk_typepayment = 3;
$echeance->fk_bank = 0;
$echeance->fk_user_creat = $user->id;
$echeance->fk_user_modif = $user->id;
$result=$echeance->create($user);
if ($result<0) {
$result = $echeance->create($user);
if ($result < 0) {
setEventMessages($echeance->error, $echeance->errors, 'errors');
}
$i++;
@ -67,8 +67,8 @@ if ($action == 'createecheancier') {
}
if ($action == 'updateecheancier') {
$i=1;
while($i <$object->nbterm+1){
$i = 1;
while ($i < $object->nbterm + 1) {
$mens = GETPOST('mens'.$i);
$int = GETPOST('hi_interets'.$i);
$id = GETPOST('hi_rowid'.$i);
@ -77,12 +77,12 @@ if ($action == 'updateecheancier') {
$echeance = new LoanSchedule($db);
$echeance->fetch($id);
$echeance->tms = dol_now();
$echeance->amount_capital = $mens-$int;
$echeance->amount_capital = $mens - $int;
$echeance->amount_insurance = $insurance;
$echeance->amount_interest = $int;
$echeance->fk_user_modif = $user->id;
$result= $echeance->update($user, 0);
if ($result<0) {
$result = $echeance->update($user, 0);
if ($result < 0) {
setEventMessages(null, $echeance->errors, 'errors');
}
$i++;
@ -93,7 +93,7 @@ $echeance = new LoanSchedule($db);
$echeance->fetchAll($object->id);
top_htmlhead('', '');
$var = ! $var;
$var = !$var;
?>
@ -109,7 +109,7 @@ $(document).ready(function() {
$.ajax({
dataType: 'json',
url: 'calcmens.php',
data: { echeance: echeance, mens: mens, capital:capital, rate:<?php echo $object->rate/100;?> , nbterm : <?php echo $object->nbterm;?>},
data: { echeance: echeance, mens: mens, capital:capital, rate:<?php echo $object->rate / 100; ?> , nbterm : <?php echo $object->nbterm; ?>},
success: function(data) {
$.each(data, function(index, element) {
var idcap_res='#hi_capital'+index;
@ -131,19 +131,19 @@ $(document).ready(function() {
<?php
print '<form name="createecheancier" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="loanid" value="' . $loanid . '">';
if(count($echeance->lines)>0)
print '<form name="createecheancier" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="loanid" value="'.$loanid.'">';
if (count($echeance->lines) > 0)
{
print '<input type="hidden" name="action" value="updateecheancier">';
}else{
} else {
print '<input type="hidden" name="action" value="createecheancier">';
}
print '<table class="border centpercent">';
print '<tr class="liste_titre">';
$colspan = 6;
if (count($echeance->lines)>0) $colspan++;
if (count($echeance->lines) > 0) $colspan++;
print '<th class="center" colspan="'.$colspan.'">';
print $langs->trans("FinancialCommitment");
print '</th>';
@ -159,57 +159,57 @@ print '<th width="40%" class="center">'.$langs->trans("CapitalRemain");
print ' ('.price2num($object->capital).')';
print '<input type="hidden" name="hi_capital0" id ="hi_capital0" value="'.$object->capital.'">';
print '</th>';
if (count($echeance->lines)>0) print '<th>'.$langs->trans('DoPayment').'</th>';
if (count($echeance->lines) > 0) print '<th>'.$langs->trans('DoPayment').'</th>';
print '</tr>'."\n";
if ($object->nbterm > 0 && count($echeance->lines)==0)
if ($object->nbterm > 0 && count($echeance->lines) == 0)
{
$i=1;
$i = 1;
$capital = $object->capital;
$insurance = $object->insurance_amount/$object->nbterm;
$insurance = $object->insurance_amount / $object->nbterm;
$insurance = price2num($insurance, 'MT');
$regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm));
while($i <$object->nbterm+1)
while ($i < $object->nbterm + 1)
{
$mens = price2num($echeance->calcMonthlyPayments($capital, $object->rate/100, $object->nbterm-$i+1), 'MT');
$int = ($capital*($object->rate/12))/100;
$mens = price2num($echeance->calcMonthlyPayments($capital, $object->rate / 100, $object->nbterm - $i + 1), 'MT');
$int = ($capital * ($object->rate / 12)) / 100;
$int = price2num($int, 'MT');
$cap_rest = price2num($capital - ($mens-$int), 'MT');
$cap_rest = price2num($capital - ($mens - $int), 'MT');
print '<tr>';
print '<td class="center" id="n'.$i.'">' . $i .'</td>';
print '<td class="center" id ="date' .$i .'"><input type="hidden" name="hi_date' .$i .'" id ="hi_date' .$i .'" value="' . dol_time_plus_duree($object->datestart, $i-1, 'm') . '">' . dol_print_date(dol_time_plus_duree($object->datestart, $i-1, 'm'), 'day') . '</td>';
print '<td class="center" id="insurance'.$i.'">'.price($insurance+(($i == 1) ? $regulInsurance : 0), 0, '', 1).' €</td><input type="hidden" name="hi_insurance' .$i .'" id ="hi_insurance' .$i .'" value="' . ($insurance+(($i == 1) ? $regulInsurance : 0)) . '">';
print '<td class="center" id="interets'.$i.'">'.price($int, 0, '', 1).' €</td><input type="hidden" name="hi_interets' .$i .'" id ="hi_interets' .$i .'" value="' . $int . '">';
print '<td class="center" id="n'.$i.'">'.$i.'</td>';
print '<td class="center" id ="date'.$i.'"><input type="hidden" name="hi_date'.$i.'" id ="hi_date'.$i.'" value="'.dol_time_plus_duree($object->datestart, $i - 1, 'm').'">'.dol_print_date(dol_time_plus_duree($object->datestart, $i - 1, 'm'), 'day').'</td>';
print '<td class="center" id="insurance'.$i.'">'.price($insurance + (($i == 1) ? $regulInsurance : 0), 0, '', 1).' €</td><input type="hidden" name="hi_insurance'.$i.'" id ="hi_insurance'.$i.'" value="'.($insurance + (($i == 1) ? $regulInsurance : 0)).'">';
print '<td class="center" id="interets'.$i.'">'.price($int, 0, '', 1).' €</td><input type="hidden" name="hi_interets'.$i.'" id ="hi_interets'.$i.'" value="'.$int.'">';
print '<td class="center"><input name="mens'.$i.'" id="mens'.$i.'" size="5" value="'.$mens.'" ech="'.$i.'"> €</td>';
print '<td class="center" id="capital'.$i.'">'.price($cap_rest).' €</td><input type="hidden" name="hi_capital' .$i .'" id ="hi_capital' .$i .'" value="' . $cap_rest . '">';
print '<td class="center" id="capital'.$i.'">'.price($cap_rest).' €</td><input type="hidden" name="hi_capital'.$i.'" id ="hi_capital'.$i.'" value="'.$cap_rest.'">';
print '</tr>'."\n";
$i++;
$capital = $cap_rest;
}
}
elseif(count($echeance->lines)>0)
elseif (count($echeance->lines) > 0)
{
$i=1;
$i = 1;
$capital = $object->capital;
$insurance = $object->insurance_amount/$object->nbterm;
$insurance = $object->insurance_amount / $object->nbterm;
$insurance = price2num($insurance, 'MT');
$regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm));
foreach ($echeance->lines as $line){
$mens = $line->amount_capital+$line->amount_insurance+$line->amount_interest;
foreach ($echeance->lines as $line) {
$mens = $line->amount_capital + $line->amount_insurance + $line->amount_interest;
$int = $line->amount_interest;
$cap_rest = price2num($capital - ($mens-$int), 'MT');
$cap_rest = price2num($capital - ($mens - $int), 'MT');
print '<tr>';
print '<td class="center" id="n'.$i.'"><input type="hidden" name="hi_rowid' .$i .'" id ="hi_rowid' .$i .'" value="' . $line->id . '">' . $i .'</td>';
print '<td class="center" id ="date' .$i .'"><input type="hidden" name="hi_date' .$i .'" id ="hi_date' .$i .'" value="' . $line->datep . '">' . dol_print_date($line->datep, 'day') . '</td>';
print '<td class="center" id="insurance'.$i.'">'.price($insurance+(($i == 1) ? $regulInsurance : 0), 0, '', 1).' €</td><input type="hidden" name="hi_insurance' .$i .'" id ="hi_insurance' .$i .'" value="' . ($insurance+(($i == 1) ? $regulInsurance : 0)) . '">';
print '<td class="center" id="interets'.$i.'">'.price($int, 0, '', 1).' €</td><input type="hidden" name="hi_interets' .$i .'" id ="hi_interets' .$i .'" value="' . $int . '">';
if($line->datep > dol_now()){
print '<td class="center" id="n'.$i.'"><input type="hidden" name="hi_rowid'.$i.'" id ="hi_rowid'.$i.'" value="'.$line->id.'">'.$i.'</td>';
print '<td class="center" id ="date'.$i.'"><input type="hidden" name="hi_date'.$i.'" id ="hi_date'.$i.'" value="'.$line->datep.'">'.dol_print_date($line->datep, 'day').'</td>';
print '<td class="center" id="insurance'.$i.'">'.price($insurance + (($i == 1) ? $regulInsurance : 0), 0, '', 1).' €</td><input type="hidden" name="hi_insurance'.$i.'" id ="hi_insurance'.$i.'" value="'.($insurance + (($i == 1) ? $regulInsurance : 0)).'">';
print '<td class="center" id="interets'.$i.'">'.price($int, 0, '', 1).' €</td><input type="hidden" name="hi_interets'.$i.'" id ="hi_interets'.$i.'" value="'.$int.'">';
if ($line->datep > dol_now()) {
print '<td class="center"><input name="mens'.$i.'" id="mens'.$i.'" size="5" value="'.$mens.'" ech="'.$i.'"> €</td>';
}else{
print '<td class="center">' . price($mens) . ' €</td><input type="hidden" name="mens' .$i .'" id ="mens' .$i .'" value="' . $mens . '">';
} else {
print '<td class="center">'.price($mens).' €</td><input type="hidden" name="mens'.$i.'" id ="mens'.$i.'" value="'.$mens.'">';
}
print '<td class="center" id="capital'.$i.'">'.price($cap_rest).' €</td><input type="hidden" name="hi_capital' .$i .'" id ="hi_capital' .$i .'" value="' . $cap_rest . '">';
print '<td class="center" id="capital'.$i.'">'.price($cap_rest).' €</td><input type="hidden" name="hi_capital'.$i.'" id ="hi_capital'.$i.'" value="'.$cap_rest.'">';
print '<td class="center"><a class="butAction" href="'.DOL_URL_ROOT.'/loan/payment/payment.php?id='.$object->id.'&amp;action=create">'.$langs->trans('DoPayment').'</a></td>';
print '</tr>'."\n";
$i++;

View File

@ -35,19 +35,19 @@ $object = new Loan($db);
$object->fetch($loanid);
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","loan"));
$langs->loadLangs(array("compta", "bills", "loan"));
$title = $langs->trans("Loan") . ' - ' . $langs->trans("Card");
$title = $langs->trans("Loan").' - '.$langs->trans("Card");
$help_url = 'EN:Module_Loan|FR:Module_Emprunt';
llxHeader("", $title, $help_url);
$head=loan_prepare_head($object);
$head = loan_prepare_head($object);
dol_fiche_head($head, 'FinancialCommitment', $langs->trans("Loan"), -1, 'bill');
if ($action == 'createecheancier') {
$i=1;
while($i <$object->nbterm+1){
$date = GETPOST('hi_date'.$i, 'int');
$i = 1;
while ($i < $object->nbterm + 1) {
$date = GETPOST('hi_date'.$i, 'int');
$mens = GETPOST('mens'.$i);
$int = GETPOST('hi_interets'.$i);
$insurance = GETPOST('hi_insurance'.$i);
@ -58,15 +58,15 @@ if ($action == 'createecheancier') {
$echeance->datec = dol_now();
$echeance->tms = dol_now();
$echeance->datep = $date;
$echeance->amount_capital = $mens-$int;
$echeance->amount_capital = $mens - $int;
$echeance->amount_insurance = $insurance;
$echeance->amount_interest = $int;
$echeance->fk_typepayment = 3;
$echeance->fk_bank = 0;
$echeance->fk_user_creat = $user->id;
$echeance->fk_user_modif = $user->id;
$result=$echeance->create($user);
if ($result<0) {
$result = $echeance->create($user);
if ($result < 0) {
setEventMessages($echeance->error, $echeance->errors, 'errors');
}
$i++;
@ -74,8 +74,8 @@ if ($action == 'createecheancier') {
}
if ($action == 'updateecheancier') {
$i=1;
while($i <$object->nbterm+1){
$i = 1;
while ($i < $object->nbterm + 1) {
$mens = GETPOST('mens'.$i);
$int = GETPOST('hi_interets'.$i);
$id = GETPOST('hi_rowid'.$i);
@ -84,12 +84,12 @@ if ($action == 'updateecheancier') {
$echeance = new LoanSchedule($db);
$echeance->fetch($id);
$echeance->tms = dol_now();
$echeance->amount_capital = $mens-$int;
$echeance->amount_capital = $mens - $int;
$echeance->amount_insurance = $insurance;
$echeance->amount_interest = $int;
$echeance->fk_user_modif = $user->id;
$result= $echeance->update($user, 0);
if ($result<0) {
$result = $echeance->update($user, 0);
if ($result < 0) {
setEventMessages(null, $echeance->errors, 'errors');
}
$i++;
@ -99,7 +99,7 @@ if ($action == 'updateecheancier') {
$echeance = new LoanSchedule($db);
$echeance->fetchAll($object->id);
$var = ! $var;
$var = !$var;
?>
@ -115,7 +115,7 @@ $(document).ready(function() {
$.ajax({
dataType: 'json',
url: 'calcmens.php',
data: { echeance: echeance, mens: mens, capital:capital, rate:<?php echo $object->rate/100;?> , nbterm : <?php echo $object->nbterm;?>},
data: { echeance: echeance, mens: mens, capital:capital, rate:<?php echo $object->rate / 100; ?> , nbterm : <?php echo $object->nbterm; ?>},
success: function(data) {
$.each(data, function(index, element) {
var idcap_res='#hi_capital'+index;
@ -137,19 +137,19 @@ $(document).ready(function() {
<?php
print '<form name="createecheancier" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="loanid" value="' . $loanid . '">';
if(count($echeance->lines)>0)
print '<form name="createecheancier" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="loanid" value="'.$loanid.'">';
if (count($echeance->lines) > 0)
{
print '<input type="hidden" name="action" value="updateecheancier">';
}else{
} else {
print '<input type="hidden" name="action" value="createecheancier">';
}
print '<table class="border centpercent">';
print '<tr class="liste_titre">';
$colspan = 6;
if (count($echeance->lines)>0) $colspan++;
if (count($echeance->lines) > 0) $colspan++;
print '<th class="center" colspan="'.$colspan.'">';
print $langs->trans("FinancialCommitment");
print '</th>';
@ -165,61 +165,61 @@ print '<th width="40%" class="center">'.$langs->trans("CapitalRemain");
print ' ('.price2num($object->capital).')';
print '<input type="hidden" name="hi_capital0" id ="hi_capital0" value="'.$object->capital.'">';
print '</th>';
if (count($echeance->lines)>0) print '<th>'.$langs->trans('DoPayment').'</th>';
if (count($echeance->lines) > 0) print '<th>'.$langs->trans('DoPayment').'</th>';
print '</tr>'."\n";
if ($object->nbterm > 0 && count($echeance->lines)==0)
if ($object->nbterm > 0 && count($echeance->lines) == 0)
{
$i=1;
$i = 1;
$capital = $object->capital;
$insurance = $object->insurance_amount/$object->nbterm;
$insurance = $object->insurance_amount / $object->nbterm;
$insurance = price2num($insurance, 'MT');
$regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm));
while($i <$object->nbterm+1)
while ($i < $object->nbterm + 1)
{
$mens = price2num($echeance->calcMonthlyPayments($capital, $object->rate/100, $object->nbterm-$i+1), 'MT');
$int = ($capital*($object->rate/12))/100;
$mens = price2num($echeance->calcMonthlyPayments($capital, $object->rate / 100, $object->nbterm - $i + 1), 'MT');
$int = ($capital * ($object->rate / 12)) / 100;
$int = price2num($int, 'MT');
$insu = ($insurance+(($i == 1) ? $regulInsurance : 0));
$cap_rest = price2num($capital - ($mens-$int), 'MT');
$insu = ($insurance + (($i == 1) ? $regulInsurance : 0));
$cap_rest = price2num($capital - ($mens - $int), 'MT');
print '<tr>';
print '<td class="center" id="n'.$i.'">' . $i .'</td>';
print '<td class="center" id ="date' .$i .'"><input type="hidden" name="hi_date' .$i .'" id ="hi_date' .$i .'" value="' . dol_time_plus_duree($object->datestart, $i-1, 'm') . '">' . dol_print_date(dol_time_plus_duree($object->datestart, $i-1, 'm'), 'day') . '</td>';
print '<td class="center" id="insurance'.$i.'">'.price($insurance+(($i == 1) ? $regulInsurance : 0), 0, '', 1).' €</td><input type="hidden" name="hi_insurance' .$i .'" id ="hi_insurance' .$i .'" value="' . ($insurance+(($i == 1) ? $regulInsurance : 0)) . '">';
print '<td class="center" id="interets'.$i.'">'.price($int, 0, '', 1).' €</td><input type="hidden" name="hi_interets' .$i .'" id ="hi_interets' .$i .'" value="' . $int . '">';
print '<td class="center" id="n'.$i.'">'.$i.'</td>';
print '<td class="center" id ="date'.$i.'"><input type="hidden" name="hi_date'.$i.'" id ="hi_date'.$i.'" value="'.dol_time_plus_duree($object->datestart, $i - 1, 'm').'">'.dol_print_date(dol_time_plus_duree($object->datestart, $i - 1, 'm'), 'day').'</td>';
print '<td class="center" id="insurance'.$i.'">'.price($insurance + (($i == 1) ? $regulInsurance : 0), 0, '', 1).' €</td><input type="hidden" name="hi_insurance'.$i.'" id ="hi_insurance'.$i.'" value="'.($insurance + (($i == 1) ? $regulInsurance : 0)).'">';
print '<td class="center" id="interets'.$i.'">'.price($int, 0, '', 1).' €</td><input type="hidden" name="hi_interets'.$i.'" id ="hi_interets'.$i.'" value="'.$int.'">';
print '<td class="center"><input name="mens'.$i.'" id="mens'.$i.'" size="5" value="'.$mens.'" ech="'.$i.'"> €</td>';
print '<td class="center" id="capital'.$i.'">'.price($cap_rest).' €</td><input type="hidden" name="hi_capital' .$i .'" id ="hi_capital' .$i .'" value="' . $cap_rest . '">';
print '<td class="center" id="capital'.$i.'">'.price($cap_rest).' €</td><input type="hidden" name="hi_capital'.$i.'" id ="hi_capital'.$i.'" value="'.$cap_rest.'">';
print '</tr>'."\n";
$i++;
$capital = $cap_rest;
}
}
elseif(count($echeance->lines)>0)
elseif (count($echeance->lines) > 0)
{
$i=1;
$i = 1;
$capital = $object->capital;
$insurance = $object->insurance_amount/$object->nbterm;
$insurance = $object->insurance_amount / $object->nbterm;
$insurance = price2num($insurance, 'MT');
$regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm));
$printed = false;
foreach ($echeance->lines as $line){
$mens = $line->amount_capital+$line->amount_interest;
foreach ($echeance->lines as $line) {
$mens = $line->amount_capital + $line->amount_interest;
$int = $line->amount_interest;
$insu = ($insurance+(($i == 1) ? $regulInsurance : 0));
$cap_rest = price2num($capital - ($mens-$int), 'MT');
$insu = ($insurance + (($i == 1) ? $regulInsurance : 0));
$cap_rest = price2num($capital - ($mens - $int), 'MT');
print '<tr>';
print '<td class="center" id="n'.$i.'"><input type="hidden" name="hi_rowid' .$i .'" id ="hi_rowid' .$i .'" value="' . $line->id . '">' . $i .'</td>';
print '<td class="center" id ="date' .$i .'"><input type="hidden" name="hi_date' .$i .'" id ="hi_date' .$i .'" value="' . $line->datep . '">' . dol_print_date($line->datep, 'day') . '</td>';
print '<td class="center" id="insurance'.$i.'">'.price($insu, 0, '', 1).' €</td><input type="hidden" name="hi_insurance' .$i .'" id ="hi_insurance' .$i .'" value="' . $insu . '">';
print '<td class="center" id="interets'.$i.'">'.price($int, 0, '', 1).' €</td><input type="hidden" name="hi_interets' .$i .'" id ="hi_interets' .$i .'" value="' . $int . '">';
if($line->datep > dol_now() && empty($line->fk_bank)){
print '<td class="center" id="n'.$i.'"><input type="hidden" name="hi_rowid'.$i.'" id ="hi_rowid'.$i.'" value="'.$line->id.'">'.$i.'</td>';
print '<td class="center" id ="date'.$i.'"><input type="hidden" name="hi_date'.$i.'" id ="hi_date'.$i.'" value="'.$line->datep.'">'.dol_print_date($line->datep, 'day').'</td>';
print '<td class="center" id="insurance'.$i.'">'.price($insu, 0, '', 1).' €</td><input type="hidden" name="hi_insurance'.$i.'" id ="hi_insurance'.$i.'" value="'.$insu.'">';
print '<td class="center" id="interets'.$i.'">'.price($int, 0, '', 1).' €</td><input type="hidden" name="hi_interets'.$i.'" id ="hi_interets'.$i.'" value="'.$int.'">';
if ($line->datep > dol_now() && empty($line->fk_bank)) {
print '<td class="center"><input name="mens'.$i.'" id="mens'.$i.'" size="5" value="'.$mens.'" ech="'.$i.'"> €</td>';
}else{
print '<td class="center">' . price($mens) . ' €</td><input type="hidden" name="mens' .$i .'" id ="mens' .$i .'" value="' . $mens . '">';
} else {
print '<td class="center">'.price($mens).' €</td><input type="hidden" name="mens'.$i.'" id ="mens'.$i.'" value="'.$mens.'">';
}
print '<td class="center" id="capital'.$i.'">'.price($cap_rest).' €</td><input type="hidden" name="hi_capital' .$i .'" id ="hi_capital' .$i .'" value="' . $cap_rest . '">';
print '<td class="center" id="capital'.$i.'">'.price($cap_rest).' €</td><input type="hidden" name="hi_capital'.$i.'" id ="hi_capital'.$i.'" value="'.$cap_rest.'">';
print '<td class="center">';
if (!empty($line->fk_bank)) print $langs->trans('Paid');
elseif (!$printed)
@ -237,7 +237,7 @@ elseif(count($echeance->lines)>0)
print '</table>';
print '</br>';
print '</br>';
if (count($echeance->lines)==0) $label = $langs->trans("Create");
if (count($echeance->lines) == 0) $label = $langs->trans("Create");
else $label = $langs->trans("Save");
print '<div class="center"><input class="button" type="submit" value="'.$label.'"></div>';
print '</form>';

View File

@ -33,17 +33,17 @@ use OAuth\Common\Storage\DoliStorage;
// Load translation files required by the page
$langs->loadLangs(array('admin', 'printing', 'oauth'));
if (! $user->admin) accessforbidden();
if (!$user->admin) accessforbidden();
$action = GETPOST('action', 'alpha');
$mode = GETPOST('mode', 'alpha');
$value = GETPOST('value', 'alpha', 0, null, null, 1); // The value may be __google__docs so we force disable of replace
$value = GETPOST('value', 'alpha', 0, null, null, 1); // The value may be __google__docs so we force disable of replace
$varname = GETPOST('varname', 'alpha');
$driver = GETPOST('driver', 'alpha');
if (! empty($driver)) $langs->load($driver);
if (!empty($driver)) $langs->load($driver);
if (!$mode) $mode='config';
if (!$mode) $mode = 'config';
$OAUTH_SERVICENAME_GOOGLE = 'Google';
@ -61,15 +61,15 @@ if (($mode == 'test' || $mode == 'setup') && empty($driver))
if ($action == 'setconst' && $user->admin)
{
$error=0;
$error = 0;
$db->begin();
foreach ($_POST['setupdriver'] as $setupconst) {
//print '<pre>'.print_r($setupconst, true).'</pre>';
$result=dolibarr_set_const($db, $setupconst['varname'], $setupconst['value'], 'chaine', 0, '', $conf->entity);
if (! $result > 0) $error++;
$result = dolibarr_set_const($db, $setupconst['varname'], $setupconst['value'], 'chaine', 0, '', $conf->entity);
if (!$result > 0) $error++;
}
if (! $error)
if (!$error)
{
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null);
@ -79,17 +79,17 @@ if ($action == 'setconst' && $user->admin)
$db->rollback();
dol_print_error($db);
}
$action='';
$action = '';
}
if ($action == 'setvalue' && $user->admin)
{
$db->begin();
$result=dolibarr_set_const($db, $varname, $value, 'chaine', 0, '', $conf->entity);
if (! $result > 0) $error++;
$result = dolibarr_set_const($db, $varname, $value, 'chaine', 0, '', $conf->entity);
if (!$result > 0) $error++;
if (! $error)
if (!$error)
{
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null);
@ -111,7 +111,7 @@ $form = new Form($db);
llxHeader('', $langs->trans("PrintingSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("PrintingSetup"), $linkback, 'title_setup');
$head = printingAdminPrepareHead($mode);
@ -132,32 +132,32 @@ if ($mode == 'setup' && $user->admin)
print '<th>'.$langs->trans("Value").'</th>';
print '<th>&nbsp;</th>';
print "</tr>\n";
$submit_enabled=0;
$submit_enabled = 0;
if (! empty($driver)) {
if (!empty($driver)) {
require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php';
$classname = 'printing_'.$driver;
$langs->load($driver);
$printer = new $classname($db);
$i=0;
$submit_enabled=0;
$i = 0;
$submit_enabled = 0;
foreach ($printer->conf as $key)
{
switch ($key['type']) {
case "text":
case "password":
print '<tr class="oddeven">';
print '<td'.($key['required']?' class=required':'').'>'.$langs->trans($key['varname']).'</td>';
print '<td><input size="32" type="'.(empty($key['type'])?'text':$key['type']).'" name="setupdriver['.$i.'][value]" value="'.$conf->global->{$key['varname']}.'"';
print isset($key['moreattributes'])?' '.$key['moreattributes']:'';
print '<td'.($key['required'] ? ' class=required' : '').'>'.$langs->trans($key['varname']).'</td>';
print '<td><input size="32" type="'.(empty($key['type']) ? 'text' : $key['type']).'" name="setupdriver['.$i.'][value]" value="'.$conf->global->{$key['varname']}.'"';
print isset($key['moreattributes']) ? ' '.$key['moreattributes'] : '';
print '><input type="hidden" name="setupdriver['.$i.'][varname]" value="'.$key['varname'].'"></td>';
print '<td>&nbsp;'.($key['example']!=''?$langs->trans("Example").' : '.$key['example']:'').'</td>';
print '<td>&nbsp;'.($key['example'] != '' ? $langs->trans("Example").' : '.$key['example'] : '').'</td>';
print '</tr>'."\n";
break;
case "info": // Google Api setup or Google OAuth Token
print '<tr class="oddeven">';
print '<td'.($key['required']?' class=required':'').'>';
print '<td'.($key['required'] ? ' class=required' : '').'>';
if ($key['varname'] == 'PRINTGCP_TOKEN_ACCESS')
{
print $langs->trans("IsTokenGenerated");
@ -173,7 +173,7 @@ if ($mode == 'setup' && $user->admin)
if ($key['varname'] == 'PRINTGCP_TOKEN_ACCESS')
{
// Delete remote tokens
if (! empty($key['delete'])) print '<a class="button" href="'.$key['delete'].'">'.$langs->trans('DeleteAccess').'</a><br><br>';
if (!empty($key['delete'])) print '<a class="button" href="'.$key['delete'].'">'.$langs->trans('DeleteAccess').'</a><br><br>';
// Request remote token
print '<a class="button" href="'.$key['renew'].'">'.$langs->trans('RequestAccess').'</a><br><br>';
// Check remote access
@ -183,7 +183,7 @@ if ($mode == 'setup' && $user->admin)
print '</tr>'."\n";
break;
case "submit":
if ($key['enabled']) $submit_enabled=1;
if ($key['enabled']) $submit_enabled = 1;
break;
}
$i++;
@ -194,14 +194,14 @@ if ($mode == 'setup' && $user->admin)
print '<tr class="oddeven">';
print '<td>'.$langs->trans("Token").'</td>';
print '<td colspan="2">';
$tokenobj=null;
$tokenobj = null;
// Dolibarr storage
$storage = new DoliStorage($db, $conf);
try
{
$tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME_GOOGLE);
}
catch(Exception $e)
catch (Exception $e)
{
// Return an error if token not found
}
@ -228,7 +228,7 @@ if ($mode == 'setup' && $user->admin)
dol_fiche_end();
if (! empty($driver))
if (!empty($driver))
{
if ($submit_enabled) {
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'"></div>';
@ -264,7 +264,7 @@ if ($mode == 'config' && $user->admin)
print '<tr class="oddeven">';
print '<td>'.img_picto('', $printer->picto).' '.$langs->trans($printer->desc).'</td>';
print '<td class="center">';
if (! empty($conf->use_javascript_ajax))
if (!empty($conf->use_javascript_ajax))
{
print ajax_constantonoff($printer->active);
}
@ -296,7 +296,7 @@ if ($mode == 'test' && $user->admin)
print $langs->trans('PrintTestDesc'.$driver)."<br><br>\n";
print '<table class="noborder centpercent">';
if (! empty($driver))
if (!empty($driver))
{
require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php';
$classname = 'printing_'.$driver;
@ -304,7 +304,7 @@ if ($mode == 'test' && $user->admin)
$printer = new $classname($db);
//print '<pre>'.print_r($printer, true).'</pre>';
if (count($printer->getlistAvailablePrinters())) {
if ($printer->listAvailablePrinters()==0) {
if ($printer->listAvailablePrinters() == 0) {
print $printer->resprint;
} else {
setEventMessages($printer->error, $printer->errors, 'errors');
@ -340,7 +340,7 @@ if ($mode == 'userconf' && $user->admin)
print "</tr>\n";
$sql = 'SELECT p.rowid, p.printer_name, p.printer_location, p.printer_id, p.copy, p.module, p.driver, p.userid, u.login FROM '.MAIN_DB_PREFIX.'printing as p, '.MAIN_DB_PREFIX.'user as u WHERE p.userid=u.rowid';
$resql = $db->query($sql);
while ($row=$db->fetch_array($resql)) {
while ($row = $db->fetch_array($resql)) {
print '<tr class="oddeven">';
print '<td>'.$row['login'].'</td>';
print '<td>'.$row['module'].'</td>';

File diff suppressed because it is too large Load Diff

View File

@ -33,14 +33,14 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php';
$type=GETPOST("type", 'int');
if ($type =='' && !$user->rights->produit->lire) $type='1'; // Force global page on service page only
if ($type =='' && !$user->rights->service->lire) $type='0'; // Force global page on product page only
$type = GETPOST("type", 'int');
if ($type == '' && !$user->rights->produit->lire) $type = '1'; // Force global page on service page only
if ($type == '' && !$user->rights->service->lire) $type = '0'; // Force global page on product page only
// Security check
if ($type=='0') $result=restrictedArea($user, 'produit');
elseif ($type=='1') $result=restrictedArea($user, 'service');
else $result=restrictedArea($user, 'produit|service');
if ($type == '0') $result = restrictedArea($user, 'produit');
elseif ($type == '1') $result = restrictedArea($user, 'service');
else $result = restrictedArea($user, 'produit|service');
// Load translation files required by the page
$langs->loadLangs(array('products', 'stocks'));
@ -57,38 +57,38 @@ $product_static = new Product($db);
$transAreaType = $langs->trans("ProductsAndServicesArea");
$helpurl='';
if (! isset($_GET["type"]))
$helpurl = '';
if (!isset($_GET["type"]))
{
$transAreaType = $langs->trans("ProductsAndServicesArea");
$helpurl='EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
$helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
}
if ((isset($_GET["type"]) && $_GET["type"] == 0) || empty($conf->service->enabled))
{
$transAreaType = $langs->trans("ProductsArea");
$helpurl='EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
$helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
}
if ((isset($_GET["type"]) && $_GET["type"] == 1) || empty($conf->product->enabled))
{
$transAreaType = $langs->trans("ServicesArea");
$helpurl='EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
}
llxHeader("", $langs->trans("ProductsAndServices"), $helpurl);
$linkback="";
$linkback = "";
print load_fiche_titre($transAreaType, $linkback, 'products');
print '<div class="fichecenter"><div class="fichethirdleft">';
if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
{
// Search contract
if ((! empty($conf->product->enabled) || ! empty($conf->service->enabled)) && ($user->rights->produit->lire || $user->rights->service->lire))
if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($user->rights->produit->lire || $user->rights->service->lire))
{
$listofsearchfields['search_product']=array('text'=>'ProductOrService');
$listofsearchfields['search_product'] = array('text'=>'ProductOrService');
}
if (count($listofsearchfields))
@ -97,8 +97,8 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder nohover centpercent">';
$i=0;
foreach($listofsearchfields as $key => $value)
$i = 0;
foreach ($listofsearchfields as $key => $value)
{
if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
print '<tr '.$bc[false].'>';
@ -118,28 +118,28 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele
* Number of products and/or services
*/
$prodser = array();
$prodser[0][0]=$prodser[0][1]=$prodser[0][2]=$prodser[0][3]=0;
$prodser[1][0]=$prodser[1][1]=$prodser[1][2]=$prodser[1][3]=0;
$prodser[0][0] = $prodser[0][1] = $prodser[0][2] = $prodser[0][3] = 0;
$prodser[1][0] = $prodser[1][1] = $prodser[1][2] = $prodser[1][3] = 0;
$sql = "SELECT COUNT(p.rowid) as total, p.fk_product_type, p.tosell, p.tobuy";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
$sql.= ' WHERE p.entity IN ('.getEntity($product_static->element, 1).')';
$sql .= " FROM ".MAIN_DB_PREFIX."product as p";
$sql .= ' WHERE p.entity IN ('.getEntity($product_static->element, 1).')';
// Add where from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql.= " GROUP BY p.fk_product_type, p.tosell, p.tobuy";
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= " GROUP BY p.fk_product_type, p.tosell, p.tobuy";
$result = $db->query($sql);
while ($objp = $db->fetch_object($result))
{
$status=3; // On sale + On purchase
if (! $objp->tosell && ! $objp->tobuy) $status=0; // Not on sale, not on purchase
if ($objp->tosell && ! $objp->tobuy) $status=1; // On sale only
if (! $objp->tosell && $objp->tobuy) $status=2; // On purchase only
$prodser[$objp->fk_product_type][$status]=$objp->total;
if ($objp->tosell) $prodser[$objp->fk_product_type]['sell']+=$objp->total;
if ($objp->tobuy) $prodser[$objp->fk_product_type]['buy']+=$objp->total;
if (! $objp->tosell && ! $objp->tobuy) $prodser[$objp->fk_product_type]['none']+=$objp->total;
$status = 3; // On sale + On purchase
if (!$objp->tosell && !$objp->tobuy) $status = 0; // Not on sale, not on purchase
if ($objp->tosell && !$objp->tobuy) $status = 1; // On sale only
if (!$objp->tosell && $objp->tobuy) $status = 2; // On purchase only
$prodser[$objp->fk_product_type][$status] = $objp->total;
if ($objp->tosell) $prodser[$objp->fk_product_type]['sell'] += $objp->total;
if ($objp->tobuy) $prodser[$objp->fk_product_type]['buy'] += $objp->total;
if (!$objp->tosell && !$objp->tobuy) $prodser[$objp->fk_product_type]['none'] += $objp->total;
}
if ($conf->use_javascript_ajax)
@ -149,30 +149,30 @@ if ($conf->use_javascript_ajax)
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
print '<tr><td class="center" colspan="2">';
$SommeA=$prodser[0]['sell'];
$SommeB=$prodser[0]['buy'];
$SommeC=$prodser[0]['none'];
$SommeD=$prodser[1]['sell'];
$SommeE=$prodser[1]['buy'];
$SommeF=$prodser[1]['none'];
$total=0;
$dataval=array();
$datalabels=array();
$i=0;
$SommeA = $prodser[0]['sell'];
$SommeB = $prodser[0]['buy'];
$SommeC = $prodser[0]['none'];
$SommeD = $prodser[1]['sell'];
$SommeE = $prodser[1]['buy'];
$SommeF = $prodser[1]['none'];
$total = 0;
$dataval = array();
$datalabels = array();
$i = 0;
$total = $SommeA + $SommeB + $SommeC + $SommeD + $SommeE + $SommeF;
$dataseries=array();
if (! empty($conf->product->enabled))
$dataseries = array();
if (!empty($conf->product->enabled))
{
$dataseries[]=array($langs->trans("ProductsOnSale"), round($SommeA));
$dataseries[]=array($langs->trans("ProductsOnPurchase"), round($SommeB));
$dataseries[]=array($langs->trans("ProductsNotOnSell"), round($SommeC));
$dataseries[] = array($langs->trans("ProductsOnSale"), round($SommeA));
$dataseries[] = array($langs->trans("ProductsOnPurchase"), round($SommeB));
$dataseries[] = array($langs->trans("ProductsNotOnSell"), round($SommeC));
}
if (! empty($conf->service->enabled))
if (!empty($conf->service->enabled))
{
$dataseries[]=array($langs->trans("ServicesOnSale"), round($SommeD));
$dataseries[]=array($langs->trans("ServicesOnPurchase"), round($SommeE));
$dataseries[]=array($langs->trans("ServicesNotOnSell"), round($SommeF));
$dataseries[] = array($langs->trans("ServicesOnSale"), round($SommeD));
$dataseries[] = array($langs->trans("ServicesOnPurchase"), round($SommeE));
$dataseries[] = array($langs->trans("ServicesNotOnSell"), round($SommeF));
}
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
@ -183,7 +183,7 @@ if ($conf->use_javascript_ajax)
$dolgraph->SetType(array('pie'));
$dolgraph->setWidth('100%');
$dolgraph->draw('idgraphstatus');
print $dolgraph->show($total?0:1);
print $dolgraph->show($total ? 0 : 1);
print '</td></tr>';
print '</table>';
@ -191,7 +191,7 @@ if ($conf->use_javascript_ajax)
}
if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHSTATS_ON_PRODUCTS))
if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTATS_ON_PRODUCTS))
{
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
print '<br>';
@ -200,39 +200,39 @@ if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHS
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Categories").'</th></tr>';
print '<tr '.$bc[0].'><td class="center" colspan="2">';
$sql = "SELECT c.label, count(*) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."categorie_product as cs";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid";
$sql.= " WHERE c.type = 0";
$sql.= " AND c.entity IN (".getEntity('category').")";
$sql.= " GROUP BY c.label";
$total=0;
$sql .= " FROM ".MAIN_DB_PREFIX."categorie_product as cs";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid";
$sql .= " WHERE c.type = 0";
$sql .= " AND c.entity IN (".getEntity('category').")";
$sql .= " GROUP BY c.label";
$total = 0;
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i=0;
if (! empty($conf->use_javascript_ajax))
$i = 0;
if (!empty($conf->use_javascript_ajax))
{
$dataseries=array();
$rest=0;
$nbmax=10;
$dataseries = array();
$rest = 0;
$nbmax = 10;
while ($i < $num)
{
$obj = $db->fetch_object($result);
if ($i < $nbmax)
{
$dataseries[]=array($obj->label, round($obj->nb));
$dataseries[] = array($obj->label, round($obj->nb));
}
else
{
$rest+=$obj->nb;
$rest += $obj->nb;
}
$total+=$obj->nb;
$total += $obj->nb;
$i++;
}
if ($i > $nbmax)
{
$dataseries[]=array($langs->trans("Other"), round($rest));
$dataseries[] = array($langs->trans("Other"), round($rest));
}
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
@ -243,7 +243,7 @@ if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHS
$dolgraph->SetType(array('pie'));
$dolgraph->setWidth('100%');
$dolgraph->draw('idstatscategproduct');
print $dolgraph->show($total?0:1);
print $dolgraph->show($total ? 0 : 1);
}
else
{
@ -252,7 +252,7 @@ if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHS
$obj = $db->fetch_object($result);
print '<tr><td>'.$obj->label.'</td><td>'.$obj->nb.'</td></tr>';
$total+=$obj->nb;
$total += $obj->nb;
$i++;
}
}
@ -270,19 +270,19 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
/*
* Latest modified products
*/
$max=15;
$max = 15;
$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.tosell, p.tobuy, p.tobatch, p.fk_price_expression,";
$sql.= " p.entity,";
$sql.= " p.tms as datem";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
$sql.= " WHERE p.entity IN (".getEntity($product_static->element, 1).")";
if ($type != '') $sql.= " AND p.fk_product_type = ".$type;
$sql .= " p.entity,";
$sql .= " p.tms as datem";
$sql .= " FROM ".MAIN_DB_PREFIX."product as p";
$sql .= " WHERE p.entity IN (".getEntity($product_static->element, 1).")";
if ($type != '') $sql .= " AND p.fk_product_type = ".$type;
// Add where from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql.= $db->order("p.tms", "DESC");
$sql.= $db->plimit($max, 0);
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= $db->order("p.tms", "DESC");
$sql .= $db->plimit($max, 0);
//print $sql;
$result = $db->query($sql);
@ -301,7 +301,7 @@ if ($result)
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
$colnb=2;
$colnb = 2;
if (empty($conf->global->PRODUIT_MULTIPRICES)) $colnb++;
print '<tr class="liste_titre"><th colspan="'.$colnb.'">'.$transRecordedType.'</th>';
@ -313,12 +313,12 @@ if ($result)
$objp = $db->fetch_object($result);
//Multilangs
if (! empty($conf->global->MAIN_MULTILANGS))
if (!empty($conf->global->MAIN_MULTILANGS))
{
$sql = "SELECT label";
$sql.= " FROM ".MAIN_DB_PREFIX."product_lang";
$sql.= " WHERE fk_product=".$objp->rowid;
$sql.= " AND lang='". $langs->getDefaultLang() ."'";
$sql .= " FROM ".MAIN_DB_PREFIX."product_lang";
$sql .= " WHERE fk_product=".$objp->rowid;
$sql .= " AND lang='".$langs->getDefaultLang()."'";
$resultd = $db->query($sql);
if ($resultd)
@ -331,10 +331,10 @@ if ($result)
print '<tr class="oddeven">';
print '<td class="nowrap">';
$product_static->id=$objp->rowid;
$product_static->ref=$objp->ref;
$product_static->id = $objp->rowid;
$product_static->ref = $objp->ref;
$product_static->label = $objp->label;
$product_static->type=$objp->fk_product_type;
$product_static->type = $objp->fk_product_type;
$product_static->entity = $objp->entity;
$product_static->status_batch = $objp->tobatch;
print $product_static->getNomUrl(1, '', 16);
@ -387,10 +387,10 @@ else
// TODO Move this into a page that should be available into menu "accountancy - report - turnover - per quarter"
// Also method used for counting must provide the 2 possible methods like done by all other reports into menu "accountancy - report - turnover":
// "commitment engagment" method and "cash accounting" method
if (! empty($conf->global->MAIN_SHOW_PRODUCT_ACTIVITY_TRIM))
if (!empty($conf->global->MAIN_SHOW_PRODUCT_ACTIVITY_TRIM))
{
if (! empty($conf->product->enabled)) activitytrim(0);
if (! empty($conf->service->enabled)) activitytrim(1);
if (!empty($conf->product->enabled)) activitytrim(0);
if (!empty($conf->service->enabled)) activitytrim(1);
}
@ -412,42 +412,42 @@ $db->close();
*/
function activitytrim($product_type)
{
global $conf,$langs,$db;
global $conf, $langs, $db;
global $bc;
// We display the last 3 years
$yearofbegindate=date('Y', dol_time_plus_duree(time(), -3, "y"));
$yearofbegindate = date('Y', dol_time_plus_duree(time(), -3, "y"));
// breakdown by quarter
$sql = "SELECT DATE_FORMAT(p.datep,'%Y') as annee, DATE_FORMAT(p.datep,'%m') as mois, SUM(fd.total_ht) as Mnttot";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as fd";
$sql.= " , ".MAIN_DB_PREFIX."paiement as p,".MAIN_DB_PREFIX."paiement_facture as pf";
$sql.= " WHERE f.entity IN (".getEntity('invoice').")";
$sql.= " AND f.rowid = fd.fk_facture";
$sql.= " AND pf.fk_facture = f.rowid";
$sql.= " AND pf.fk_paiement= p.rowid";
$sql.= " AND fd.product_type=".$product_type;
$sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($yearofbegindate), 1)."'";
$sql.= " GROUP BY annee, mois ";
$sql.= " ORDER BY annee, mois ";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as fd";
$sql .= " , ".MAIN_DB_PREFIX."paiement as p,".MAIN_DB_PREFIX."paiement_facture as pf";
$sql .= " WHERE f.entity IN (".getEntity('invoice').")";
$sql .= " AND f.rowid = fd.fk_facture";
$sql .= " AND pf.fk_facture = f.rowid";
$sql .= " AND pf.fk_paiement= p.rowid";
$sql .= " AND fd.product_type=".$product_type;
$sql .= " AND p.datep >= '".$db->idate(dol_get_first_day($yearofbegindate), 1)."'";
$sql .= " GROUP BY annee, mois ";
$sql .= " ORDER BY annee, mois ";
$result = $db->query($sql);
if ($result)
{
$tmpyear=0;
$trim1=0;
$trim2=0;
$trim3=0;
$trim4=0;
$tmpyear = 0;
$trim1 = 0;
$trim2 = 0;
$trim3 = 0;
$trim4 = 0;
$lgn = 0;
$num = $db->num_rows($result);
if ($num > 0 )
if ($num > 0)
{
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="75%">';
if ($product_type==0)
if ($product_type == 0)
print '<tr class="liste_titre"><td class=left>'.$langs->trans("ProductSellByQuarterHT").'</td>';
else
print '<tr class="liste_titre"><td class=left>'.$langs->trans("ServiceSellByQuarterHT").'</td>';
@ -465,23 +465,23 @@ function activitytrim($product_type)
$objp = $db->fetch_object($result);
if ($tmpyear != $objp->annee)
{
if ($trim1+$trim2+$trim3+$trim4 > 0)
if ($trim1 + $trim2 + $trim3 + $trim4 > 0)
{
print '<tr class="oddeven"><td class=left>'.$tmpyear.'</td>';
print '<td class="nowrap right">'.price($trim1).'</td>';
print '<td class="nowrap right">'.price($trim2).'</td>';
print '<td class="nowrap right">'.price($trim3).'</td>';
print '<td class="nowrap right">'.price($trim4).'</td>';
print '<td class="nowrap right">'.price($trim1+$trim2+$trim3+$trim4).'</td>';
print '<td class="nowrap right">'.price($trim1 + $trim2 + $trim3 + $trim4).'</td>';
print '</tr>';
$lgn++;
}
// We go to the following year
$tmpyear = $objp->annee;
$trim1=0;
$trim2=0;
$trim3=0;
$trim4=0;
$trim1 = 0;
$trim2 = 0;
$trim3 = 0;
$trim4 = 0;
}
if ($objp->mois == "01" || $objp->mois == "02" || $objp->mois == "03")
@ -498,17 +498,17 @@ function activitytrim($product_type)
$i++;
}
if ($trim1+$trim2+$trim3+$trim4 > 0)
if ($trim1 + $trim2 + $trim3 + $trim4 > 0)
{
print '<tr class="oddeven"><td class=left>'.$tmpyear.'</td>';
print '<td class="nowrap right">'.price($trim1).'</td>';
print '<td class="nowrap right">'.price($trim2).'</td>';
print '<td class="nowrap right">'.price($trim3).'</td>';
print '<td class="nowrap right">'.price($trim4).'</td>';
print '<td class="nowrap right">'.price($trim1+$trim2+$trim3+$trim4).'</td>';
print '<td class="nowrap right">'.price($trim1 + $trim2 + $trim3 + $trim4).'</td>';
print '</tr>';
}
if ($num > 0 )
if ($num > 0)
print '</table></div>';
}
}

File diff suppressed because it is too large Load Diff

View File

@ -33,33 +33,33 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
$WIDTH=DolGraph::getDefaultGraphSizeForStats('width', 380);
$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height', 160);
$WIDTH = DolGraph::getDefaultGraphSizeForStats('width', 380);
$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height', 160);
// Load translation files required by the page
$langs->loadLangs(array('companies', 'products', 'stocks', 'bills', 'other'));
$id = GETPOST('id', 'int'); // For this page, id can also be 'all'
$id = GETPOST('id', 'int'); // For this page, id can also be 'all'
$ref = GETPOST('ref', 'alpha');
$mode = (GETPOST('mode', 'alpha') ? GETPOST('mode', 'alpha') : 'byunit');
$mode = (GETPOST('mode', 'alpha') ? GETPOST('mode', 'alpha') : 'byunit');
$search_year = GETPOST('search_year', 'int');
$search_categ = GETPOST('search_categ', 'int');
$error = 0;
$error = 0;
$mesg = '';
$graphfiles=array();
$graphfiles = array();
$socid='';
if (! empty($user->socid)) $socid=$user->socid;
$socid = '';
if (!empty($user->socid)) $socid = $user->socid;
// Security check
$fieldvalue = (! empty($id) ? $id : $ref);
$fieldtype = (! empty($ref) ? 'ref' : 'rowid');
$result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
$fieldvalue = (!empty($id) ? $id : $ref);
$fieldtype = (!empty($ref) ? 'ref' : 'rowid');
$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
$tmp=dol_getdate(dol_now());
$currentyear=$tmp['year'];
if (empty($search_year)) $search_year=$currentyear;
$tmp = dol_getdate(dol_now());
$currentyear = $tmp['year'];
if (empty($search_year)) $search_year = $currentyear;
/*
@ -77,30 +77,30 @@ $form = new Form($db);
$htmlother = new FormOther($db);
$object = new Product($db);
if (! $id && empty($ref))
if (!$id && empty($ref))
{
llxHeader("", $langs->trans("ProductStatistics"));
$type = GETPOST('type', 'int');
$helpurl='';
$helpurl = '';
if ($type == '0')
{
$helpurl='EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
$helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
//$title=$langs->trans("StatisticsOfProducts");
$title=$langs->trans("Statistics");
$title = $langs->trans("Statistics");
}
elseif ($type == '1')
{
$helpurl='EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
//$title=$langs->trans("StatisticsOfServices");
$title=$langs->trans("Statistics");
$title = $langs->trans("Statistics");
}
else
{
$helpurl='EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
//$title=$langs->trans("StatisticsOfProductsOrServices");
$title=$langs->trans("Statistics");
$title = $langs->trans("Statistics");
}
print load_fiche_titre($title, $mesg, 'products');
@ -114,39 +114,39 @@ else
$shortlabel = dol_trunc($object->label, 16);
if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT))
{
$title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Statistics');
$helpurl='EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
$title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Statistics');
$helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
}
if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE))
{
$title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Statistics');
$helpurl='EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
$title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Statistics');
$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
}
llxHeader('', $title, $helpurl);
}
if ($result && (! empty($id) || ! empty($ref)))
if ($result && (!empty($id) || !empty($ref)))
{
$head=product_prepare_head($object);
$titre=$langs->trans("CardProduct".$object->type);
$picto=($object->type==Product::TYPE_SERVICE?'service':'product');
$head = product_prepare_head($object);
$titre = $langs->trans("CardProduct".$object->type);
$picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
dol_fiche_head($head, 'stats', $titre, -1, $picto);
$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'ref', $linkback, ($user->socid?0:1), 'ref', '', '', '', 0, '', '', 1);
dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', '', '', '', 0, '', '', 1);
dol_fiche_end();
}
if (empty($id) & empty($ref))
{
$h=0;
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/product/stats/card.php'.($type != ''?'?type='.$type:'');
$head[$h][0] = DOL_URL_ROOT.'/product/stats/card.php'.($type != '' ? '?type='.$type : '');
$head[$h][1] = $langs->trans("Chart");
$head[$h][2] = 'chart';
$h++;
@ -159,7 +159,7 @@ if (empty($id) & empty($ref))
$title = $langs->trans("ListProductByPopularity");
}
$head[$h][0] = DOL_URL_ROOT.'/product/popuprop.php'.($type != ''?'?type='.$type:'');
$head[$h][0] = DOL_URL_ROOT.'/product/popuprop.php'.($type != '' ? '?type='.$type : '');
$head[$h][1] = $title;
$head[$h][2] = 'popularityprop';
$h++;
@ -180,7 +180,7 @@ if ($result || empty($id))
{
// Type
print '<tr><td class="titlefield">'.$langs->trans("ProductsAndServices").'</td><td>';
$array=array('-1'=>'&nbsp;', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service'));
$array = array('-1'=>'&nbsp;', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service'));
print $form->selectarray('type', $array, $type);
print '</td></tr>';
@ -189,7 +189,7 @@ if ($result || empty($id))
{
print '<tr><td class="titlefield">'.$langs->trans("Categories").'</td><td>';
//$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1);
$moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1);
//$moreforfilter.='</div>';
print $moreforfilter;
print '</td></tr>';
@ -198,13 +198,13 @@ if ($result || empty($id))
// Year
print '<tr><td class="titlefield">'.$langs->trans("Year").'</td><td>';
$arrayyears=array();
for ($year = $currentyear - 10; $year < $currentyear + 10 ; $year++)
$arrayyears = array();
for ($year = $currentyear - 10; $year < $currentyear + 10; $year++)
{
$arrayyears[$year]=$year;
$arrayyears[$year] = $year;
}
if (! in_array($year, $arrayyears)) $arrayyears[$year]=$year;
if (! in_array($nowyear, $arrayyears)) $arrayyears[$nowyear]=$nowyear;
if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear;
arsort($arrayyears);
print $form->selectarray('search_year', $arrayyears, $search_year, 0);
print '</td></tr>';
@ -216,32 +216,32 @@ if ($result || empty($id))
// Choice of stats mode (byunit or bynumber)
if (! empty($conf->dol_use_jmobile)) print "\n".'<div class="fichecenter"><div class="nowrap">'."\n";
if (!empty($conf->dol_use_jmobile)) print "\n".'<div class="fichecenter"><div class="nowrap">'."\n";
if ($mode == 'bynumber') print '<a href="'.$_SERVER["PHP_SELF"].'?id='.(GETPOST('id')?GETPOST('id'):$object->id).($type != '' ? '&type='.$type:'').'&mode=byunit&search_year='.$search_year.'">';
if ($mode == 'bynumber') print '<a href="'.$_SERVER["PHP_SELF"].'?id='.(GETPOST('id') ?GETPOST('id') : $object->id).($type != '' ? '&type='.$type : '').'&mode=byunit&search_year='.$search_year.'">';
else print img_picto('', 'tick').' ';
print $langs->trans("StatsByNumberOfUnits");
if ($mode == 'bynumber') print '</a>';
if (! empty($conf->dol_use_jmobile)) print '</div>'."\n".'<div class="nowrap">'."\n";
if (!empty($conf->dol_use_jmobile)) print '</div>'."\n".'<div class="nowrap">'."\n";
else print ' &nbsp; / &nbsp; ';
if ($mode == 'byunit') print '<a href="'.$_SERVER["PHP_SELF"].'?id='.(GETPOST('id')?GETPOST('id'):$object->id).($type != '' ? '&type='.$type:'').'&mode=bynumber&search_year='.$search_year.'">';
if ($mode == 'byunit') print '<a href="'.$_SERVER["PHP_SELF"].'?id='.(GETPOST('id') ?GETPOST('id') : $object->id).($type != '' ? '&type='.$type : '').'&mode=bynumber&search_year='.$search_year.'">';
else print img_picto('', 'tick').' ';
print $langs->trans("StatsByNumberOfEntities");
if ($mode == 'byunit') print '</a>';
if (! empty($conf->dol_use_jmobile)) print '</div></div>';
if (!empty($conf->dol_use_jmobile)) print '</div></div>';
else print '<br>';
print '<br>';
//print '<table width="100%">';
// Generation des graphs
$dir = (! empty($conf->product->multidir_temp[$object->entity])?$conf->product->multidir_temp[$object->entity]:$conf->service->multidir_temp[$object->entity]);
$dir = (!empty($conf->product->multidir_temp[$object->entity]) ? $conf->product->multidir_temp[$object->entity] : $conf->service->multidir_temp[$object->entity]);
if ($object->id > 0) // We are on statistics for a dedicated product
{
if (! file_exists($dir.'/'.$object->id))
if (!file_exists($dir.'/'.$object->id))
{
if (dol_mkdir($dir.'/'.$object->id) < 0)
{
@ -251,78 +251,78 @@ if ($result || empty($id))
}
}
if($conf->propal->enabled) {
$graphfiles['propal']=array('modulepart'=>'productstats_proposals',
'file' => $object->id.'/propal12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year?'_year'.$search_year:'').'.png',
'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsProposals"):$langs->transnoentitiesnoconv("NumberOfProposals")));
if ($conf->propal->enabled) {
$graphfiles['propal'] = array('modulepart'=>'productstats_proposals',
'file' => $object->id.'/propal12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png',
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsProposals") : $langs->transnoentitiesnoconv("NumberOfProposals")));
}
if($conf->supplier_proposal->enabled) {
$graphfiles['proposalssuppliers']=array('modulepart'=>'productstats_proposalssuppliers',
'file' => $object->id.'/proposalssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year?'_year'.$search_year:'').'.png',
'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsSupplierProposals"):$langs->transnoentitiesnoconv("NumberOfSupplierProposals")));
if ($conf->supplier_proposal->enabled) {
$graphfiles['proposalssuppliers'] = array('modulepart'=>'productstats_proposalssuppliers',
'file' => $object->id.'/proposalssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png',
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierProposals") : $langs->transnoentitiesnoconv("NumberOfSupplierProposals")));
}
if($conf->order->enabled) {
$graphfiles['orders']=array('modulepart'=>'productstats_orders',
'file' => $object->id.'/orders12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year?'_year'.$search_year:'').'.png',
'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsCustomerOrders"):$langs->transnoentitiesnoconv("NumberOfCustomerOrders")));
if ($conf->order->enabled) {
$graphfiles['orders'] = array('modulepart'=>'productstats_orders',
'file' => $object->id.'/orders12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png',
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsCustomerOrders") : $langs->transnoentitiesnoconv("NumberOfCustomerOrders")));
}
if($conf->supplier_order->enabled) {
$graphfiles['orderssuppliers']=array('modulepart'=>'productstats_orderssuppliers',
'file' => $object->id.'/orderssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year?'_year'.$search_year:'').'.png',
'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsSupplierOrders"):$langs->transnoentitiesnoconv("NumberOfSupplierOrders")));
if ($conf->supplier_order->enabled) {
$graphfiles['orderssuppliers'] = array('modulepart'=>'productstats_orderssuppliers',
'file' => $object->id.'/orderssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png',
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierOrders") : $langs->transnoentitiesnoconv("NumberOfSupplierOrders")));
}
if($conf->facture->enabled) {
$graphfiles['invoices']=array('modulepart'=>'productstats_invoices',
'file' => $object->id.'/invoices12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year?'_year'.$search_year:'').'.png',
'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsCustomerInvoices"):$langs->transnoentitiesnoconv("NumberOfCustomerInvoices")));
if ($conf->facture->enabled) {
$graphfiles['invoices'] = array('modulepart'=>'productstats_invoices',
'file' => $object->id.'/invoices12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png',
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsCustomerInvoices") : $langs->transnoentitiesnoconv("NumberOfCustomerInvoices")));
}
if($conf->supplier_invoice->enabled) {
$graphfiles['invoicessuppliers']=array('modulepart'=>'productstats_invoicessuppliers',
'file' => $object->id.'/invoicessuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year?'_year'.$search_year:'').'.png',
'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsSupplierInvoices"):$langs->transnoentitiesnoconv("NumberOfSupplierInvoices")));
if ($conf->supplier_invoice->enabled) {
$graphfiles['invoicessuppliers'] = array('modulepart'=>'productstats_invoicessuppliers',
'file' => $object->id.'/invoicessuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png',
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierInvoices") : $langs->transnoentitiesnoconv("NumberOfSupplierInvoices")));
}
if($conf->contrat->enabled) {
$graphfiles['contracts']=array('modulepart'=>'productstats_contracts',
'file' => $object->id.'/contracts12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year?'_year'.$search_year:'').'.png',
'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsContracts"):$langs->transnoentitiesnoconv("NumberOfContracts")));
if ($conf->contrat->enabled) {
$graphfiles['contracts'] = array('modulepart'=>'productstats_contracts',
'file' => $object->id.'/contracts12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png',
'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsContracts") : $langs->transnoentitiesnoconv("NumberOfContracts")));
}
$px = new DolGraph();
if (! $error && count($graphfiles)>0)
if (!$error && count($graphfiles) > 0)
{
$mesg = $px->isGraphKo();
if (! $mesg)
if (!$mesg)
{
foreach($graphfiles as $key => $val)
foreach ($graphfiles as $key => $val)
{
if (! $graphfiles[$key]['file']) continue;
if (!$graphfiles[$key]['file']) continue;
$graph_data = array();
if (dol_is_file($dir . '/' . $graphfiles[$key]['file']))
if (dol_is_file($dir.'/'.$graphfiles[$key]['file']))
{
// TODO Load cachefile $graphfiles[$key]['file']
}
else
{
$morefilters='';
$morefilters = '';
if ($search_categ > 0)
{
$categ=new Categorie($db);
$categ = new Categorie($db);
$categ->fetch($search_categ);
$listofprodids = $categ->getObjectsInCateg('product', 1);
$morefilters=' AND d.fk_product IN ('.((is_array($listofprodids) && count($listofprodids)) ? join(',', $listofprodids):'0').')';
$morefilters = ' AND d.fk_product IN ('.((is_array($listofprodids) && count($listofprodids)) ? join(',', $listofprodids) : '0').')';
}
if ($search_categ == -2)
{
$morefilters=' AND d.fk_product NOT IN (SELECT cp.fk_product from '.MAIN_DB_PREFIX.'categorie_product as cp)';
$morefilters = ' AND d.fk_product NOT IN (SELECT cp.fk_product from '.MAIN_DB_PREFIX.'categorie_product as cp)';
}
if ($key == 'propal') $graph_data = $object->get_nb_propal($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters);
@ -340,18 +340,18 @@ if ($result || empty($id))
{
$px->SetData($graph_data);
$px->SetYLabel($graphfiles[$key]['label']);
$px->SetMaxValue($px->GetCeilMaxValue()<0?0:$px->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue()>0?0:$px->GetFloorMinValue());
$px->SetMaxValue($px->GetCeilMaxValue() < 0 ? 0 : $px->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue() > 0 ? 0 : $px->GetFloorMinValue());
$px->SetWidth($WIDTH);
$px->SetHeight($HEIGHT);
$px->SetHorizTickIncrement(1);
$px->SetShading(3);
//print 'x '.$key.' '.$graphfiles[$key]['file'];
$url=DOL_URL_ROOT.'/viewimage.php?modulepart='.$graphfiles[$key]['modulepart'].'&entity='.$object->entity.'&file='.urlencode($graphfiles[$key]['file']);
$url = DOL_URL_ROOT.'/viewimage.php?modulepart='.$graphfiles[$key]['modulepart'].'&entity='.$object->entity.'&file='.urlencode($graphfiles[$key]['file']);
$px->draw($dir."/".$graphfiles[$key]['file'], $url);
$graphfiles[$key]['output']=$px->show();
$graphfiles[$key]['output'] = $px->show();
}
else
{
@ -364,19 +364,19 @@ if ($result || empty($id))
}
// Show graphs
$i=0;
if ( count($graphfiles)>0)
$i = 0;
if (count($graphfiles) > 0)
{
foreach($graphfiles as $key => $val)
foreach ($graphfiles as $key => $val)
{
if (! $graphfiles[$key]['file']) continue;
if (!$graphfiles[$key]['file']) continue;
if ($graphfiles == 'propal' && ! $user->rights->propale->lire) continue;
if ($graphfiles == 'order' && ! $user->rights->commande->lire) continue;
if ($graphfiles == 'invoices' && ! $user->rights->facture->lire) continue;
if ($graphfiles == 'proposals_suppliers' && ! $user->rights->supplier_proposal->lire) continue;
if ($graphfiles == 'invoices_suppliers' && ! $user->rights->fournisseur->facture->lire) continue;
if ($graphfiles == 'orders_suppliers' && ! $user->rights->fournisseur->commande->lire) continue;
if ($graphfiles == 'propal' && !$user->rights->propale->lire) continue;
if ($graphfiles == 'order' && !$user->rights->commande->lire) continue;
if ($graphfiles == 'invoices' && !$user->rights->facture->lire) continue;
if ($graphfiles == 'proposals_suppliers' && !$user->rights->supplier_proposal->lire) continue;
if ($graphfiles == 'invoices_suppliers' && !$user->rights->fournisseur->facture->lire) continue;
if ($graphfiles == 'orders_suppliers' && !$user->rights->fournisseur->commande->lire) continue;
if ($i % 2 == 0)
@ -389,16 +389,16 @@ if ($result || empty($id))
}
// Date generation
if ($graphfiles[$key]['output'] && ! $px->isGraphKo())
if ($graphfiles[$key]['output'] && !$px->isGraphKo())
{
if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file'])) $dategenerated=$langs->trans("GeneratedOn", dol_print_date(filemtime($dir."/".$graphfiles[$key]['file']), "dayhour"));
else $dategenerated=$langs->trans("GeneratedOn", dol_print_date(dol_now(), "dayhour"));
if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file'])) $dategenerated = $langs->trans("GeneratedOn", dol_print_date(filemtime($dir."/".$graphfiles[$key]['file']), "dayhour"));
else $dategenerated = $langs->trans("GeneratedOn", dol_print_date(dol_now(), "dayhour"));
}
else
{
$dategenerated=($mesg?'<font class="error">'.$mesg.'</font>':$langs->trans("ChartNotGenerated"));
$dategenerated = ($mesg ? '<font class="error">'.$mesg.'</font>' : $langs->trans("ChartNotGenerated"));
}
$linktoregenerate='<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.(GETPOST('id')?GETPOST('id'):$object->id).((string) $type != ''?'&type='.$type:'').'&action=recalcul&mode='.$mode.'&search_year='.$search_year.'&search_categ='.$search_categ.'">'.img_picto($langs->trans("ReCalculate").' ('.$dategenerated.')', 'refresh').'</a>';
$linktoregenerate = '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.(GETPOST('id') ?GETPOST('id') : $object->id).((string) $type != '' ? '&type='.$type : '').'&action=recalcul&mode='.$mode.'&search_year='.$search_year.'&search_categ='.$search_categ.'">'.img_picto($langs->trans("ReCalculate").' ('.$dategenerated.')', 'refresh').'</a>';
// Show graph
print '<table class="noborder centpercent">';
@ -436,7 +436,7 @@ if ($result || empty($id))
}
}
if (! $id)
if (!$id)
{
dol_fiche_end();
}

View File

@ -36,14 +36,14 @@ $langs->loadLangs(array('products', 'languages'));
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action=GETPOST('action', 'alpha');
$cancel=GETPOST('cancel', 'alpha');
$action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'alpha');
// Security check
$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : ''));
$fieldtype = (! empty($ref) ? 'ref' : 'rowid');
if ($user->socid) $socid=$user->socid;
$result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
$fieldtype = (!empty($ref) ? 'ref' : 'rowid');
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
/*
@ -73,21 +73,21 @@ $cancel != $langs->trans("Cancel") &&
$current_lang = $langs->getDefaultLang();
// update de l'objet
if ( $_POST["forcelangprod"] == $current_lang )
if ($_POST["forcelangprod"] == $current_lang)
{
$object->label = $_POST["libelle"];
$object->description = dol_htmlcleanlastbr($_POST["desc"]);
$object->description = dol_htmlcleanlastbr($_POST["desc"]);
$object->other = dol_htmlcleanlastbr($_POST["other"]);
}
else
{
$object->multilangs[$_POST["forcelangprod"]]["label"] = $_POST["libelle"];
$object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]);
$object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]);
$object->multilangs[$_POST["forcelangprod"]]["other"] = dol_htmlcleanlastbr($_POST["other"]);
}
// sauvegarde en base
if ( $object->setMultiLangs($user) > 0 )
if ($object->setMultiLangs($user) > 0)
{
$action = '';
}
@ -109,21 +109,21 @@ $cancel != $langs->trans("Cancel") &&
foreach ($object->multilangs as $key => $value) // enregistrement des nouvelles valeurs dans l'objet
{
if ( $key == $current_lang )
if ($key == $current_lang)
{
$object->label = $_POST["libelle-".$key];
$object->description = dol_htmlcleanlastbr($_POST["desc-".$key]);
$object->description = dol_htmlcleanlastbr($_POST["desc-".$key]);
$object->other = dol_htmlcleanlastbr($_POST["other-".$key]);
}
else
{
$object->multilangs[$key]["label"] = $_POST["libelle-".$key];
$object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]);
$object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]);
$object->multilangs[$key]["other"] = dol_htmlcleanlastbr($_POST["other-".$key]);
}
}
if ( $object->setMultiLangs($user) > 0 )
if ($object->setMultiLangs($user) > 0)
{
$action = '';
}
@ -141,10 +141,10 @@ $cancel != $langs->trans("Cancel") &&
{
$object = new Product($db);
$object->fetch($id);
$langtodelete=GETPOST('langdel', 'alpha');
$langtodelete = GETPOST('langdel', 'alpha');
if ( $object->delMultiLangs($langtodelete, $user) > 0 )
if ($object->delMultiLangs($langtodelete, $user) > 0)
{
$action = '';
}
@ -168,28 +168,28 @@ $helpurl = '';
$shortlabel = dol_trunc($object->label, 16);
if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT))
{
$title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Translation');
$helpurl='EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
$title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Translation');
$helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
}
if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE))
{
$title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Translation');
$helpurl='EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
$title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Translation');
$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
}
llxHeader('', $title, $helpurl);
$form = new Form($db);
$formadmin=new FormAdmin($db);
$formadmin = new FormAdmin($db);
$head=product_prepare_head($object);
$titre=$langs->trans("CardProduct".$object->type);
$picto=($object->type==Product::TYPE_SERVICE?'service':'product');
$head = product_prepare_head($object);
$titre = $langs->trans("CardProduct".$object->type);
$picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
// Calculate $cnt_trans
$cnt_trans = 0;
if (! empty($object->multilangs))
if (!empty($object->multilangs))
{
foreach ($object->multilangs as $key => $value)
{
@ -203,7 +203,7 @@ dol_fiche_head($head, 'translation', $titre, 0, $picto);
$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$shownav = 1;
if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0;
if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', '', '', '', 0, '', '', 1);
@ -242,12 +242,12 @@ if ($action == 'edit')
print '<input type="hidden" name="action" value="vedit">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
if (! empty($object->multilangs))
if (!empty($object->multilangs))
{
foreach ($object->multilangs as $key => $value)
{
$s=picto_from_langcode($key);
print "<br>".($s?$s.' ':'')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom"')."</a><br>";
$s = picto_from_langcode($key);
print "<br>".($s ? $s.' ' : '')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom"')."</a><br>";
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
@ -256,7 +256,7 @@ if ($action == 'edit')
$doleditor = new DolEditor("desc-$key", $object->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%');
$doleditor->Create();
print '</td></tr>';
if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION))
if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION))
{
print '<tr><td class="tdtop">'.$langs->trans('Other').' ('.$langs->trans("NotUsed").')</td><td>';
$doleditor = new DolEditor("other-$key", $object->multilangs[$key]["other"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%');
@ -279,19 +279,19 @@ if ($action == 'edit')
}
elseif ($action != 'add')
{
if (! empty($object->multilangs))
if (!empty($object->multilangs))
{
foreach ($object->multilangs as $key => $value)
{
$s=picto_from_langcode($key);
print ($s?$s.' ':'')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom"').'</a>';
$s = picto_from_langcode($key);
print ($s ? $s.' ' : '')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom"').'</a>';
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
print '<tr><td class="titlefieldcreate">'.$langs->trans('Label').'</td><td>'.$object->multilangs[$key]["label"].'</td></tr>';
print '<tr><td class="tdtop">'.$langs->trans('Description').'</td><td>'.$object->multilangs[$key]["description"].'</td></tr>';
if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION))
if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION))
{
print '<tr><td>'.$langs->trans('Other').' ('.$langs->trans("NotUsed").')</td><td>'.$object->multilangs[$key]["other"].'</td></tr>';
}
@ -299,7 +299,7 @@ elseif ($action != 'add')
print '</div>';
}
}
if (! $cnt_trans && $action != 'add') print '<div class="opacitymedium">'. $langs->trans('NoTranslation').'</div>';
if (!$cnt_trans && $action != 'add') print '<div class="opacitymedium">'.$langs->trans('NoTranslation').'</div>';
}
@ -331,7 +331,7 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service
$doleditor->Create();
print '</td></tr>';
// Other field (not used)
if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION))
if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION))
{
print '<tr><td class="tdtop">'.$langs->trans('Other').' ('.$langs->trans("NotUsed").'</td><td>';
$doleditor = new DolEditor('other', '', '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%');

File diff suppressed because it is too large Load Diff

View File

@ -26,30 +26,30 @@
// if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language
// if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
// if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
if (!defined('NOCSRFCHECK')) { define('NOCSRFCHECK', '1'); }
if (!defined('NOCSRFCHECK')) { define('NOCSRFCHECK', '1'); }
if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); }
if (!defined('NOREQUIREMENU')) { define('NOREQUIREMENU', '1'); }
if (!defined('NOREQUIREHTML')) { define('NOREQUIREHTML', '1'); }
if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); }
if (!defined('NOREQUIREMENU')) { define('NOREQUIREMENU', '1'); }
if (!defined('NOREQUIREHTML')) { define('NOREQUIREHTML', '1'); }
if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); }
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
$langs->loadLangs(array("companies", "commercial", "bills", "cashdesk", "stocks"));
$id = GETPOST('id', 'int');
$action = GETPOST('action', 'alpha');
$idproduct = GETPOST('idproduct', 'int');
$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Bar or Restaurant
$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Bar or Restaurant
if ($conf->global->TAKEPOS_PHONE_BASIC_LAYOUT==1 && $conf->browser->layout == 'phone')
if ($conf->global->TAKEPOS_PHONE_BASIC_LAYOUT == 1 && $conf->browser->layout == 'phone')
{
// DIRECT LINK TO THIS PAGE FROM MOBILE AND NO TERMINAL SELECTED
if ($_SESSION["takeposterminal"]=="")
if ($_SESSION["takeposterminal"] == "")
{
if ($conf->global->TAKEPOS_NUM_TERMINALS=="1") $_SESSION["takeposterminal"]=1;
if ($conf->global->TAKEPOS_NUM_TERMINALS == "1") $_SESSION["takeposterminal"] = 1;
else
{
header("Location: takepos.php");
@ -57,9 +57,9 @@ if ($conf->global->TAKEPOS_PHONE_BASIC_LAYOUT==1 && $conf->browser->layout == 'p
}
}
$mobilepage = GETPOST('mobilepage', 'alpha');
$title='TakePOS - Dolibarr '.DOL_VERSION;
if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title='TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
$head='<meta name="apple-mobile-web-app-title" content="TakePOS"/>
$title = 'TakePOS - Dolibarr '.DOL_VERSION;
if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
$head = '<meta name="apple-mobile-web-app-title" content="TakePOS"/>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
@ -77,13 +77,13 @@ if ($conf->global->TAKEPOS_PHONE_BASIC_LAYOUT==1 && $conf->browser->layout == 'p
*/
function fail($message)
{
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
header($_SERVER['SERVER_PROTOCOL'].' 500 Internal Server Error', true, 500);
die($message);
}
$placeid = 0; // $placeid is id of invoice
$placeid = 0; // $placeid is id of invoice
$number = GETPOST('number', 'alpha');
$idline = GETPOST('idline', 'int');
@ -94,17 +94,17 @@ $amountofpayment = price2num(GETPOST('amount', 'alpha'));
$invoiceid = GETPOST('invoiceid', 'int');
$paycode = $pay;
if ($pay == 'cash') $paycode = 'LIQ'; // For backward compatibility
if ($pay == 'card') $paycode = 'CB'; // For backward compatibility
if ($pay == 'cheque') $paycode = 'CHQ'; // For backward compatibility
if ($pay == 'cash') $paycode = 'LIQ'; // For backward compatibility
if ($pay == 'card') $paycode = 'CB'; // For backward compatibility
if ($pay == 'cheque') $paycode = 'CHQ'; // For backward compatibility
// Retrieve paiementid
$sql = "SELECT id FROM ".MAIN_DB_PREFIX."c_paiement";
$sql.= " WHERE entity IN (".getEntity('c_paiement').")";
$sql.= " AND code = '".$db->escape($paycode)."'";
$sql .= " WHERE entity IN (".getEntity('c_paiement').")";
$sql .= " AND code = '".$db->escape($paycode)."'";
$resql = $db->query($sql);
$codes = $db->fetch_array($resql);
$paiementid=$codes[0];
$paiementid = $codes[0];
$invoice = new Facture($db);
@ -133,32 +133,32 @@ if ($action == 'valid' && $user->rights->facture->creer)
elseif ($pay == "cheque") $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION["takeposterminal"]}; // For backward compatibility
else
{
$accountname="CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION["takeposterminal"];
$bankaccount=$conf->global->$accountname;
$accountname = "CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION["takeposterminal"];
$bankaccount = $conf->global->$accountname;
}
$now=dol_now();
$now = dol_now();
$res = 0;
$invoice = new Facture($db);
$invoice->fetch($placeid);
if ($invoice->total_ttc < 0) {
$invoice->type= $invoice::TYPE_CREDIT_NOTE;
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE ";
$sql.="fk_soc = '".$invoice->socid."' ";
$sql.="AND type <> ".Facture::TYPE_CREDIT_NOTE." ";
$sql.="AND fk_statut >= ".$invoice::STATUS_VALIDATED." ";
$sql.="ORDER BY rowid DESC";
$invoice->type = $invoice::TYPE_CREDIT_NOTE;
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE ";
$sql .= "fk_soc = '".$invoice->socid."' ";
$sql .= "AND type <> ".Facture::TYPE_CREDIT_NOTE." ";
$sql .= "AND fk_statut >= ".$invoice::STATUS_VALIDATED." ";
$sql .= "ORDER BY rowid DESC";
$resql = $db->query($sql);
if($resql){
if ($resql) {
$obj = $db->fetch_object($resql);
$fk_source=$obj->rowid;
if($fk_source == null){
$fk_source = $obj->rowid;
if ($fk_source == null) {
fail($langs->transnoentitiesnoconv("NoPreviousBillForCustomer"));
}
}else{
} else {
fail($langs->transnoentitiesnoconv("NoPreviousBillForCustomer"));
}
$invoice->fk_facture_source=$fk_source;
$invoice->fk_facture_source = $fk_source;
$invoice->update($user);
}
@ -166,21 +166,21 @@ if ($action == 'valid' && $user->rights->facture->creer)
if ($invoice->statut != Facture::STATUS_DRAFT)
{
//If invoice is validated but it is not fully paid is not error and make the payment
if ($invoice->getRemainToPay()>0) $res=1;
else{
if ($invoice->getRemainToPay() > 0) $res = 1;
else {
dol_syslog("Sale already validated");
dol_htmloutput_errors($langs->trans("InvoiceIsAlreadyValidated", "TakePos"), null, 1);
}
}
elseif (count($invoice->lines)==0)
elseif (count($invoice->lines) == 0)
{
dol_syslog("Sale without lines");
dol_htmloutput_errors($langs->trans("NoLinesToBill", "TakePos"), null, 1);
}
elseif (! empty($conf->stock->enabled) && $conf->global->$constantforkey != "1")
elseif (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1")
{
$savconst = $conf->global->STOCK_CALCULATE_ON_BILL;
$conf->global->STOCK_CALCULATE_ON_BILL=1;
$conf->global->STOCK_CALCULATE_ON_BILL = 1;
$constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"];
dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".$conf->global->$constantforkey);
@ -205,19 +205,19 @@ if ($action == 'valid' && $user->rights->facture->creer)
// If user has not used change control, add total invoice payment
if ($amountofpayment == 0) $payment->amounts[$invoice->id] = $remaintopay;
$payment->paiementid=$paiementid;
$payment->num_payment=$invoice->ref;
$payment->paiementid = $paiementid;
$payment->num_payment = $invoice->ref;
$payment->create($user);
$payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', '');
$remaintopay = $invoice->getRemainToPay(); // Recalculate remain to pay after the payment is recorded
$remaintopay = $invoice->getRemainToPay(); // Recalculate remain to pay after the payment is recorded
if ($remaintopay == 0) {
dol_syslog("Invoice is paid, so we set it to status Paid");
$result = $invoice->set_paid($user);
if ($result > 0) $invoice->paye = 1;
} else {
dol_syslog("Invoice is not paid, remain to pay = " . $remaintopay);
dol_syslog("Invoice is not paid, remain to pay = ".$remaintopay);
}
} else {
dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
@ -231,7 +231,7 @@ if ($action == 'history')
$invoice->fetch($placeid);
}
if (($action=="addline" || $action=="freezone") && $placeid == 0)
if (($action == "addline" || $action == "freezone") && $placeid == 0)
{
$invoice->socid = $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]};
$invoice->date = dol_now();
@ -250,7 +250,7 @@ if (($action=="addline" || $action=="freezone") && $placeid == 0)
{
dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
}
$sql="UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid=".$placeid;
$sql = "UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid=".$placeid;
$db->query($sql);
}
}
@ -268,7 +268,7 @@ if ($action == "addline")
$price_ttc = $prod->price_ttc;
$price_base_type = $prod->price_base_type;
if (! empty($conf->global->PRODUIT_MULTIPRICES))
if (!empty($conf->global->PRODUIT_MULTIPRICES))
{
$price = $prod->multiprices[$customer->price_level];
$tva_tx = $prod->multiprices_tva_tx[$customer->price_level];
@ -288,7 +288,7 @@ if ($action == "freezone") {
}
if ($action == "addnote") {
foreach($invoice->lines as $line)
foreach ($invoice->lines as $line)
{
if ($line->id == $number)
{
@ -305,7 +305,7 @@ if ($action == "deleteline") {
$invoice->fetch($placeid);
}
elseif ($placeid > 0) { // If invoice exists but no line selected, proceed to delete last line.
$sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "facturedet where fk_facture='".$placeid."' order by rowid DESC";
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facturedet where fk_facture='".$placeid."' order by rowid DESC";
$resql = $db->query($sql);
$row = $db->fetch_array($resql);
$deletelineid = $row[0];
@ -324,11 +324,11 @@ if ($action == "delete") {
$db->begin();
// We delete the lines
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "facturedet_extrafields where fk_object = ".$placeid;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_extrafields where fk_object = ".$placeid;
$resql1 = $db->query($sql);
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "facturedet where fk_facture = ".$placeid;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet where fk_facture = ".$placeid;
$resql2 = $db->query($sql);
$sql="UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'";
$sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'";
$resql3 = $db->query($sql);
if ($resql1 && $resql2 && $resql3)
@ -347,7 +347,7 @@ if ($action == "delete") {
if ($action == "updateqty")
{
foreach($invoice->lines as $line)
foreach ($invoice->lines as $line)
{
if ($line->id == $idline)
{
@ -360,7 +360,7 @@ if ($action == "updateqty")
if ($action == "updateprice")
{
foreach($invoice->lines as $line)
foreach ($invoice->lines as $line)
{
if ($line->id == $idline) { $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'TTC', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
}
@ -371,7 +371,7 @@ if ($action == "updateprice")
if ($action == "updatereduction")
{
foreach($invoice->lines as $line)
foreach ($invoice->lines as $line)
{
if ($line->id == $idline) { $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
}
@ -382,15 +382,15 @@ if ($action == "updatereduction")
if ($action == "order" and $placeid != 0)
{
include_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$headerorder = '<html><br><b>' . $langs->trans('Place') . ' ' . $place . '<br><table width="65%"><thead><tr><th class="left">' . $langs->trans("Label") . '</th><th class="right">' . $langs->trans("Qty") . '</th></tr></thead><tbody>';
$footerorder = '</tbody></table>' . dol_print_date(dol_now(), 'dayhour') . '<br></html>';
$headerorder = '<html><br><b>'.$langs->trans('Place').' '.$place.'<br><table width="65%"><thead><tr><th class="left">'.$langs->trans("Label").'</th><th class="right">'.$langs->trans("Qty").'</th></tr></thead><tbody>';
$footerorder = '</tbody></table>'.dol_print_date(dol_now(), 'dayhour').'<br></html>';
$order_receipt_printer1 = "";
$order_receipt_printer2 = "";
$catsprinter1 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1);
$catsprinter2 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2);
foreach($invoice->lines as $line)
foreach ($invoice->lines as $line)
{
if ($line->special_code == "4") { continue;
}
@ -399,15 +399,15 @@ if ($action == "order" and $placeid != 0)
$result = array_intersect($catsprinter1, $existing);
$count = count($result);
if ($count > 0) {
$sql = "UPDATE " . MAIN_DB_PREFIX . "facturedet set special_code='4' where rowid=$line->rowid";
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where rowid=$line->rowid";
$db->query($sql);
$order_receipt_printer1.= '<tr>' . $line->product_label . '<td class="right">' . $line->qty;
if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer1.="<br>(".$line->array_options['options_order_notes'].")";
$order_receipt_printer1.='</td></tr>';
$order_receipt_printer1 .= '<tr>'.$line->product_label.'<td class="right">'.$line->qty;
if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer1 .= "<br>(".$line->array_options['options_order_notes'].")";
$order_receipt_printer1 .= '</td></tr>';
}
}
foreach($invoice->lines as $line)
foreach ($invoice->lines as $line)
{
if ($line->special_code == "4") { continue;
}
@ -416,47 +416,47 @@ if ($action == "order" and $placeid != 0)
$result = array_intersect($catsprinter2, $existing);
$count = count($result);
if ($count > 0) {
$sql = "UPDATE " . MAIN_DB_PREFIX . "facturedet set special_code='4' where rowid=$line->rowid";
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where rowid=$line->rowid";
$db->query($sql);
$order_receipt_printer2.= '<tr>' . $line->product_label . '<td class="right">' . $line->qty;
if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer2.="<br>(".$line->array_options['options_order_notes'].")";
$order_receipt_printer2.='</td></tr>';
$order_receipt_printer2 .= '<tr>'.$line->product_label.'<td class="right">'.$line->qty;
if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer2 .= "<br>(".$line->array_options['options_order_notes'].")";
$order_receipt_printer2 .= '</td></tr>';
}
}
$invoice->fetch($placeid);
}
$sectionwithinvoicelink='';
if ($action=="valid" || $action=="history")
$sectionwithinvoicelink = '';
if ($action == "valid" || $action == "history")
{
$sectionwithinvoicelink.='<!-- Section with invoice link -->'."\n";
$sectionwithinvoicelink.='<span style="font-size:120%;" class="center">';
$sectionwithinvoicelink.=$invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." - ";
$sectionwithinvoicelink .= '<!-- Section with invoice link -->'."\n";
$sectionwithinvoicelink .= '<span style="font-size:120%;" class="center">';
$sectionwithinvoicelink .= $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." - ";
$remaintopay = $invoice->getRemainToPay();
if ($remaintopay > 0)
{
$sectionwithinvoicelink.=$langs->trans('RemainToPay').': <span class="amountremaintopay" style="font-size: unset">'.price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
$sectionwithinvoicelink .= $langs->trans('RemainToPay').': <span class="amountremaintopay" style="font-size: unset">'.price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
}
else
{
if ($invoice->paye) $sectionwithinvoicelink.='<span class="amountpaymentcomplete" style="font-size: unset">'.$langs->trans("Paid").'</span>';
else $sectionwithinvoicelink.=$langs->trans('BillShortStatusValidated');
if ($invoice->paye) $sectionwithinvoicelink .= '<span class="amountpaymentcomplete" style="font-size: unset">'.$langs->trans("Paid").'</span>';
else $sectionwithinvoicelink .= $langs->trans('BillShortStatusValidated');
}
$sectionwithinvoicelink.='</span>';
$sectionwithinvoicelink .= '</span>';
if ($conf->global->TAKEPOSCONNECTOR) {
$sectionwithinvoicelink.=' <button id="buttonprint" type="button" onclick="TakeposPrinting('.$placeid.');">'.$langs->trans('PrintTicket').'</button>';
$sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="TakeposPrinting('.$placeid.');">'.$langs->trans('PrintTicket').'</button>';
} elseif ($conf->global->TAKEPOS_DOLIBARR_PRINTER) {
$sectionwithinvoicelink.=' <button id="buttonprint" type="button" onclick="DolibarrTakeposPrinting('.$placeid.');">'.$langs->trans('PrintTicket').'</button>';
$sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="DolibarrTakeposPrinting('.$placeid.');">'.$langs->trans('PrintTicket').'</button>';
} else {
$sectionwithinvoicelink.=' <button id="buttonprint" type="button" onclick="Print('.$placeid.');">'.$langs->trans('PrintTicket').'</button>';
$sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="Print('.$placeid.');">'.$langs->trans('PrintTicket').'</button>';
}
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
{
$sectionwithinvoicelink.=' <button id="buttonsend" type="button" onclick="SendTicket('.$placeid.');">'.$langs->trans('SendTicket').'</button>';
$sectionwithinvoicelink .= ' <button id="buttonsend" type="button" onclick="SendTicket('.$placeid.');">'.$langs->trans('SendTicket').'</button>';
}
if ($conf->global->TAKEPOS_AUTO_PRINT_TICKETS) $sectionwithinvoicelink.='<script language="javascript">$("#buttonprint").click();</script>';
if ($conf->global->TAKEPOS_AUTO_PRINT_TICKETS) $sectionwithinvoicelink .= '<script language="javascript">$("#buttonprint").click();</script>';
}
/*
@ -469,9 +469,9 @@ $form = new Form($db);
<script language="javascript">
var selectedline=0;
var selectedtext="";
var placeid=<?php echo ($placeid > 0 ? $placeid : 0);?>;
var placeid=<?php echo ($placeid > 0 ? $placeid : 0); ?>;
$(document).ready(function() {
var idoflineadded = <?php echo ($idoflineadded?$idoflineadded:0); ?>;
var idoflineadded = <?php echo ($idoflineadded ? $idoflineadded : 0); ?>;
$('.posinvoiceline').click(function(){
console.log("Click done on "+this.id);
@ -496,7 +496,7 @@ if ($action == "order" and $order_receipt_printer1 != "") {
type: "POST",
url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print',
data: '<?php
print $headerorder . $order_receipt_printer1 . $footerorder; ?>'
print $headerorder.$order_receipt_printer1.$footerorder; ?>'
});
<?php
}
@ -507,7 +507,7 @@ if ($action == "order" and $order_receipt_printer2 != "") {
type: "POST",
url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print2',
data: '<?php
print $headerorder . $order_receipt_printer2 . $footerorder; ?>'
print $headerorder.$order_receipt_printer2.$footerorder; ?>'
});
<?php
}
@ -526,7 +526,7 @@ if ($action == "temp" and $ticket_printer1 != "") {
type: "POST",
url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print',
data: '<?php
print $header_soc . $header_ticket . $body_ticket . $ticket_printer1 . $ticket_total . $footer_ticket; ?>'
print $header_soc.$header_ticket.$body_ticket.$ticket_printer1.$ticket_total.$footer_ticket; ?>'
});
<?php
}
@ -544,7 +544,7 @@ if ($action == "search") {
function SendTicket(id)
{
console.log("Open box to select the Print/Send form");
$.colorbox({href:"send.php?facid="+id, width:"90%", height:"50%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("SendTicket");?>"});
$.colorbox({href:"send.php?facid="+id, width:"90%", height:"50%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("SendTicket"); ?>"});
}
function Print(id){
@ -575,10 +575,10 @@ function DolibarrTakeposPrinting(id) {
<?php
// Add again js for footer because this content is injected into takepos.php page so all init
// for tooltip and other js beautifiers must be reexecuted too.
if (! empty($conf->use_javascript_ajax))
if (!empty($conf->use_javascript_ajax))
{
print "\n".'<!-- Includes JS Footer of Dolibarr -->'."\n";
print '<script src="'.DOL_URL_ROOT.'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.($ext?'&'.$ext:'').'"></script>'."\n";
print '<script src="'.DOL_URL_ROOT.'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.($ext ? '&'.$ext : '').'"></script>'."\n";
}
@ -589,7 +589,7 @@ print '<td class="linecoldescription">';
print '<span style="font-size:120%;" class="right">';
if ($conf->global->TAKEPOS_BAR_RESTAURANT)
{
$sql="SELECT floor, label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place);
$sql = "SELECT floor, label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place);
$resql = $db->query($sql);
$obj = $db->fetch_object($resql);
if ($obj)
@ -598,83 +598,83 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT)
$floor = $obj->floor;
}
// In phone version only show when is invoice page
if ($mobilepage=="invoice" || $mobilepage=="") {
print $langs->trans('Place') . " <b>" . $label . "</b> - ";
print $langs->trans('Floor') . " <b>" . $floor . "</b> - ";
if ($mobilepage == "invoice" || $mobilepage == "") {
print $langs->trans('Place')." <b>".$label."</b> - ";
print $langs->trans('Floor')." <b>".$floor."</b> - ";
}
}
// In phone version only show when is invoice page
if ($mobilepage=="invoice" || $mobilepage=="") {
if ($mobilepage == "invoice" || $mobilepage == "") {
print $langs->trans('TotalTTC');
print ' : <b>' . price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency) . '</b></span>';
print '<br><input type="hidden" name="invoiceid" id="invoiceid" value="'.$invoice->id.'">' . $sectionwithinvoicelink;
print ' : <b>'.price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency).'</b></span>';
print '<br><input type="hidden" name="invoiceid" id="invoiceid" value="'.$invoice->id.'">'.$sectionwithinvoicelink;
print '</td>';
}
if ($_SESSION["basiclayout"]!=1)
if ($_SESSION["basiclayout"] != 1)
{
print '<td class="linecolqty right">' . $langs->trans('ReductionShort') . '</td>';
print '<td class="linecolqty right">' . $langs->trans('Qty') . '</td>';
print '<td class="linecolht right nowraponall">' . $langs->trans('TotalTTCShort') . '</td>';
print '<td class="linecolqty right">'.$langs->trans('ReductionShort').'</td>';
print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
print '<td class="linecolht right nowraponall">'.$langs->trans('TotalTTCShort').'</td>';
}
print "</tr>\n";
if ($_SESSION["basiclayout"]==1)
if ($_SESSION["basiclayout"] == 1)
{
if ($mobilepage=="cats")
if ($mobilepage == "cats")
{
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$categorie = new Categorie($db);
$categories = $categorie->get_full_arbo('product');
$htmlforlines = '';
foreach ($categories as $row){
$htmlforlines.= '<tr class="drag drop oddeven posinvoiceline';
$htmlforlines.= '" onclick="LoadProducts(' . $row['id'] . ');">';
$htmlforlines.= '<td class="left">';
$htmlforlines.= $row['label'];
$htmlforlines.= '</td>';
$htmlforlines.= '</tr>'."\n";
foreach ($categories as $row) {
$htmlforlines .= '<tr class="drag drop oddeven posinvoiceline';
$htmlforlines .= '" onclick="LoadProducts('.$row['id'].');">';
$htmlforlines .= '<td class="left">';
$htmlforlines .= $row['label'];
$htmlforlines .= '</td>';
$htmlforlines .= '</tr>'."\n";
}
$htmlforlines.= '</table>';
$htmlforlines.= '</table>';
$htmlforlines .= '</table>';
$htmlforlines .= '</table>';
print $htmlforlines;
}
if ($mobilepage=="products")
if ($mobilepage == "products")
{
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$object = new Categorie($db);
$catid = GETPOST('catid', 'int');
$result=$object->fetch($catid);
$result = $object->fetch($catid);
$prods = $object->getObjectsInCateg("product");
$htmlforlines = '';
foreach ($prods as $row) {
$htmlforlines.= '<tr class="drag drop oddeven posinvoiceline';
$htmlforlines.= '" onclick="AddProduct(\'' . $place . '\', ' . $row->id . ')">';
$htmlforlines.= '<td class="left">';
$htmlforlines.= $row->label;
$htmlforlines.= '</td>';
$htmlforlines.= '</tr>'."\n";
$htmlforlines .= '<tr class="drag drop oddeven posinvoiceline';
$htmlforlines .= '" onclick="AddProduct(\''.$place.'\', '.$row->id.')">';
$htmlforlines .= '<td class="left">';
$htmlforlines .= $row->label;
$htmlforlines .= '</td>';
$htmlforlines .= '</tr>'."\n";
}
$htmlforlines.= '</table>';
$htmlforlines .= '</table>';
print $htmlforlines;
}
if ($mobilepage=="places")
if ($mobilepage == "places")
{
$sql="SELECT rowid, entity, label, leftpos, toppos, floor FROM ".MAIN_DB_PREFIX."takepos_floor_tables";
$sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM ".MAIN_DB_PREFIX."takepos_floor_tables";
$resql = $db->query($sql);
$rows = array();
$htmlforlines = '';
while($row = $db->fetch_array($resql)){
while ($row = $db->fetch_array($resql)) {
$rows[] = $row;
$htmlforlines.= '<tr class="drag drop oddeven posinvoiceline';
$htmlforlines.= '" onclick="LoadPlace(\'' . $row['label'] . '\')">';
$htmlforlines.= '<td class="left">';
$htmlforlines.= $row['label'];
$htmlforlines.= '</td>';
$htmlforlines.= '</tr>'."\n";
$htmlforlines .= '<tr class="drag drop oddeven posinvoiceline';
$htmlforlines .= '" onclick="LoadPlace(\''.$row['label'].'\')">';
$htmlforlines .= '<td class="left">';
$htmlforlines .= $row['label'];
$htmlforlines .= '</td>';
$htmlforlines .= '</tr>'."\n";
}
$htmlforlines.= '</table>';
$htmlforlines .= '</table>';
print $htmlforlines;
}
}
@ -682,50 +682,50 @@ if ($_SESSION["basiclayout"]==1)
if ($placeid > 0)
{
//In Phone basic layout hide some content depends situation
if ($_SESSION["basiclayout"]==1 && $mobilepage!="invoice" && $action!="order") return;
if ($_SESSION["basiclayout"] == 1 && $mobilepage != "invoice" && $action != "order") return;
if (is_array($invoice->lines) && count($invoice->lines))
{
$tmplines = array_reverse($invoice->lines);
foreach($tmplines as $line)
foreach ($tmplines as $line)
{
$htmlforlines = '';
$htmlforlines.= '<tr class="drag drop oddeven posinvoiceline';
$htmlforlines .= '<tr class="drag drop oddeven posinvoiceline';
if ($line->special_code == "4") {
$htmlforlines.= ' order';
$htmlforlines .= ' order';
}
$htmlforlines.= '" id="' . $line->id . '">';
$htmlforlines.= '<td class="left">';
$htmlforlines .= '" id="'.$line->id.'">';
$htmlforlines .= '<td class="left">';
//if ($line->product_label) $htmlforlines.= '<b>'.$line->product_label.'</b>';
if (isset($line->product_type))
{
if (empty($line->product_type)) $htmlforlines.=img_object('', 'product').' ';
else $htmlforlines.=img_object('', 'service').' ';
if (empty($line->product_type)) $htmlforlines .= img_object('', 'product').' ';
else $htmlforlines .= img_object('', 'service').' ';
}
if ($line->product_label) $htmlforlines.= $line->product_label;
if ($line->product_label && $line->desc) $htmlforlines.= '<br>';
if ($line->product_label) $htmlforlines .= $line->product_label;
if ($line->product_label && $line->desc) $htmlforlines .= '<br>';
if ($line->product_label != $line->desc)
{
$firstline = dolGetFirstLineOfText($line->desc);
if ($firstline != $line->desc)
{
$htmlforlines.= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
$htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
}
else
{
$htmlforlines.= $line->desc;
$htmlforlines .= $line->desc;
}
}
if (!empty($line->array_options['options_order_notes'])) $htmlforlines.= "<br>(".$line->array_options['options_order_notes'].")";
if ($_SESSION["basiclayout"]!=1)
if (!empty($line->array_options['options_order_notes'])) $htmlforlines .= "<br>(".$line->array_options['options_order_notes'].")";
if ($_SESSION["basiclayout"] != 1)
{
$htmlforlines.= '</td>';
$htmlforlines.= '<td class="right">' . vatrate($line->remise_percent, true) . '</td>';
$htmlforlines.= '<td class="right">' . $line->qty . '</td>';
$htmlforlines.= '<td class="right">' . price($line->total_ttc) . '</td>';
$htmlforlines .= '</td>';
$htmlforlines .= '<td class="right">'.vatrate($line->remise_percent, true).'</td>';
$htmlforlines .= '<td class="right">'.$line->qty.'</td>';
$htmlforlines .= '<td class="right">'.price($line->total_ttc).'</td>';
}
$htmlforlines.= '</tr>'."\n";
$htmlforlines .= '</tr>'."\n";
print $htmlforlines;
}
@ -743,7 +743,7 @@ print '</table>';
if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]})
{
$constforcompanyid='CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"];
$constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"];
$soc = new Societe($db);
if ($invoice->socid > 0) $soc->fetch($invoice->socid);
else $soc->fetch($conf->global->$constforcompanyid);
@ -752,7 +752,7 @@ if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takep
print $langs->trans("Customer").': '.$soc->name;
$constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"];
if (! empty($conf->stock->enabled) && $conf->global->$constantforkey != "1")
if (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1")
{
$constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"];
$warehouse = new Entrepot($db);
@ -761,16 +761,16 @@ if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takep
}
// Module Adherent
if (! empty($conf->adherent->enabled))
if (!empty($conf->adherent->enabled))
{
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$langs->load("members");
print '<br>'.$langs->trans("Member").': ';
$adh=new Adherent($db);
$result=$adh->fetch('', '', $invoice->socid);
$adh = new Adherent($db);
$result = $adh->fetch('', '', $invoice->socid);
if ($result > 0)
{
$adh->ref=$adh->getFullName($langs);
$adh->ref = $adh->getFullName($langs);
print $adh->getFullName($langs);
print '<br>'.$langs->trans("Type").': '.$adh->type;
if ($adh->datefin)
@ -797,7 +797,7 @@ if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takep
if ($action == "search")
{
print '<center>
<input type="text" id="search" name="search" onkeyup="Search2();" name="search" style="width:80%;font-size: 150%;" placeholder=' . $langs->trans('Search') . '
<input type="text" id="search" name="search" onkeyup="Search2();" name="search" style="width:80%;font-size: 150%;" placeholder=' . $langs->trans('Search').'
</center>';
}

View File

@ -25,15 +25,15 @@
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
require '../main.inc.php'; // Load $user and permissions
require '../main.inc.php'; // Load $user and permissions
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$invoiceid = GETPOST('facid', 'int');
@ -48,16 +48,16 @@ if ($invoiceid > 0)
}
else
{
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'";
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'";
$resql = $db->query($sql);
$obj = $db->fetch_object($resql);
if ($obj)
{
$invoiceid = $obj->rowid;
}
if (! $invoiceid)
if (!$invoiceid)
{
$invoiceid=0; // Invoice does not exist yet
$invoiceid = 0; // Invoice does not exist yet
}
else
{
@ -82,7 +82,7 @@ if ($invoice->id > 0)
}
$alreadypayed = (is_object($invoice) ? ($invoice->total_ttc - $remaintopay) : 0);
if ($conf->global->TAKEPOS_NUMPAD==0) print "var received='';";
if ($conf->global->TAKEPOS_NUMPAD == 0) print "var received='';";
else print "var received=0;";
?>
@ -98,10 +98,10 @@ else print "var received=0;";
$('.change1').val(parseFloat(received));
alreadypaydplusreceived=price2numjs(alreadypayed + parseFloat(received));
//console.log("already+received = "+alreadypaydplusreceived);
//console.log("total_ttc = "+<?php echo $invoice->total_ttc;?>);
if (alreadypaydplusreceived > <?php echo $invoice->total_ttc;?>)
//console.log("total_ttc = "+<?php echo $invoice->total_ttc; ?>);
if (alreadypaydplusreceived > <?php echo $invoice->total_ttc; ?>)
{
var change=parseFloat(alreadypayed + parseFloat(received) - <?php echo $invoice->total_ttc;?>);
var change=parseFloat(alreadypayed + parseFloat(received) - <?php echo $invoice->total_ttc; ?>);
$('.change2').html(pricejs(change, 'MT'));
$('.change2').val(change);
$('.change1').removeClass('colorred');
@ -113,7 +113,7 @@ else print "var received=0;";
{
$('.change2').html(pricejs(0, 'MT'));
$('.change2').val(0);
if (alreadypaydplusreceived == <?php echo $invoice->total_ttc;?>)
if (alreadypaydplusreceived == <?php echo $invoice->total_ttc; ?>)
{
$('.change1').removeClass('colorred');
$('.change1').addClass('colorgreen');
@ -140,7 +140,7 @@ function Print(id){
<div class="center">
<center>
<center><input type="email" id="email" name="email" style="width:60%;font-size: 200%;" value="<?php echo $invoice->thirdparty->email;?>"></center>
<center><input type="email" id="email" name="email" style="width:60%;font-size: 200%;" value="<?php echo $invoice->thirdparty->email; ?>"></center>
</center>
</div>
<br>

View File

@ -32,9 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/userbankaccount.class.php';
if (! empty($conf->holiday->enabled)) require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
if (! empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
if (! empty($conf->salaries->enabled)) require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
if (!empty($conf->holiday->enabled)) require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
if (!empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
if (!empty($conf->salaries->enabled)) require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
// Load translation files required by page
$langs->loadLangs(array('companies', 'commercial', 'banks', 'bills', 'trips', 'holiday', 'salaries'));
@ -45,23 +45,23 @@ $action = GETPOST("action", 'alpha');
$cancel = GETPOST('cancel', 'alpha');
// Security check
$socid=0;
$socid = 0;
if ($user->socid > 0) $socid = $user->socid;
$feature2 = (($socid && $user->rights->user->self->creer)?'':'user');
$feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
// Ok if user->rights->salaries->read or user->rights->hrm->read
//$result = restrictedArea($user, 'salaries|hrm', $id, 'user&user', $feature2);
$ok=false;
if ($user->id == $id) $ok=true; // A user can always read its own card
if (! empty($user->rights->salaries->read)) $ok=true;
if (! empty($user->rights->hrm->read)) $ok=true;
if (! empty($user->rights->expensereport->lire) && ($user->id == $object->id || $user->rights->expensereport->readall)) $ok=true;
if (! $ok)
$ok = false;
if ($user->id == $id) $ok = true; // A user can always read its own card
if (!empty($user->rights->salaries->read)) $ok = true;
if (!empty($user->rights->hrm->read)) $ok = true;
if (!empty($user->rights->expensereport->lire) && ($user->id == $object->id || $user->rights->expensereport->readall)) $ok = true;
if (!$ok)
{
accessforbidden();
}
$object = new User($db);
if ($id > 0 || ! empty($ref))
if ($id > 0 || !empty($ref))
{
$result = $object->fetch($id, $ref, '', 1);
$object->getrights();
@ -72,7 +72,7 @@ if ($id > 0 || ! empty($ref))
* Actions
*/
if ($action == 'add' && ! $cancel)
if ($action == 'add' && !$cancel)
{
// Modification
$account = new UserBankAccount($db);
@ -94,10 +94,10 @@ if ($action == 'add' && ! $cancel)
$result = $account->create($user);
if (! $result)
if (!$result)
{
setEventMessages($account->error, $account->errors, 'errors');
$action='edit'; // Force chargement page edition
$action = 'edit'; // Force chargement page edition
}
else
{
@ -106,14 +106,14 @@ if ($action == 'add' && ! $cancel)
}
}
if ($action == 'update' && ! $cancel)
if ($action == 'update' && !$cancel)
{
// Modification
$account = new UserBankAccount($db);
$account->fetch($bankid);
$account->userid = $object->id;
$account->userid = $object->id;
$account->bank = GETPOST('bank', 'alpha');
$account->label = GETPOST('label', 'alpha');
@ -130,10 +130,10 @@ if ($action == 'update' && ! $cancel)
$result = $account->update($user);
if (! $result)
if (!$result)
{
setEventMessages($account->error, $account->errors, 'errors');
$action='edit'; // Force chargement page edition
$action = 'edit'; // Force chargement page edition
}
else
{
@ -154,7 +154,7 @@ llxHeader(null, $langs->trans("BankAccounts"));
$head = user_prepare_head($object);
$account = new UserBankAccount($db);
if (! $bankid)
if (!$bankid)
{
$account->fetch(0, '', $id);
}
@ -162,7 +162,7 @@ else
{
$account->fetch($bankid);
}
if (empty($account->userid)) $account->userid=$object->id;
if (empty($account->userid)) $account->userid = $object->id;
if ($id && $bankid && $action == 'edit' && $user->rights->user->user->creer)
@ -239,9 +239,9 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
}
print '<tr><td class="tdtop">'.$langs->trans("IBAN").'</td>';
print '<td>'.$account->iban . '&nbsp;';
if (! empty($account->iban)) {
if (! checkIbanForAccount($account)) {
print '<td>'.$account->iban.'&nbsp;';
if (!empty($account->iban)) {
if (!checkIbanForAccount($account)) {
print img_picto($langs->trans("IbanNotValid"), 'warning');
} else {
print img_picto($langs->trans("IbanValid"), 'info');
@ -251,8 +251,8 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
print '<tr><td class="tdtop">'.$langs->trans("BIC").'</td>';
print '<td>'.$account->bic.'&nbsp;';
if (! empty($account->bic)) {
if (! checkSwiftForAccount($account)) {
if (!empty($account->bic)) {
if (!checkSwiftForAccount($account)) {
print img_picto($langs->trans("SwiftNotValid"), 'warning');
} else {
print img_picto($langs->trans("SwiftValid"), 'info');
@ -275,7 +275,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
print '</table>';
// Check BBAN
if ($account->label && ! checkBanForAccount($account))
if ($account->label && !checkBanForAccount($account))
{
print '<div class="warning">'.$langs->trans("RIBControlError").'</div>';
}
@ -283,24 +283,24 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
// Nbre max d'elements des petites listes
$MAXLIST=$conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
$MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
/*
* Last salaries
*/
if (! empty($conf->salaries->enabled) &&
if (!empty($conf->salaries->enabled) &&
($user->rights->salaries->read && $object->id == $user->id)
)
{
$salary = new PaymentSalary($db);
$sql = "SELECT ps.rowid, ps.datesp, ps.dateep, ps.amount";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as ps";
$sql.= " WHERE ps.fk_user = ".$object->id;
$sql.= " AND ps.entity = ".$conf->entity;
$sql.= " ORDER BY ps.datesp DESC";
$sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as ps";
$sql .= " WHERE ps.fk_user = ".$object->id;
$sql .= " AND ps.entity = ".$conf->entity;
$sql .= " ORDER BY ps.datesp DESC";
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
@ -308,7 +308,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastSalaries", ($num<=$MAXLIST?"":$MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/salaries/list.php?search_user='.$object->login.'">'.$langs->trans("AllSalaries").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastSalaries", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/salaries/list.php?search_user='.$object->login.'">'.$langs->trans("AllSalaries").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
print '</tr></table></td>';
print '</tr>';
@ -342,19 +342,19 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
/*
* Last holidays
*/
if (! empty($conf->holiday->enabled) &&
if (!empty($conf->holiday->enabled) &&
($user->rights->holiday->read_all || ($user->rights->holiday->read && $object->id == $user->id))
)
{
$holiday = new Holiday($db);
$sql = "SELECT h.rowid, h.statut, h.fk_type, h.date_debut, h.date_fin, h.halfday";
$sql.= " FROM ".MAIN_DB_PREFIX."holiday as h";
$sql.= " WHERE h.fk_user = ".$object->id;
$sql.= " AND h.entity = ".$conf->entity;
$sql.= " ORDER BY h.date_debut DESC";
$sql .= " FROM ".MAIN_DB_PREFIX."holiday as h";
$sql .= " WHERE h.fk_user = ".$object->id;
$sql .= " AND h.entity = ".$conf->entity;
$sql .= " ORDER BY h.date_debut DESC";
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
@ -362,7 +362,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td colspan="4"><table class="nobordernopadding centpercent"><tr><td>'.$langs->trans("LastHolidays", ($num<=$MAXLIST?"":$MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/holiday/list.php?id='.$object->id.'">'.$langs->trans("AllHolidays").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
print '<td colspan="4"><table class="nobordernopadding centpercent"><tr><td>'.$langs->trans("LastHolidays", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/holiday/list.php?id='.$object->id.'">'.$langs->trans("AllHolidays").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
print '</tr></table></td>';
print '</tr>';
@ -376,7 +376,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
$holiday->id = $objp->rowid;
$holiday->ref = $objp->rowid;
$holiday->fk_type = $objp->fk_type;
$nbopenedday=num_open_day($db->jdate($objp->date_debut), $db->jdate($objp->date_fin), 0, 1, $objp->halfday);
$nbopenedday = num_open_day($db->jdate($objp->date_debut), $db->jdate($objp->date_fin), 0, 1, $objp->halfday);
print $holiday->getNomUrl(1);
print '</td><td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_debut), 'day')."</td>\n";
@ -398,19 +398,19 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
/*
* Last expense report
*/
if (! empty($conf->expensereport->enabled) &&
if (!empty($conf->expensereport->enabled) &&
($user->rights->expensereport->readall || ($user->rights->expensereport->lire && $object->id == $user->id))
)
{
$exp = new ExpenseReport($db);
$sql = "SELECT e.rowid, e.ref, e.fk_statut, e.date_debut, e.total_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as e";
$sql.= " WHERE e.fk_user_author = ".$object->id;
$sql.= " AND e.entity = ".$conf->entity;
$sql.= " ORDER BY e.date_debut DESC";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as e";
$sql .= " WHERE e.fk_user_author = ".$object->id;
$sql .= " AND e.entity = ".$conf->entity;
$sql .= " ORDER BY e.date_debut DESC";
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
@ -418,7 +418,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td colspan="4"><table class="nobordernopadding centpercent"><tr><td>'.$langs->trans("LastExpenseReports", ($num<=$MAXLIST?"":$MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/expensereport/list.php?id='.$object->id.'">'.$langs->trans("AllExpenseReports").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
print '<td colspan="4"><table class="nobordernopadding centpercent"><tr><td>'.$langs->trans("LastExpenseReports", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/expensereport/list.php?id='.$object->id.'">'.$langs->trans("AllExpenseReports").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
print '</tr></table></td>';
print '</tr>';
@ -472,7 +472,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
}
// Edit
if ($id && ($action == 'edit' || $action == 'create' ) && $user->rights->user->user->creer)
if ($id && ($action == 'edit' || $action == 'create') && $user->rights->user->user->creer)
{
$title = $langs->trans("User");
dol_fiche_head($head, 'bank', $title, 0, 'user');

File diff suppressed because it is too large Load Diff