';
- if (! empty($arrayfields['t.field1']['checked'])) print_liste_field_titre($langs->trans('field1'),$_SERVER['PHP_SELF'],'t.field1','',$param,'',$sortfield,$sortorder);
- if (! empty($arrayfields['t.field2']['checked'])) print_liste_field_titre($langs->trans('field2'),$_SERVER['PHP_SELF'],'t.field2','',$param,'',$sortfield,$sortorder);
+ if (! empty($arrayfields['t.field1']['checked'])) print_liste_field_titre($arrayfields['t.field1']['label'],$_SERVER['PHP_SELF'],'t.field1','',$param,'',$sortfield,$sortorder);
+ if (! empty($arrayfields['t.field2']['checked'])) print_liste_field_titre($arrayfields['t.field2']['label'],$_SERVER['PHP_SELF'],'t.field2','',$param,'',$sortfield,$sortorder);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
@@ -315,8 +334,8 @@ if ($resql)
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
- if (! empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($langs->trans("DateCreationShort"),$_SERVER["PHP_SELF"],"t.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
- if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($langs->trans("DateModificationShort"),$_SERVER["PHP_SELF"],"t.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
+ if (! empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($arrayfields['t.datec']['label'],$_SERVER["PHP_SELF"],"t.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
+ if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'],$_SERVER["PHP_SELF"],"t.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
//if (! empty($arrayfields['t.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"t.status","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch ');
print '
';
@@ -151,7 +154,5 @@ print '';
print '';
-print info_admin($langs->trans("NoNeedForDeliveryReceipts"));
-
llxFooter();
$db->close();
diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index 8ee8b791303..f904c7f6cf0 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -8,7 +8,7 @@
* Copyright (C) 2011 Remy Younes
* Copyright (C) 2012-2015 Marcos GarcÃa
* Copyright (C) 2012 Christophe Battarel
- * Copyright (C) 2011-2015 Alexandre Spangaro
+ * Copyright (C) 2011-2016 Alexandre Spangaro
* Copyright (C) 2015 Ferran Marcet
* Copyright (C) 2016 Raphaël Doursenaud
*
@@ -46,6 +46,8 @@ $langs->load("admin");
$langs->load("companies");
$langs->load("resource");
$langs->load("holiday");
+$langs->load("accountancy");
+$langs->load("hrm");
$action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view';
$confirm=GETPOST('confirm','alpha');
@@ -78,7 +80,7 @@ $hookmanager->initHooks(array('admin'));
// Put here declaration of dictionaries properties
// Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
-$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,6,0,29,0,7,17,24,28,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,25,0,26);
+$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,33,34,0,6,0,29,0,7,17,24,28,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,25,0,26,0,31,32,0);
// Name of SQL tables of dictionaries
$tabname=array();
@@ -112,6 +114,10 @@ $tabname[27]= MAIN_DB_PREFIX."c_stcomm";
$tabname[28]= MAIN_DB_PREFIX."c_holiday_types";
$tabname[29]= MAIN_DB_PREFIX."c_lead_status";
$tabname[30]= MAIN_DB_PREFIX."c_format_cards";
+$tabname[31]= MAIN_DB_PREFIX."accounting_system";
+$tabname[32]= MAIN_DB_PREFIX."c_accounting_category";
+$tabname[33]= MAIN_DB_PREFIX."c_hrm_department";
+$tabname[34]= MAIN_DB_PREFIX."c_hrm_function";
// Dictionary labels
$tablib=array();
@@ -145,6 +151,10 @@ $tablib[27]= "DictionaryProspectStatus";
$tablib[28]= "DictionaryHolidayTypes";
$tablib[29]= "DictionaryOpportunityStatus";
$tablib[30]= "DictionaryFormatCards";
+$tablib[31]= "DictionaryAccountancysystem";
+$tablib[32]= "DictionaryAccountancyCategory";
+$tablib[33]= "DictionaryDepartment";
+$tablib[34]= "DictionaryFunction";
// Requests to extract data
$tabsql=array();
@@ -172,12 +182,16 @@ $tabsql[21]= "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX
$tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason";
$tabsql[23]= "SELECT t.rowid as rowid, t.taux, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid";
$tabsql[24]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource";
-$tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content, active FROM ".MAIN_DB_PREFIX."c_email_templates";
+$tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content, active FROM ".MAIN_DB_PREFIX."c_email_templates WHERE entity IN (".getEntity('email_template',1).")";
$tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units";
$tabsql[27]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_stcomm";
-$tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newByMonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid";
+$tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid";
$tabsql[29]= "SELECT rowid as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status";
$tabsql[30]= "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards";
+$tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.fk_pays as country_id, c.code as country_code, c.label as country, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s, ".MAIN_DB_PREFIX."c_country as c WHERE s.fk_pays=c.rowid and c.active=1";
+$tabsql[32]= "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1";
+$tabsql[33]= "SELECT rowid, pos, code, label, active FROM ".MAIN_DB_PREFIX."c_hrm_department";
+$tabsql[34]= "SELECT rowid, pos, code, label, c_level, active FROM ".MAIN_DB_PREFIX."c_hrm_function";
// Criteria to sort dictionaries
$tabsqlsort=array();
@@ -211,6 +225,10 @@ $tabsqlsort[27]="code ASC";
$tabsqlsort[28]="country ASC, code ASC";
$tabsqlsort[29]="position ASC";
$tabsqlsort[30]="code ASC";
+$tabsqlsort[31]="pcg_version ASC";
+$tabsqlsort[32]="code ASC, label ASC";
+$tabsqlsort[33]="code ASC";
+$tabsqlsort[34]="code ASC";
// Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield=array();
@@ -241,9 +259,13 @@ $tabfield[24]= "code,label";
$tabfield[25]= "label,type_template,position,topic,content";
$tabfield[26]= "code,label,short_label";
$tabfield[27]= "code,libelle";
-$tabfield[28]= "code,label,affect,delay,newByMonth,country_id,country";
+$tabfield[28]= "code,label,affect,delay,newbymonth,country_id,country";
$tabfield[29]= "code,label,percent,position";
$tabfield[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
+$tabfield[31]= "pcg_version,country_id,country,label";
+$tabfield[32]= "code,label,range,position,country_id,country";
+$tabfield[33]= "code,label";
+$tabfield[34]= "code,label";
// Nom des champs d'edition pour modification d'un enregistrement
$tabfieldvalue=array();
@@ -274,9 +296,13 @@ $tabfieldvalue[24]= "code,label";
$tabfieldvalue[25]= "label,type_template,position,topic,content";
$tabfieldvalue[26]= "code,label,short_label";
$tabfieldvalue[27]= "code,libelle";
-$tabfieldvalue[28]= "code,label,affect,delay,newByMonth,country";
+$tabfieldvalue[28]= "code,label,affect,delay,newbymonth,country";
$tabfieldvalue[29]= "code,label,percent,position";
$tabfieldvalue[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
+$tabfieldvalue[31]= "pcg_version,country,label";
+$tabfieldvalue[32]= "code,label,range_account,position,country";
+$tabfieldvalue[33]= "code,label";
+$tabfieldvalue[34]= "code,label";
// Nom des champs dans la table pour insertion d'un enregistrement
$tabfieldinsert=array();
@@ -304,12 +330,16 @@ $tabfieldinsert[21]= "code,label";
$tabfieldinsert[22]= "code,label";
$tabfieldinsert[23]= "fk_pays,taux,accountancy_code_sell,accountancy_code_buy,note";
$tabfieldinsert[24]= "code,label";
-$tabfieldinsert[25]= "label,type_template,position,topic,content";
+$tabfieldinsert[25]= "label,type_template,private,position,topic,content,entity";
$tabfieldinsert[26]= "code,label,short_label";
$tabfieldinsert[27]= "code,libelle";
-$tabfieldinsert[28]= "code,label,affect,delay,newByMonth,fk_country";
+$tabfieldinsert[28]= "code,label,affect,delay,newbymonth,fk_country";
$tabfieldinsert[29]= "code,label,percent,position";
$tabfieldinsert[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
+$tabfieldinsert[31]= "pcg_version,fk_pays,label";
+$tabfieldinsert[32]= "code,label,range_account,position,fk_country";
+$tabfieldinsert[33]= "code,label";
+$tabfieldinsert[34]= "code,label";
// Nom du rowid si le champ n'est pas de type autoincrement
// Example: "" if id field is "rowid" and has autoincrement on
@@ -345,6 +375,10 @@ $tabrowid[27]= "id";
$tabrowid[28]= "";
$tabrowid[29]= "";
$tabrowid[30]= "";
+$tabrowid[31]= "";
+$tabrowid[32]= "";
+$tabrowid[33]= "rowid";
+$tabrowid[34]= "rowid";
// Condition to show dictionary in setup page
$tabcond=array();
@@ -378,6 +412,10 @@ $tabcond[27]= ! empty($conf->societe->enabled);
$tabcond[28]= ! empty($conf->holiday->enabled);
$tabcond[29]= ! empty($conf->projet->enabled);
$tabcond[30]= ! empty($conf->label->enabled);
+$tabcond[31]= ! empty($conf->accounting->enabled);
+$tabcond[32]= ! empty($conf->accounting->enabled);
+$tabcond[33]= ! empty($conf->hrm->enabled);
+$tabcond[34]= ! empty($conf->hrm->enabled);
// List of help for fields
$tabhelp=array();
@@ -408,9 +446,13 @@ $tabhelp[24] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[25] = array('topic'=>$langs->trans('SeeSubstitutionVars'),'content'=>$langs->trans('SeeSubstitutionVars'),'type_template'=>$langs->trans("TemplateForElement"),'private'=>$langs->trans("TemplateIsVisibleByOwnerOnly"), 'position'=>$langs->trans("PositionIntoComboList"));
$tabhelp[26] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[27] = array('code'=>$langs->trans("EnterAnyCode"));
-$tabhelp[28] = array('affect'=>$langs->trans("FollowedByACounter"),'delay'=>$langs->trans("MinimumNoticePeriod"), 'newByMonth'=>$langs->trans("NbAddedAutomatically"));
+$tabhelp[28] = array('affect'=>$langs->trans("FollowedByACounter"),'delay'=>$langs->trans("MinimumNoticePeriod"), 'newbymonth'=>$langs->trans("NbAddedAutomatically"));
$tabhelp[29] = array('code'=>$langs->trans("EnterAnyCode"), 'percent'=>$langs->trans("OpportunityPercent"), 'position'=>$langs->trans("PositionIntoComboList"));
$tabhelp[30] = array('code'=>$langs->trans("EnterAnyCode"), 'name'=>$langs->trans("LabelName"), 'paper_size'=>$langs->trans("LabelPaperSize"));
+$tabhelp[31] = array('pcg_version'=>$langs->trans("EnterAnyCode"));
+$tabhelp[32] = array('code'=>$langs->trans("EnterAnyCode"));
+$tabhelp[33] = array('code'=>$langs->trans("EnterAnyCode"));
+$tabhelp[34] = array('code'=>$langs->trans("EnterAnyCode"));
// List of check for fields (NOT USED YET)
$tabfieldcheck=array();
@@ -444,6 +486,10 @@ $tabfieldcheck[27] = array();
$tabfieldcheck[28] = array();
$tabfieldcheck[29] = array();
$tabfieldcheck[30] = array();
+$tabfieldcheck[31] = array();
+$tabfieldcheck[32] = array();
+$tabfieldcheck[33] = array();
+$tabfieldcheck[34] = array();
// Complete all arrays with entries found into modules
complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond,$tabhelp,$tabfieldcheck);
@@ -534,7 +580,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
$ok=1;
foreach ($listfield as $f => $value)
{
- if ($value == 'country_id' && in_array($tablib[$id],array('DictionaryVAT','DictionaryRegion','DictionaryCompanyType','DictionaryHolidayTypes','DictionaryRevenueStamp'))) continue; // For some pages, country is not mandatory
+ if ($value == 'country_id' && in_array($tablib[$id],array('DictionaryVAT','DictionaryRegion','DictionaryCompanyType','DictionaryHolidayTypes','DictionaryRevenueStamp','DictionaryAccountancysystem','DictionaryAccountancyCategory'))) continue; // For some pages, country is not mandatory
if ($value == 'country' && in_array($tablib[$id],array('DictionaryCanton','DictionaryCompanyType','DictionaryRevenueStamp'))) continue; // For some pages, country is not mandatory
if ($value == 'localtax1' && empty($_POST['localtax1_type'])) continue;
if ($value == 'localtax2' && empty($_POST['localtax2_type'])) continue;
@@ -952,6 +998,7 @@ if ($id)
if ($fieldlist[$field]=='sortorder') { $valuetoshow=$langs->trans("SortOrder"); }
if ($fieldlist[$field]=='short_label') { $valuetoshow=$langs->trans("ShortLabel"); }
if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); }
+ if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Range"); }
if ($id == 2) // Special cas for state page
{
@@ -1119,6 +1166,7 @@ if ($id)
if ($fieldlist[$field]=='sortorder') { $valuetoshow=$langs->trans("SortOrder"); }
if ($fieldlist[$field]=='short_label') { $valuetoshow=$langs->trans("ShortLabel"); }
if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); }
+ if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Range"); }
// Affiche nom du champ
if ($showfield)
@@ -1341,8 +1389,10 @@ if ($id)
$valuetoshow = length_accountg($valuetoshow);
}
+ $class='tddict';
+ if ($fieldlist[$field] == 'tracking') $class.=' tdoverflowauto';
// Show value for field
- if ($showfield) print '
';
+ }
+ }
+ }
+ // Fields from hook
+ $parameters=array('arrayfields'=>$arrayfields);
+ $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+ // Date creation
+ if (! empty($arrayfields['p.datec']['checked']))
+ {
+ print '
';
+ print '
';
+ }
+ // Date modification
+ if (! empty($arrayfields['p.tms']['checked']))
+ {
+ print '
';
+ print '
';
+ }
+ // Status
+ if (! empty($arrayfields['p.fk_statut']['checked']))
+ {
+ print '
';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ }
+ }
+ // Fields from hook
+ $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
+ $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+ // Date creation
+ if (! empty($arrayfields['p.datec']['checked']))
+ {
+ print '
';
+
+ }
+ $db->free($result);
+
+ $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
+ $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+
print '
';
+ }
+
// TODO How record was recorded OrderMode (llx_c_input_method)
// Project
@@ -2255,18 +2284,6 @@ if ($action == 'create' && $user->rights->commande->creer)
print '';
}
- if ($soc->outstanding_limit)
- {
- // Outstanding Bill
- print '
';
+ }
+ }
+ }
+ // Fields from hook
+ $parameters=array('arrayfields'=>$arrayfields);
+ $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+ // Date creation
+ if (! empty($arrayfields['c.datec']['checked']))
+ {
+ print '
';
-
- // Show shippable Icon (create subloop, so may be slow)
- if ($conf->stock->enabled)
+ if (! empty($arrayfields['c.ref']['checked']))
{
- $langs->load("stocks");
- if (($objp->fk_statut > 0) && ($objp->fk_statut < 3))
+ print '
';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ }
+ }
+ // Fields from hook
+ $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
+ $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+ // Date creation
+ if (! empty($arrayfields['c.datec']['checked']))
+ {
+ print '
';
+
}
+ $db->free($resql);
+
+ $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
+ $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+
print '
';
+ }
+ }
+ }
+ // Fields from hook
+ $parameters=array('arrayfields'=>$arrayfields);
+ $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+ // Date creation
+ if (! empty($arrayfields['f.datec']['checked']))
+ {
+ print '
';
+ print '
';
+ }
+ // Date modification
+ if (! empty($arrayfields['f.tms']['checked']))
+ {
+ print '
';
+ print '
';
+ }
+ // Status
+ if (! empty($arrayfields['f.fk_statut']['checked']))
+ {
+ print '
';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ }
+ }
+ // Fields from hook
+ $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
+ $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+ // Date creation
+ if (! empty($arrayfields['f.datec']['checked']))
+ {
+ print '
\n";
- print "\n";
$db->free($resql);
+
+ $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
+ $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+
+ print "
'."\n";
+ }
+ // Other attributes
+ $parameters=array('colspan' => ' colspan="1"');
+ $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
+
print '
';
- print " ";
+ dol_fiche_end();
print '
';
print '';
@@ -210,8 +225,6 @@ if ($_GET["action"] == 'create')
if ($id)
{
- if ($mesg) print $mesg;
-
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/compta/localtax/card.php?id='.$vatpayment->id;
$head[$h][1] = $langs->trans('Card');
@@ -255,9 +268,14 @@ if ($id)
}
}
- print '
';
+ // Other attributes
+ $parameters=array('colspan' => ' colspan="3"');
+ $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$vatpayment,$action); // Note that $action and $object may have been modified by hook
+
+ print '
';
- print '';
+ dol_fiche_end();
+
/*
* Boutons d'actions
diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php
index ac30e529839..b4cea5b4982 100644
--- a/htdocs/compta/localtax/clients.php
+++ b/htdocs/compta/localtax/clients.php
@@ -168,9 +168,11 @@ if($conf->global->$calc ==0 || $conf->global->$calc == 2)
$parameters["start"] = $date_start;
$parameters["end"] = $date_end;
$parameters["direction"] = 'sell';
+ $parameters["type"] = 'localtax'.$local;
+
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('externalbalance'));
- $reshook=$hookmanager->executeHooks('addStatisticLine',$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($coll_list))
{
@@ -244,7 +246,9 @@ if($conf->global->$calc ==0 || $conf->global->$calc == 1){
$coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'buy');
$parameters["direction"] = 'buy';
- $reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+ $parameters["type"] = 'localtax'.$local;
+
+ $reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if (is_array($coll_list))
{
$var=true;
diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php
index 3bed627402e..d7b6b897ec3 100644
--- a/htdocs/compta/localtax/index.php
+++ b/htdocs/compta/localtax/index.php
@@ -27,10 +27,15 @@ require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$langs->load("other");
+$langs->load("compta");
+$langs->load("banks");
+$langs->load("bills");
+
$localTaxType=GETPOST('localTaxType', 'int');
-$year=$_GET["year"];
-if ($year == 0 ) {
+$year=GETPOST("year","int");
+if ($year == 0)
+{
$year_current = strftime("%Y",time());
$year_start = $year_current;
} else {
@@ -122,25 +127,24 @@ if($localTaxType==1) {
$textprevyear="".img_previous()."";
$textnextyear=" ".img_next()."";
-print load_fiche_titre($langs->transcountry($LT,$mysoc->country_code),"$textprevyear ".$langs->trans("Year")." $year_start $textnextyear");
+print load_fiche_titre($langs->transcountry($LT,$mysoc->country_code),"$textprevyear ".$langs->trans("Year")." $year_start $textnextyear", 'title_accountancy.png');
print $langs->trans("LTReportBuildWithOptionDefinedInModule").' ';
print '('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').') ';
print ' ';
-print '
';
}
else
{
- print $form->showrefnav($object,'ref',$linkback, 1, 'number');
+ print $form->showrefnav($object,'ref',$linkback, 1, 'ref');
}
print '';
@@ -796,7 +796,7 @@ if ($action != 'new')
if ($object->statut == 1)
{
$filename=dol_sanitizeFileName($object->ref);
- $filedir=$dir.get_exdir($object->number,0,1,0,$object,'cheque') . 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;
$formfile->show_documents('remisecheque', $filename, $filedir, $urlsource, 1, 1);
diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php
index e70993bcaed..6ab43a277c0 100644
--- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php
+++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php
@@ -2,7 +2,7 @@
/* Copyright (C) 2006 Rodolphe Quiedeville
* Copyright (C) 2007-2011 Laurent Destailleur
* Copyright (C) 2005-2009 Regis Houssin
- * Copyright (C) 2011-2015 Juanjo Menent
+ * Copyright (C) 2011-2016 Juanjo Menent
* Copyright (C) 2015 Marcos GarcÃa
*
* This program is free software; you can redistribute it and/or modify
@@ -47,7 +47,7 @@ class RemiseCheque extends CommonObject
public $account_label;
public $author_id;
public $nbcheque;
- public $number;
+ public $ref;
/**
* Constructor
@@ -72,14 +72,14 @@ class RemiseCheque extends CommonObject
{
global $conf;
- $sql = "SELECT bc.rowid, bc.datec, bc.fk_user_author, bc.fk_bank_account, bc.amount, bc.number, bc.statut, bc.nbcheque, bc.ref_ext";
+ $sql = "SELECT bc.rowid, bc.datec, bc.fk_user_author, bc.fk_bank_account, bc.amount, bc.ref, bc.statut, bc.nbcheque, bc.ref_ext";
$sql.= ", bc.date_bordereau as date_bordereau";
$sql.= ", ba.label as account_label";
$sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON bc.fk_bank_account = ba.rowid";
$sql.= " WHERE bc.entity = ".$conf->entity;
if ($id) $sql.= " AND bc.rowid = ".$id;
- if ($ref) $sql.= " AND bc.number = '".$this->db->escape($ref)."'";
+ if ($ref) $sql.= " AND bc.ref = '".$this->db->escape($ref)."'";
dol_syslog("RemiseCheque::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
@@ -99,13 +99,12 @@ class RemiseCheque extends CommonObject
if ($this->statut == 0)
{
- $this->number = "(PROV".$this->id.")";
+ $this->ref = "(PROV".$this->id.")";
}
else
{
- $this->number = $obj->number;
+ $this->ref = $obj->ref;
}
- $this->ref = $this->number;
}
$this->db->free($resql);
@@ -124,7 +123,7 @@ class RemiseCheque extends CommonObject
*
* @param User $user User making creation
* @param int $account_id Bank account for cheque receipt
- * @param int $limit Limit number of cheque to this
+ * @param int $limit Limit ref of cheque to this
* @param array $toRemise array with cheques to remise
* @return int <0 if KO, >0 if OK
*/
@@ -146,7 +145,7 @@ class RemiseCheque extends CommonObject
$sql.= ", fk_bank_account";
$sql.= ", statut";
$sql.= ", amount";
- $sql.= ", number";
+ $sql.= ", ref";
$sql.= ", entity";
$sql.= ", nbcheque";
$sql.= ", ref_ext";
@@ -177,7 +176,7 @@ class RemiseCheque extends CommonObject
if ($this->id > 0 && $this->errno == 0)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque";
- $sql.= " SET number='(PROV".$this->id.")'";
+ $sql.= " SET ref='(PROV".$this->id.")'";
$sql.= " WHERE rowid='".$this->id."';";
dol_syslog("RemiseCheque::Create", LOG_DEBUG);
@@ -345,13 +344,13 @@ class RemiseCheque extends CommonObject
$this->errno = 0;
$this->db->begin();
-
- $numref=$this->getNextNumber();
+
+ $numref = $this->getNextNumRef();
if ($this->errno == 0 && $numref)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque";
- $sql.= " SET statut = 1, number = '".$numref."'";
+ $sql.= " SET statut = 1, ref = '".$numref."'";
$sql.= " WHERE rowid = ".$this->id;
$sql.= " AND entity = ".$conf->entity;
$sql.= " AND statut = 0";
@@ -364,7 +363,7 @@ class RemiseCheque extends CommonObject
if ($num == 1)
{
- $this->number = $numref;
+ $this->ref = $numref;
$this->statut = 1;
}
else
@@ -394,46 +393,92 @@ class RemiseCheque extends CommonObject
}
}
-
/**
- * Old module for cheque receipt numbering
+ * Return next reference of cheque receipts not already used (or last reference)
+ * according to numbering module defined into constant FACTURE_ADDON
*
- * @return int Next number of cheque
+ * @param string $mode 'next' for next value or 'last' for last value
+ * @return string free ref or last ref
*/
- function getNextNumber()
+ function getNextNumRef($mode='next')
{
- global $conf;
+ global $conf, $db, $langs, $mysoc;
+ $langs->load("bills");
- $num=0;
+ // Clean parameters (if not defined or using deprecated value)
+ if (empty($conf->global->CHEQUERECEIPTS_ADDON)) $conf->global->CHEQUERECEIPTS_ADDON='mod_chequereceipt_mint';
+ else if ($conf->global->CHEQUERECEIPTS_ADDON=='thyme') $conf->global->CHEQUERECEIPTS_ADDON='mod_chequereceipt_thyme';
+ else if ($conf->global->CHEQUERECEIPTS_ADDON=='mint') $conf->global->CHEQUERECEIPTS_ADDON='mod_chequereceipt_mint';
- // We use +0 to convert varchar to number for mysql, use ::integer for postgres.
- // We must found a generic solution (Use a $db->toint function ?)
- $sql = "SELECT ";
- if ($this->db->type == 'pgsql') $sql.="MAX(number::integer)";
- else $sql.="MAX(number+0)";
- $sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque";
- $sql.= " WHERE entity = ".$conf->entity;
- $sql.= " AND number not like '(%'";
-
- dol_syslog("Remisecheque::getNextNumber", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
+ if (! empty($conf->global->CHEQUERECEIPTS_ADDON))
{
- $row = $this->db->fetch_row($resql);
- $num = $row[0];
- $this->db->free($resql);
+ $mybool=false;
+
+ $file = $conf->global->CHEQUERECEIPTS_ADDON.".php";
+ $classname = $conf->global->CHEQUERECEIPTS_ADDON;
+
+ // Include file with class
+ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
+
+ foreach ($dirmodels as $reldir) {
+
+ $dir = dol_buildpath($reldir."core/modules/cheque/");
+
+ // Load file with numbering class (if found)
+ if (is_file($dir.$file) && is_readable($dir.$file))
+ {
+ $mybool |= include_once $dir . $file;
+ }
+ }
+
+ // For compatibility
+ if (! $mybool)
+ {
+ $file = $conf->global->CHEQUERECEIPTS_ADDON.".php";
+ $classname = "mod_chequereceipt_".$conf->global->CHEQUERECEIPTS_ADDON;
+ $classname = preg_replace('/\-.*$/','',$classname);
+ // Include file with class
+ foreach ($conf->file->dol_document_root as $dirroot)
+ {
+ $dir = $dirroot."/core/modules/cheque/";
+
+ // Load file with numbering class (if found)
+ if (is_file($dir.$file) && is_readable($dir.$file)) {
+ $mybool |= include_once $dir . $file;
+ }
+ }
+ }
+
+ if (! $mybool)
+ {
+ dol_print_error('',"Failed to include file ".$file);
+ return '';
+ }
+
+ $obj = new $classname();
+ $numref = "";
+ $numref = $obj->getNextValue($mysoc,$this);
+
+ /**
+ * $numref can be empty in case we ask for the last value because if there is no invoice created with the
+ * set up mask.
+ */
+ if ($mode != 'last' && !$numref) {
+ dol_print_error($db,"ChequeReceipts::getNextNumRef ".$obj->error);
+ return "";
+ }
+
+ return $numref;
}
else
{
- $this->errno = -1034;
- dol_syslog("Remisecheque::Validate Erreur SELECT ($this->errno)", LOG_ERR);
+ $langs->load("errors");
+ print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete");
+ return "";
}
-
- $num++;
-
- return $num;
}
+
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
@@ -502,7 +547,7 @@ class RemiseCheque extends CommonObject
dol_syslog("RemiseCheque::generatePdf model=".$model." id=".$this->id, LOG_DEBUG);
- $dir=DOL_DOCUMENT_ROOT ."/core/modules/cheque/pdf/";
+ $dir=DOL_DOCUMENT_ROOT ."/core/modules/cheque/doc/";
// Charge le modele
$file = "pdf_".$model.".class.php";
@@ -540,7 +585,7 @@ class RemiseCheque extends CommonObject
}
}
$docmodel->nbcheque = $this->nbcheque;
- $docmodel->number = $this->number;
+ $docmodel->ref = $this->ref;
$docmodel->amount = $this->amount;
$docmodel->date = $this->date_bordereau;
@@ -552,7 +597,7 @@ class RemiseCheque extends CommonObject
// We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8.
$sav_charseSupprimert_output=$outputlangs->charset_output;
- $result=$docmodel->write_file($this, $conf->banque->dir_output.'/bordereau', $this->number, $outputlangs);
+ $result=$docmodel->write_file($this, $conf->banque->dir_output.'/bordereau', $this->ref, $outputlangs);
if ($result > 0)
{
//$outputlangs->charset_output=$sav_charset_output;
@@ -838,18 +883,18 @@ class RemiseCheque extends CommonObject
}
/**
- * Set the number of bordereau
+ * Set the ref of bordereau
*
* @param User $user Object user
- * @param int $number number of bordereau
+ * @param int $ref ref of bordereau
* @return int <0 if KO, >0 if OK
*/
- function set_number($user, $number)
+ function set_number($user, $ref)
{
if ($user->rights->banque->cheque)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque";
- $sql.= " SET number = '".$number."'" ;
+ $sql.= " SET ref = '".$ref."'" ;
$sql.= " WHERE rowid = ".$this->id;
dol_syslog("RemiseCheque::set_number", LOG_DEBUG);
@@ -870,6 +915,29 @@ class RemiseCheque extends CommonObject
}
}
+ /**
+ * Initialise an instance with random values.
+ * Used to build previews or test instances.
+ * id must be 0 if object instance is a specimen.
+ *
+ * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines
+ * @return void
+ */
+ function initAsSpecimen($option='')
+ {
+ global $user,$langs,$conf;
+
+ $now=dol_now();
+ $arraynow=dol_getdate($now);
+ $nownotime=dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']);
+
+ // Initialize parameters
+ $this->id=0;
+ $this->ref = 'SPECIMEN';
+ $this->specimen=1;
+ $this->date_bordereau = $nownotime;
+ }
+
/**
* Return clicable name (with picto eventually)
*
diff --git a/htdocs/compta/paiement/cheque/index.php b/htdocs/compta/paiement/cheque/index.php
index ebe9f6e8461..887868fb594 100644
--- a/htdocs/compta/paiement/cheque/index.php
+++ b/htdocs/compta/paiement/cheque/index.php
@@ -2,6 +2,7 @@
/* Copyright (C) 2006 Rodolphe Quiedeville
* Copyright (C) 2007-2011 Laurent Destailleur
* Copyright (C) 2009 Regis Houssin
+ * Copyright (C) 2016 Juanjo Menent
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -94,7 +95,7 @@ print '
';
$max=10;
-$sql = "SELECT bc.rowid, bc.date_bordereau as db, bc.amount, bc.number as ref";
+$sql = "SELECT bc.rowid, bc.date_bordereau as db, bc.amount, bc.ref as ref";
$sql.= ", bc.statut, bc.nbcheque";
$sql.= ", ba.label, ba.rowid as bid";
$sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc";
diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php
index 5b4929ae42b..1493ba1b99a 100644
--- a/htdocs/compta/paiement/cheque/list.php
+++ b/htdocs/compta/paiement/cheque/list.php
@@ -3,6 +3,7 @@
* Copyright (C) 2007-2009 Laurent Destailleur
* Copyright (C) 2009-2012 Regis Houssin
* Copyright (C) 2014 Alexandre Spangaro
+ * Copyright (C) 2016 Juanjo Menent
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -77,7 +78,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both
llxHeader('',$langs->trans("ChequesReceipts"));
-$sql = "SELECT bc.rowid, bc.number as ref, bc.date_bordereau as dp,";
+$sql = "SELECT bc.rowid, bc.ref as ref, bc.date_bordereau as dp,";
$sql.= " bc.nbcheque, bc.amount, bc.statut,";
$sql.= " ba.rowid as bid, ba.label";
$sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc,";
@@ -86,7 +87,7 @@ $sql.= " WHERE bc.fk_bank_account = ba.rowid";
$sql.= " AND bc.entity = ".$conf->entity;
// Search criteria
-if ($search_ref) $sql.=" AND bc.number=".$search_ref;
+if ($search_ref) $sql.=" AND bc.ref=".$search_ref;
if ($search_account > 0) $sql.=" AND bc.fk_bank_account=".$search_account;
if ($search_amount) $sql.=" AND bc.amount='".$db->escape(price2num(trim($search_amount)))."'";
if ($month > 0)
@@ -134,7 +135,7 @@ if ($resql)
print '
';
if (! empty($conf->banque->enabled))
{
- if ($vatpayment->fk_account > 0)
+ if ($object->fk_account > 0)
{
$bankline=new AccountLine($db);
- $bankline->fetch($vatpayment->fk_bank);
+ $bankline->fetch($object->fk_bank);
print '
';
print '
'.$langs->trans('BankTransactionLine').'
';
@@ -344,21 +357,22 @@ if ($id)
// Other attributes
$parameters=array('colspan' => ' colspan="3"');
- $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$vatpayment,$action); // Note that $action and $object may have been modified by hook
+ $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
print '
\n";
- if ($vatpayment->rappro == 0)
+ if ($object->rappro == 0)
{
if (! empty($user->rights->tax->charges->supprimer))
{
- print ''.$langs->trans("Delete").'';
+ print ''.$langs->trans("Delete").'';
}
else
{
diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php
index b0d7a9bce30..a22ca9abd3a 100644
--- a/htdocs/compta/tva/clients.php
+++ b/htdocs/compta/tva/clients.php
@@ -250,9 +250,11 @@ $parameters["mode"] = $modetax;
$parameters["start"] = $date_start;
$parameters["end"] = $date_end;
$parameters["direction"] = 'sell';
+$parameters["type"] = 'vat';
+
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('externalbalance'));
-$reshook=$hookmanager->executeHooks('addStatisticLine',$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($coll_list)) {
$var=true;
@@ -333,7 +335,7 @@ $company_static=new Societe($db);
$coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'buy');
$parameters["direction"] = 'buy';
-$reshook=$hookmanager->executeHooks('addStatisticLine',$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($coll_list)) {
$var=true;
$total = 0; $totalamount = 0;
diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php
index dc2be67e44f..f6308a3790d 100644
--- a/htdocs/compta/tva/index.php
+++ b/htdocs/compta/tva/index.php
@@ -56,7 +56,7 @@ if (isset($_GET["modetax"])) $modetax=$_GET["modetax"];
/**
- * pt
+ * print function
*
* @param DoliDB $db Database handler
* @param string $sql SQL Request
@@ -161,9 +161,11 @@ for ($m = 1 ; $m < 13 ; $m++ )
$parameters["mode"] = $modetax;
$parameters["year"] = $y;
$parameters["month"] = $m;
+ $parameters["type"] = 'vat';
+
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('externalbalance'));
- $reshook=$hookmanager->executeHooks('addStatisticLine',$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($coll_listbuy) && $coll_listbuy == -1)
{
diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php
index e04530a9dc7..28ce4e50e24 100644
--- a/htdocs/compta/tva/quadri_detail.php
+++ b/htdocs/compta/tva/quadri_detail.php
@@ -325,10 +325,12 @@ else
$parameters["mode"] = $modetax;
$parameters["start"] = $date_start;
$parameters["end"] = $date_end;
+ $parameters["type"] = 'vat';
+
$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('addStatisticLine',$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)
{
diff --git a/htdocs/compta/tva/quarter_report.php b/htdocs/compta/tva/quarter_report.php
index 61d019894e8..626a0fd6c34 100644
--- a/htdocs/compta/tva/quarter_report.php
+++ b/htdocs/compta/tva/quarter_report.php
@@ -378,10 +378,12 @@ if (!is_array($x_coll) || !is_array($x_paye)) {
$parameters["mode"] = $modetax;
$parameters["start"] = $date_start;
$parameters["end"] = $date_end;
+ $parameters["type"] = 'vat';
+
$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('addStatisticLine',$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;
diff --git a/htdocs/compta/tva/reglement.php b/htdocs/compta/tva/reglement.php
index 9615bec99f1..f6dd0be53c2 100644
--- a/htdocs/compta/tva/reglement.php
+++ b/htdocs/compta/tva/reglement.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2004-2015 Laurent Destailleur
+ * Copyright (C) 2004-2016 Laurent Destailleur
* Copyright (C) 2005-2009 Regis Houssin
* Copyright (C) 2011-2014 Alexandre Spangaro
*
@@ -91,7 +91,7 @@ $form = new Form($db);
$formother=new FormOther($db);
$tva_static = new Tva($db);
-$sql = "SELECT t.rowid, t.amount, t.label, t.datev as dm, t.fk_typepayment as type, t.num_payment, pst.code as payment_code";
+$sql = "SELECT t.rowid, t.amount, t.label, t.datev as dv, t.datep as dp, t.fk_typepayment as type, t.num_payment, pst.code as payment_code";
$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.= " WHERE t.entity = ".$conf->entity;
@@ -151,7 +151,8 @@ if ($result)
print '
\n";
+ // Type
print $type;
// Amount
$total = $total + $obj->amount;
diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index fca007bfd1f..5dbeeb951dd 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -314,13 +314,9 @@ if (empty($reshook))
else
{
$object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
- // Create small thumbs for company (Ratio is near 16/9)
- // Used on logon for example
- $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality);
- // Create mini thumbs for company (Ratio is near 16/9)
- // Used on menu or for setup page for example
- $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality);
+ // Create thumbs
+ $object->addThumbs($newfile);
}
}
}
@@ -797,7 +793,7 @@ else
{
print '
';
// Name
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index c8903d8d363..b38787a4067 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -1189,7 +1189,11 @@ if ($action == 'create')
dol_fiche_end();
- print '';
+ print '
';
+ print '';
+ print ' ';
+ print '';
+ print '
';
if (is_object($objectsrc))
{
diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php
index 395e484075d..8f3c87725fa 100644
--- a/htdocs/contrat/class/contrat.class.php
+++ b/htdocs/contrat/class/contrat.class.php
@@ -8,7 +8,7 @@
* Copyright (C) 2013 Christophe Battarel
* Copyright (C) 2013 Florian Henry
* Copyright (C) 2014-2015 Marcos GarcÃa
- * Copyright (C) 2015 Ferran Marcet
+ * Copyright (C) 2015-2016 Ferran Marcet
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1514,7 +1514,7 @@ class Contrat extends CommonObject
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
$localtaxes_type=getLocalTaxesFromRate($tvatx, 0, $this->societe, $mysoc);
- $txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate.
+ $tvatx = preg_replace('/\s*\(.*\)/','',$tvatx); // Remove code into vatrate.
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $tvatx, $localtax1tx, $localtax2tx, 0, $price_base_type, $info_bits, 1, $mysoc, $localtaxes_type);
$total_ht = $tabprice[0];
diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php
index 49466c7fcb0..95da343e3af 100644
--- a/htdocs/contrat/document.php
+++ b/htdocs/contrat/document.php
@@ -77,7 +77,7 @@ $modulepart='contract';
/*
* Actions
*/
-include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
+include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
/*
diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php
index df6e0007023..11d05c60a49 100644
--- a/htdocs/contrat/list.php
+++ b/htdocs/contrat/list.php
@@ -321,7 +321,7 @@ if ($resql)
print '
@@ -52,6 +45,4 @@ foreach($linkedObjectBlock as $key => $objectlink)
-
-
\ No newline at end of file
diff --git a/htdocs/core/tpl/document_actions_pre_headers.tpl.php b/htdocs/core/actions_linkedfiles.inc.php
similarity index 97%
rename from htdocs/core/tpl/document_actions_pre_headers.tpl.php
rename to htdocs/core/actions_linkedfiles.inc.php
index 1c0d8a8367f..22ff9155fd1 100644
--- a/htdocs/core/tpl/document_actions_pre_headers.tpl.php
+++ b/htdocs/core/actions_linkedfiles.inc.php
@@ -19,10 +19,6 @@
*/
-// TODO This is an action include, not a presentation template.
-// Move this file into htdocs/core/actions_document.inc.php
-
-
// Variable $upload_dir must be defined when entering here
// Variable $upload_dirold may also exists.
diff --git a/htdocs/core/ajax/contacts.php b/htdocs/core/ajax/contacts.php
index c0cd9ecfd70..c3788a8baeb 100644
--- a/htdocs/core/ajax/contacts.php
+++ b/htdocs/core/ajax/contacts.php
@@ -1,5 +1,6 @@
+/* Copyright (C) 2012 Regis Houssin
+ * Copyright (C) 2016 Laurent Destailleur
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php
index 2114fe04b50..b4ea22d59eb 100644
--- a/htdocs/core/ajax/selectsearchbox.php
+++ b/htdocs/core/ajax/selectsearchbox.php
@@ -34,6 +34,8 @@ if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
$res=@include '../../main.inc.php';
include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
+//global $hookmanager;
+$hookmanager->initHooks(array('searchform'));
$search_boxvalue=GETPOST('q');
@@ -71,32 +73,34 @@ if (! empty($conf->user->enabled) && empty($conf->global->MAIN_SEARCHFORM_PROJEC
$arrayresult['searchintouser']=array('text'=>img_picto('','object_user').' '.$langs->trans("SearchIntoUsers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/user/index.php?sall='.urlencode($search_boxvalue));
}
-if (! empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->rights->facture->lire)
+if (! empty($conf->propal->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_PROPAL_DISABLED) && $user->rights->propal->lire)
{
- $arrayresult['searchintoinvoice']=array('text'=>img_picto('','object_bill').' '.$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/compta/facture/list.php?sall='.urlencode($search_boxvalue));
+ $arrayresult['searchintopropal']=array('text'=>img_picto('','object_propal').' '.$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/comm/propal/list.php?sall='.urlencode($search_boxvalue));
}
-
if (! empty($conf->commande->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_ORDER_DISABLED) && $user->rights->commande->lire)
{
$arrayresult['searchintoorder']=array('text'=>img_picto('','object_order').' '.$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/commande/list.php?sall='.urlencode($search_boxvalue));
}
-
-if (! empty($conf->propal->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_PROPAL_DISABLED) && $user->rights->propal->lire)
+if (! empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->rights->facture->lire)
{
- $arrayresult['searchintopropal']=array('text'=>img_picto('','object_propal').' '.$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/comm/propal/list.php?sall='.urlencode($search_boxvalue));
+ $arrayresult['searchintoinvoice']=array('text'=>img_picto('','object_bill').' '.$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/compta/facture/list.php?sall='.urlencode($search_boxvalue));
+}
+if (! empty($conf->expedition->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_SHIPMENT_DISABLED) && $user->rights->expedition->lire)
+{
+ $arrayresult['searchintoshipment']=array('text'=>img_picto('','object_sending').' '.$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expedition/list.php?sall='.urlencode($search_boxvalue));
}
-if (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) && $user->rights->fournisseur->facture->lire)
+if (! empty($conf->supplier_proposal->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_PROPAL_DISABLED) && $user->rights->supplier_proposal->lire)
{
- $arrayresult['searchintosupplierinvoice']=array('text'=>img_picto('','object_bill').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php?sall='.urlencode($search_boxvalue));
+ $arrayresult['searchintosupplierpropal']=array('text'=>img_picto('','object_propal').' '.$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/supplier_proposal/list.php?sall='.urlencode($search_boxvalue));
}
if (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED) && $user->rights->fournisseur->commande->lire)
{
$arrayresult['searchintosupplierorder']=array('text'=>img_picto('','object_order').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php?search_all='.urlencode($search_boxvalue));
}
-if (! empty($conf->supplier_proposal->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_PROPAL_DISABLED) && $user->rights->supplier_proposal->lire)
+if (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) && $user->rights->fournisseur->facture->lire)
{
- $arrayresult['searchintosupplierpropal']=array('text'=>img_picto('','object_propal').' '.$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/supplier_proposal/list.php?sall='.urlencode($search_boxvalue));
+ $arrayresult['searchintosupplierinvoice']=array('text'=>img_picto('','object_bill').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php?sall='.urlencode($search_boxvalue));
}
if (! empty($conf->contrat->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTRACT_DISABLED) && $user->rights->contrat->lire)
@@ -113,7 +117,7 @@ if (! empty($conf->expensereport->enabled) && empty($conf->global->MAIN_SEARCHFO
}
-/* Do we really need this. We already have a select for users, and we should be able to filter into user list on employee flag
+/* Do we really need this. We already have a select for users, and we should be able to filter into user list on employee flag
if (! empty($conf->hrm->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_EMPLOYEE) && $user->rights->hrm->employee->read)
{
$langs->load("hrm");
@@ -122,9 +126,7 @@ if (! empty($conf->hrm->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_EMPLO
*/
// Execute hook addSearchEntry
-$hookmanager->initHooks(array('searchform','leftblock'));
-
-$parameters=array();
+$parameters=array('search_boxvalue'=>$search_boxvalue);
$reshook=$hookmanager->executeHooks('addSearchEntry',$parameters);
if (empty($reshook))
{
@@ -133,7 +135,6 @@ if (empty($reshook))
else $arrayresult=$hookmanager->resArray;
-
print json_encode($arrayresult);
if (is_object($db)) $db->close();
diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php
index ca851961857..46ddccc2a1d 100644
--- a/htdocs/core/boxes/box_graph_product_distribution.php
+++ b/htdocs/core/boxes/box_graph_product_distribution.php
@@ -31,9 +31,10 @@ class box_graph_product_distribution extends ModeleBoxes
var $boxcode="productdistribution";
var $boximg="object_product";
var $boxlabel="BoxProductDistribution";
- var $depends = array("product|service");
+ var $depends = array("product|service","facture|propal|commande");
var $db;
+ var $param;
var $info_box_head = array();
var $info_box_contents = array();
diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php
index 359384b5c4d..bfe427db708 100644
--- a/htdocs/core/boxes/modules_boxes.php
+++ b/htdocs/core/boxes/modules_boxes.php
@@ -260,7 +260,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty"
$out.= '
';
// The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object
$out.= img_picto($langs->trans("MoveBox",$this->box_id),'grip_title','class="boxhandle hideonsmartphone" style="cursor:move;"');
- $out.= img_picto($langs->trans("Close2",$this->box_id),'close_title','class="boxclose" rel="x:y" style="cursor:pointer;" id="imgclose'.$this->box_id.'"');
+ $out.= img_picto($langs->trans("CloseBox",$this->box_id),'close_title','class="boxclose" rel="x:y" style="cursor:pointer;" id="imgclose'.$this->box_id.'"');
$label=$head['text'];
if (! empty($head['graph'])) $label.=' ('.$langs->trans("Graph").')';
$out.= '';
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index a65573a7947..7de64135245 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -1733,10 +1733,10 @@ abstract class CommonObject
* Save a new position (field rang) for details lines.
* You can choose to set position for lines with already a position or lines without any position defined.
*
- * @param boolean $renum true to renum all already ordered lines, false to renum only not already ordered lines.
- * @param string $rowidorder ASC or DESC
- * @param boolean $fk_parent_line Table with fk_parent_line field or not
- * @return void
+ * @param boolean $renum True to renum all already ordered lines, false to renum only not already ordered lines.
+ * @param string $rowidorder ASC or DESC
+ * @param boolean $fk_parent_line Table with fk_parent_line field or not
+ * @return int <0 if KO, >0 if OK
*/
function line_order($renum=false, $rowidorder='ASC', $fk_parent_line=true)
{
@@ -1813,6 +1813,7 @@ abstract class CommonObject
dol_print_error($this->db);
}
}
+ return 1;
}
/**
@@ -2154,9 +2155,9 @@ abstract class CommonObject
* Must be called at end of methods addline or updateline.
*
* @param int $exclspec >0 = Exclude special product (product_type=9)
- * @param string $roundingadjust 'none'=Do nothing, 'auto'=Use default method (MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND if defined, or '0'), '0'=Force use total of rounding, '1'=Force use rounding of total
+ * @param string $roundingadjust 'none'=Do nothing, 'auto'=Use default method (MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND if defined, or '0'), '0'=Force mode total of rounding, '1'=Force mode rounding of total
* @param int $nodatabaseupdate 1=Do not update database. Update only properties of object.
- * @param Societe $seller If roundingadjust is '0' or '1', it means we recalculate total for lines before calculating total for object and for this, we need seller object.
+ * @param Societe $seller If roundingadjust is '0' or '1' or maybe 'auto', it means we recalculate total for lines before calculating total for object and for this, we need seller object.
* @return int <0 if KO, >0 if OK
*/
function update_price($exclspec=0,$roundingadjust='none',$nodatabaseupdate=0,$seller=null)
@@ -2939,10 +2940,72 @@ abstract class CommonObject
return price2num($total_discount);
}
+
+ /**
+ * Return into unit=0, the calculated total of weight and volume of all lines * qty
+ * Calculate by adding weight and volume of each product line, so properties ->volume/volume_units/weight/weight_units must be loaded on line.
+ *
+ * @return array array('weight'=>...,'volume'=>...)
+ */
+ function getTotalWeightVolume()
+ {
+ $weightUnit=0;
+ $volumeUnit=0;
+ $totalWeight = '';
+ $totalVolume = '';
+ $totalOrdered = ''; // defined for shipment only
+ $totalToShip = ''; // defined for shipment only
+
+ foreach ($this->lines as $line)
+ {
+
+ $totalOrdered+=$line->qty_asked; // defined for shipment only
+ $totalToShip+=$line->qty_shipped; // defined for shipment only
+
+ // Define qty, weight, volume, weight_units, volume_units
+ if ($this->element == 'shipping') $qty=$line->qty_shipped; // for shipments
+ else $qty=$line->qty;
+ $weight=$line->weight;
+ $volume=$line->volume;
+ $weight_units=$line->weight_units;
+ $volume_units=$line->volume_units;
+
+ $weightUnit=0;
+ $volumeUnit=0;
+ if (! empty($weight_units)) $weightUnit = $weight_units;
+ if (! empty($volume_units)) $volumeUnit = $volume_units;
+
+ //var_dump($line->volume_units);
+ if ($weight_units < 50) // >50 means a standard unit (power of 10 of official unit) > 50 means an exotic unit (like inch)
+ {
+ $trueWeightUnit=pow(10, $weightUnit);
+ $totalWeight += $weight * $qty * $trueWeightUnit;
+ }
+ else
+ {
+ $totalWeight += $weight * $qty; // This may be wrong if we mix different units
+ }
+ if ($volume_units < 50) // >50 means a standard unit (power of 10 of official unit) > 50 means an exotic unit (like inch)
+ {
+ //print $line->volume."x".$line->volume_units."x".($line->volume_units < 50)."x".$volumeUnit;
+ $trueVolumeUnit=pow(10, $volumeUnit);
+ //print $line->volume;
+ $totalVolume += $volume * $qty * $trueVolumeUnit;
+ }
+ else
+ {
+ $totalVolume += $volume * $qty; // This may be wrong if we mix different units
+ }
+ }
+
+ return array('weight'=>$totalWeight, 'volume'=>$totalVolume, 'ordered'=>$totalOrdered, 'toship'=>$totalToShip);
+ }
+
+
/**
* Set extra parameters
*
- * @return void
+ * @return int <0 if KO, >0 if OK
*/
function setExtraParameters()
{
@@ -3029,7 +3092,7 @@ abstract class CommonObject
{
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET fk_incoterms = ".($id_incoterm > 0 ? $id_incoterm : "null");
- $sql.= ", location_incoterms = '".($id_incoterm > 0 ? $this->db->escape($location) : "null")."'";
+ $sql.= ", location_incoterms = ".($id_incoterm > 0 ? "'".$this->db->escape($location)."'" : "null");
$sql.= " WHERE rowid = " . $this->id;
dol_syslog(get_class($this).'::setIncoterms', LOG_DEBUG);
$resql=$this->db->query($sql);
@@ -3210,18 +3273,18 @@ abstract class CommonObject
if ($inputalsopricewithtax) print '
';
}
if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id))
@@ -3238,10 +3301,10 @@ abstract class CommonObject
}
// Total HT
- print '
'.$langs->trans('TotalHTShort').'
';
+ print '
'.$langs->trans('TotalHTShort').'
';
// Multicurrency
- if (!empty($conf->multicurrency->enabled)) print '
'.$langs->trans('TotalHTShortCurrency').'
';
+ if (!empty($conf->multicurrency->enabled)) print '
'.$langs->trans('TotalHTShortCurrency').'
';
print '
'; // No width to allow autodim
@@ -3848,7 +3911,7 @@ abstract class CommonObject
* @param string $file Path file in UTF8 to original file to create thumbs from.
* @return void
*/
- function add_thumb($file)
+ function addThumbs($file)
{
global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality;
@@ -3880,15 +3943,15 @@ abstract class CommonObject
* 3) If not but a constant $conf->global->OBJECTELEMENT_FIELDNAME is set, we return it (It is better to use the dedicated table).
* 4) Return value found into database (TODO No yet implemented)
*
- * @param string $fieldname Name of field
- * @param string $alternatevalue Alternate value to use
- * @return string Default value
+ * @param string $fieldname Name of field
+ * @param string $alternatevalue Alternate value to use
+ * @return string|string[] Default value (can be an array if the GETPOST return an array)
**/
function getDefaultCreateValueFor($fieldname, $alternatevalue=null)
{
global $conf, $_POST;
- // If param is has been posted with use this value first.
+ // If param here has been posted, we use this value first.
if (isset($_POST[$fieldname])) return GETPOST($fieldname, 2);
if (isset($alternatevalue)) return $alternatevalue;
@@ -4329,7 +4392,7 @@ abstract class CommonObject
* @param DoliDB $db Database handler
* @param int $origin_id Old thirdparty id (the thirdparty to delete)
* @param int $dest_id New thirdparty id (the thirdparty that will received element of the other)
- * @param array $tables Tables that need to be changed
+ * @param string[] $tables Tables that need to be changed
* @return bool
*/
public static function commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables)
diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php
index 74d14af0819..8cacf7065b1 100644
--- a/htdocs/core/class/commonorder.class.php
+++ b/htdocs/core/class/commonorder.class.php
@@ -25,8 +25,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php';
/**
- * \class CommonOrder
- * \brief Superclass for orders classes
+ * Superclass for orders classes
*/
abstract class CommonOrder extends CommonObject
{
@@ -34,8 +33,7 @@ abstract class CommonOrder extends CommonObject
}
/**
- * \class CommonOrderLine
- * \brief Superclass for orders classes
+ * Superclass for orders classes
*/
abstract class CommonOrderLine extends CommonObjectLine
{
diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php
index 35c3b3909ef..8564a18822e 100644
--- a/htdocs/core/class/doleditor.class.php
+++ b/htdocs/core/class/doleditor.class.php
@@ -138,7 +138,7 @@ class DolEditor
/**
* Output edit area inside the HTML stream.
- * Output depends on this->tool (fckeditor, ckeditor, texatrea, ...)
+ * Output depends on this->tool (fckeditor, ckeditor, textarea, ...)
*
* @param int $noprint 1=Return HTML string instead of printing it to output
* @param string $morejs Add more js. For example: ".on( \'saveSnapshot\', function(e) { alert(\'ee\'); });"
diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php
index a38b034747b..e25709fd303 100644
--- a/htdocs/core/class/fileupload.class.php
+++ b/htdocs/core/class/fileupload.class.php
@@ -219,7 +219,7 @@ class FileUpload
}
/**
- * Enter description here ...
+ * getFileObject
*
* @param string $file_name Filename
* @return stdClass|NULL
@@ -247,7 +247,7 @@ class FileUpload
}
/**
- * Enter description here ...
+ * getFileObjects
*
* @return void
*/
@@ -257,11 +257,11 @@ class FileUpload
}
/**
- * Create thumbs
+ * Create thumbs of a file uploaded. Only the "mini" thumb is generated.
*
* @param string $file_name Filename
* @param string $options is array('max_width', 'max_height')
- * @return void
+ * @return boolean
*/
protected function createScaledImage($file_name, $options)
{
@@ -277,9 +277,8 @@ class FileUpload
return false;
}
- $res=vignette($file_path,$maxwidthmini,$maxheightmini,'_mini');
+ $res=vignette($file_path,$maxwidthmini,$maxheightmini,'_mini'); // We don't use ->addThumbs here because there is no object and we don't need all thumbs, only the "mini".
- //return $success;
if (preg_match('/error/i',$res)) return false;
return true;
}
@@ -296,7 +295,7 @@ class FileUpload
* @param string $file File
* @param string $error Error
* @param string $index Index
- * @return unknown|string
+ * @return boolean True if OK, False if KO
*/
protected function validate($uploaded_file, $file, $error, $index)
{
@@ -376,12 +375,12 @@ class FileUpload
}
/**
- * Enter description here ...
+ * trimFileName
*
- * @param unknown_type $name Filename
- * @param unknown_type $type ???
- * @param unknown_type $index ???
- * @return void
+ * @param string $name Filename
+ * @param string $type ???
+ * @param string $index ???
+ * @return string
*/
protected function trimFileName($name, $type, $index)
{
@@ -405,43 +404,7 @@ class FileUpload
}
/**
- * Enter description here ...
- *
- * @param unknown_type $file_path ???
- * @return int Success or not
- */
- protected function orientImage($file_path)
- {
- $exif = @exif_read_data($file_path);
- if ($exif === false) {
- return false;
- }
- $orientation = intval(@$exif['Orientation']);
- if (!in_array($orientation, array(3, 6, 8))) {
- return false;
- }
- $image = @imagecreatefromjpeg($file_path);
- switch ($orientation) {
- case 3:
- $image = @imagerotate($image, 180, 0);
- break;
- case 6:
- $image = @imagerotate($image, 270, 0);
- break;
- case 8:
- $image = @imagerotate($image, 90, 0);
- break;
- default:
- return false;
- }
- $success = imagejpeg($image, $file_path);
- // Free up memory (imagedestroy does not delete files):
- @imagedestroy($image);
- return $success;
- }
-
- /**
- * Enter description here ...
+ * handleFileUpload
*
* @param string $uploaded_file Uploade file
* @param string $name Name
diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php
index df24b5a36ca..f92056893b6 100644
--- a/htdocs/core/class/hookmanager.class.php
+++ b/htdocs/core/class/hookmanager.class.php
@@ -64,7 +64,7 @@ class HookManager
* class found into file /mymodule/class/actions_mymodule.class.php (if module has declared the context as a managed context).
* Then when a hook executeHooks('aMethod'...) is called, the method aMethod found into class will be executed.
*
- * @param array $arraycontext Array list of searched hooks tab/features. For example: 'thirdpartycard' (for hook methods into page card thirdparty), 'thirdpartydao' (for hook methods into Societe), ...
+ * @param string[] $arraycontext Array list of searched hooks tab/features. For example: 'thirdpartycard' (for hook methods into page card thirdparty), 'thirdpartydao' (for hook methods into Societe), ...
* @return int Always 1
*/
function initHooks($arraycontext)
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index cf1deea4bb8..082f362458b 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -74,14 +74,15 @@ class Form
*
* @param string $text Text of label or key to translate
* @param string $htmlname Name of select field ('edit' prefix will be added)
- * @param string $preselected Name of Value to show/edit (not used in this function)
+ * @param string $preselected Value to show/edit (not used in this function)
* @param object $object Object
* @param boolean $perm Permission to allow button to edit parameter. Set it to 0 to have a not edited field.
* @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...)
- * @param string $moreparam More param to add on a href URL
+ * @param string $moreparam More param to add on a href URL*
+ * @param int $fieldrequired 1 if we want to show field as mandatory using the fieldrequired CSS.
* @return string HTML edit field
*/
- function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata='string', $moreparam='')
+ function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata='string', $moreparam='', $fieldrequired=0)
{
global $conf,$langs;
@@ -94,18 +95,24 @@ class Form
{
$tmp=explode(':',$typeofdata);
$ret.= '
';
+ if ($fieldrequired) $ret.='';
$ret.= $langs->trans($text);
+ if ($fieldrequired) $ret.='';
$ret.= '
'."\n";
}
else
{
+ if ($fieldrequired) $ret.='';
$ret.= $langs->trans($text);
+ if ($fieldrequired) $ret.='';
}
}
else
{
if (GETPOST('action') != 'edit'.$htmlname && $perm) $ret.='
';
+ if ($fieldrequired) $ret.='';
$ret.=$langs->trans($text);
+ if ($fieldrequired) $ret.='';
if (GETPOST('action') != 'edit'.$htmlname && $perm) $ret.='
';
if (GETPOST('action') != 'edit'.$htmlname && $perm) $ret.='
'."\n";
$ret.=''."\n";
}
else
@@ -1338,7 +1345,7 @@ class Form
* @param int $maxlength Maximum length of string into list (0=no limit)
* @param int $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status
* @param string $morefilter Add more filters into sql request
- * @param string $show_every 0=default list, 1=add also a value "Everybody" at beginning of list
+ * @param integer $show_every 0=default list, 1=add also a value "Everybody" at beginning of list
* @param string $enableonlytext If option $enableonly is set, we use this text to explain into label why record is disabled. Not used if enableonly is empty.
* @param string $morecss More css
* @param int $noactive Show only active users (this will also happened whatever is this option if USER_HIDE_INACTIVE_IN_COMBOBOX is on).
@@ -2089,7 +2096,8 @@ class Form
$sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration, p.fk_product_type,";
$sql.= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,";
- $sql.= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name";
+ $sql.= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name,";
+ $sql.= " pfp.supplier_reputation";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
if ($socid) $sql.= " AND pfp.fk_soc = ".$socid;
@@ -2228,6 +2236,15 @@ class Form
$opt .= " - ".dol_trunc($objp->name,8);
$outval.=" - ".dol_trunc($objp->name,8);
}
+ if ($objp->supplier_reputation)
+ {
+ //TODO dictionnary
+ $reputations=array(''=>$langs->trans('Standard'),'FAVORITE'=>$langs->trans('Favorite'),'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier'));
+
+ $opt .= " - ".$reputations[$objp->supplier_reputation];
+ $outval.=" - ".$reputations[$objp->supplier_reputation];
+ }
+
}
else
{
@@ -2271,7 +2288,7 @@ class Form
*
* @param int $productid Id of product
* @param string $htmlname Name of HTML field
- * @return void
+ * @return string|null
*/
function select_product_fourn_price($productid,$htmlname='productfournpriceid')
{
@@ -2383,7 +2400,7 @@ class Form
* @param int $socid Id of company
* @param string $htmlname Name of HTML field
* @param int $showempty Add an empty field
- * @return void
+ * @return integer|null
*/
function select_address($selected, $socid, $htmlname='address_id',$showempty=0)
{
@@ -3634,7 +3651,7 @@ class Form
* @param int $displayhour Display hour selector
* @param int $displaymin Display minutes selector
* @param int $nooutput 1=No print output, return string
- * @return void
+ * @return string
* @see select_date
*/
function form_date($page, $selected, $htmlname, $displayhour=0, $displaymin=0, $nooutput=0)
@@ -4055,7 +4072,7 @@ class Form
/**
* Load into the cache vat rates of a country
*
- * @param string $country_code Country code
+ * @param string $country_code Country code with quotes ("'CA'", or "'CA,IN,...'")
* @return int Nb of loaded lines, 0 if already loaded, <0 if KO
*/
function load_cache_vatrates($country_code)
@@ -4131,11 +4148,18 @@ class Form
$return='';
- // Define defaultnpr and defaultttx
+ // Define defaultnpr, defaultttx and defaultcode
$defaultnpr=($info_bits & 0x01);
$defaultnpr=(preg_match('/\*/',$selectedrate) ? 1 : $defaultnpr);
$defaulttx=str_replace('*','',$selectedrate);
-
+ $defaultcode='';
+ if (preg_match('/\s*\((.*)\)/', $defaulttx, $reg))
+ {
+ $defaultcode=$reg[1];
+ $defaulttx=preg_replace('/\s*\(.*\)/','',$defaulttx);
+ }
+ //var_dump($defaulttx.'-'.$defaultnpr.'-'.$defaultcode);
+
// Check parameters
if (is_object($societe_vendeuse) && ! $societe_vendeuse->country_code)
{
@@ -4231,9 +4255,13 @@ class Form
$return.= $rate['nprtva'] ? '*': '';
if ($addcode && $rate['code']) $return.=' ('.$rate['code'].')';
$return.= '"';
- if ($rate['txtva'] == $defaulttx && $rate['nprtva'] == $defaultnpr)
+ if ($defaultcode)
{
- $return.= ' selected';
+ if ($defaultcode == $rate['code']) $return.= ' selected';
+ }
+ elseif ($rate['txtva'] == $defaulttx && $rate['nprtva'] == $defaultnpr)
+ {
+ $return.= ' selected';
}
$return.= '>'.vatrate($rate['libtva']);
//$return.=($rate['code']?' '.$rate['code']:'');
@@ -4274,7 +4302,7 @@ class Form
* @param int $fullday When a checkbox with this html name is on, hour and day are set with 00:00 or 23:59
* @param string $addplusone Add a link "+1 hour". Value must be name of another select_date field.
* @param datetime $adddateof Add a link "Date of invoice" using the following date.
- * @return mixed Nothing or string if nooutput is 1
+ * @return string|null Nothing or string if nooutput is 1
* @see form_date
*/
function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowlink=0, $nooutput=0, $disabled=0, $fullday='', $addplusone='', $adddateof='')
@@ -4557,9 +4585,9 @@ class Form
* @param int $iSecond Default preselected duration (number of seconds or '')
* @param int $disabled Disable the combo box
* @param string $typehour If 'select' then input hour and input min is a combo, if 'text' input hour is in text and input min is a combo
- * @param string $minunderhours If 1, show minutes selection under the hours
+ * @param integer $minunderhours If 1, show minutes selection under the hours
* @param int $nooutput Do not output html string but return it
- * @return void
+ * @return string|null
*/
function select_duration($prefix, $iSecond='', $disabled=0, $typehour='select', $minunderhours=0, $nooutput=0)
{
@@ -4741,7 +4769,7 @@ class Form
* @param string $morecss Add more class to css styles
* @param int $callurlonselect If set to 1, some code is added so an url return by the ajax is called when value is selected.
* @param string $placeholder String to use as placeholder
- * @param string $acceptdelayedhtml 1 if caller request to have html delayed content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect)
+ * @param integer $acceptdelayedhtml 1 if caller request to have html delayed content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect)
* @return string HTML select string
*/
static function selectArrayAjax($htmlname, $url, $id='', $moreparam='', $moreparamtourl='', $disabled=0, $minimumInputLength=1, $morecss='', $callurlonselect=0, $placeholder='', $acceptdelayedhtml=0)
@@ -4958,7 +4986,10 @@ class Form
foreach($array as $key => $val)
{
- if (isset($val['enabled']) && ! $val['enabled'])
+ /* var_dump($val);
+ var_dump(array_key_exists('enabled', $val));
+ var_dump(!$val['enabled']);*/
+ if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled'])
{
unset($array[$key]); // We don't want this field
continue;
@@ -5092,7 +5123,8 @@ class Form
if (empty($reshook))
{
$num = count($object->linkedObjects);
-
+ $numoutput=0;
+
foreach($object->linkedObjects as $objecttype => $objects)
{
$tplpath = $element = $subelement = $objecttype;
@@ -5143,6 +5175,26 @@ class Form
global $linkedObjectBlock;
$linkedObjectBlock = $objects;
+ if (empty($numoutput))
+ {
+ $numoutput++;
+
+ echo ' ';
+ print load_fiche_titre($langs->trans('RelatedObjects'), '', '');
+
+ print '
';
+
+ print '
';
+ print '
'.$langs->trans("Type").'
';
+ print '
'.$langs->trans("Ref").'
';
+ print '
';
+ print '
'.$langs->trans("Date").'
';
+ print '
'.$langs->trans("AmountHTShort").'
';
+ print '
'.$langs->trans("Status").'
';
+ print '
';
+ print '
';
+ }
+
// Output template part (modules that overwrite templates must declare this into descriptor)
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/'.$tplpath.'/tpl'));
foreach($dirtpls as $reldir)
@@ -5152,6 +5204,11 @@ class Form
}
}
+ if ($numoutput)
+ {
+ print '
';
diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php
new file mode 100644
index 00000000000..4a76cca81d6
--- /dev/null
+++ b/htdocs/core/class/html.formaccounting.class.php
@@ -0,0 +1,116 @@
+
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/core/class/html.formaccounting.class.php
+ * \ingroup Advanced accountancy
+ * \brief File of class with all html predefined components
+ */
+
+
+/**
+ * Class to manage generation of HTML components for accounting management
+ */
+class FormAccounting
+{
+ var $db;
+ var $error;
+
+
+ /**
+ * Constructor
+ *
+ * @param DoliDB $db Database handler
+ */
+ public function __construct($db)
+ {
+ $this->db = $db;
+ }
+
+ /**
+ * Return list of accounting category.
+ * Use mysoc->country_id or mysoc->country_code so they must be defined.
+ *
+ * @param string $selected Preselected type
+ * @param string $htmlname Name of field in form
+ * @param int $useempty Set to 1 if we want an empty value
+ * @param int $maxlen Max length of text in combo box
+ * @param int $help Add or not the admin help picto
+ * @return void
+ */
+ function select_accounting_category($selected='',$htmlname='account_category', $useempty=0, $maxlen=64, $help=1)
+ {
+ global $db,$langs,$user,$mysoc;
+
+ if (empty($mysoc->country_id) && empty($mysoc->country_code))
+ {
+ dol_print_error('','Call to select_accounting_account with mysoc country not yet defined');
+ exit;
+ }
+
+ if (! empty($mysoc->country_id))
+ {
+ $sql = "SELECT c.rowid, c.label as type, c.range_account";
+ $sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c";
+ $sql.= " WHERE c.active = 1";
+ $sql.= " AND c.fk_country = ".$mysoc->country_id;
+ $sql.= " ORDER BY c.label ASC";
+ }
+ else
+ {
+ $sql = "SELECT c.rowid, c.label as type, c.range_account";
+ $sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c, ".MAIN_DB_PREFIX."c_country as co";
+ $sql.= " WHERE c.active = 1 AND c.fk_country = co.rowid";
+ $sql.= " AND co.code = '".$mysoc->country_code."'";
+ $sql.= " ORDER BY c.label ASC";
+ }
+
+ dol_syslog("Form::select_accounting_category", LOG_DEBUG);
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ if ($num)
+ {
+ print '';
+ if ($user->admin && $help) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
+ }
+ else
+ {
+ print $langs->trans("ErrorNoAccountingCategoryForThisCountry",$mysoc->country_code);
+ }
+ }
+ else
+ {
+ dol_print_error($db,$db->lasterror());
+ }
+ }
+}
+
diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php
index 0316fb461cf..7194f1f5da6 100644
--- a/htdocs/core/class/html.formactions.class.php
+++ b/htdocs/core/class/html.formactions.class.php
@@ -52,8 +52,8 @@ class FormActions
* @param string $selected Preselected value (-1..100)
* @param int $canedit 1=can edit, 0=read only
* @param string $htmlname Name of html prefix for html fields (selectX and valX)
- * @param string $showempty Show an empty line if select is used
- * @param string $onlyselect 0=Standard, 1=Hide percent of completion and force usage of a select list, 2=Same than 1 and add "Incomplete (Todo+Running)
+ * @param integer $showempty Show an empty line if select is used
+ * @param integer $onlyselect 0=Standard, 1=Hide percent of completion and force usage of a select list, 2=Same than 1 and add "Incomplete (Todo+Running)
* @return void
*/
function form_select_status_action($formname,$selected,$canedit=1,$htmlname='complete',$showempty=0,$onlyselect=0)
@@ -136,7 +136,7 @@ class FormActions
if (empty($onlyselect))
{
print ' =0)?'':' disabled').'>';
- print '%';
+ print '%';
}
}
else
@@ -153,9 +153,10 @@ class FormActions
* @param string $typeelement 'invoice','propal','order','invoice_supplier','order_supplier','fichinter'
* @param int $socid socid of user
* @param int $forceshowtitle Show title even if there is no actions to show
+ * @param string $morecss More css on table
* @return int <0 if KO, >=0 if OK
*/
- function showactions($object,$typeelement,$socid=0,$forceshowtitle=0)
+ function showactions($object,$typeelement,$socid=0,$forceshowtitle=0,$morecss='listactions')
{
global $langs,$conf,$user;
global $bc;
@@ -182,7 +183,7 @@ class FormActions
print load_fiche_titre($title,'','');
$total = 0; $var=true;
- print '
';
- $genbutton = '';
@@ -579,8 +576,8 @@ class FormFile
{
$file_list=dol_dir_list($filedir,'files',0,'','(\.meta|_preview\.png)$','date',SORT_DESC);
- // Affiche en-tete tableau si non deja affiche
- if (! empty($file_list) && ! $headershown)
+ // Show title of array if not already shown
+ if ((! empty($file_list) || $modulepart == 'massfilesarea') && ! $headershown)
{
$headershown=1;
$out.= '