From 5223934ff03c05588f4a6832d110621221ddd346 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 14 Jul 2015 12:17:50 +0200 Subject: [PATCH 01/55] Fix #3188 SQL error if qty or discount is not a number on proposal add line --- htdocs/comm/propal/class/propal.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 507a9dce633..60cbaa6ae0d 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2910,14 +2910,14 @@ class PropaleLigne extends CommonObject $sql.= " ".($this->fk_product?"'".$this->fk_product."'":"null").","; $sql.= " '".$this->product_type."',"; $sql.= " ".($this->fk_remise_except?"'".$this->fk_remise_except."'":"null").","; - $sql.= " ".price2num($this->qty).","; + $sql.= " '".price2num($this->qty)."',"; $sql.= " ".price2num($this->tva_tx).","; $sql.= " ".price2num($this->localtax1_tx).","; $sql.= " ".price2num($this->localtax2_tx).","; $sql.= " '".$this->localtax1_type."',"; $sql.= " '".$this->localtax2_type."',"; $sql.= " ".($this->subprice?price2num($this->subprice):"null").","; - $sql.= " ".price2num($this->remise_percent).","; + $sql.= " '".price2num($this->remise_percent)."',"; $sql.= " ".(isset($this->info_bits)?"'".$this->info_bits."'":"null").","; $sql.= " ".price2num($this->total_ht).","; $sql.= " ".price2num($this->total_tva).","; From 8505e914695a0723da9fe719f1dfc3e1f4b4495b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 19 Jul 2015 13:46:25 +0200 Subject: [PATCH 02/55] Fix: [ bug 1791 ] Margin menu not available if any Finance module is not enabled --- ChangeLog | 1 + htdocs/core/menus/standard/eldy.lib.php | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 67920bbfee3..828ab2eb738 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,7 @@ Fix: [ bug #2837 ] Product list table column header does not match column body Fix: [ bug #2835 ] Customer prices of a product shows incorrect history order Fix: [ bug #2814 ] JPEG photos are not displayed in Product photos page Fix: [ bug #2715 ] Statistics page has broken layout with long thirdparty names +Fix: [ bug #1791 ] Margin menu not available if any Finance module is not enabled ***** ChangeLog for 3.5.6 compared to 3.5.5 ***** Fix: Avoid missing class error for fetch_thirdparty method #1973 diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 83fcfca04bc..860acd993a0 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -134,9 +134,11 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0) } // Financial - $tmpentry=array('enabled'=>(! empty($conf->comptabilite->enabled) || ! empty($conf->accounting->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->deplacement->enabled) || ! empty($conf->don->enabled) || ! empty($conf->tax->enabled)), - 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->plancompte->lire) || ! empty($user->rights->facture->lire) || ! empty($user->rights->deplacement->lire) || ! empty($user->rights->don->lire) || ! empty($user->rights->tax->charges->lire)), - 'module'=>'comptabilite|accounting|facture|deplacement|don|tax'); + $tmpentry = array( + 'enabled' => (!empty($conf->comptabilite->enabled) || !empty($conf->accounting->enabled) || !empty($conf->facture->enabled) || !empty($conf->deplacement->enabled) || !empty($conf->don->enabled) || !empty($conf->tax->enabled) || !empty($conf->margin->enabled)), + 'perms' => (!empty($user->rights->compta->resultat->lire) || !empty($user->rights->accounting->plancompte->lire) || !empty($user->rights->facture->lire) || !empty($user->rights->deplacement->lire) || !empty($user->rights->don->lire) || !empty($user->rights->tax->charges->lire) || !empty($user->rights->margins->liretous)), + 'module' => 'comptabilite|accounting|facture|deplacement|don|tax' + ); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) { From 038f171d6cb628ad9f1902f0f33232580c63d3a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Mon, 20 Jul 2015 12:18:30 +0200 Subject: [PATCH 03/55] Fix: [ bug #3074 ] Accruals accounting use payment date instead of commitment date in turnover reports for salaries Close #3074 --- ChangeLog | 1 + htdocs/compta/resultat/clientfourn.php | 12 +++++++++--- htdocs/compta/resultat/index.php | 9 ++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 198a194c35b..776a6b2b15c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -39,6 +39,7 @@ English Dolibarr ChangeLog - Fix: Bad permission assignments for stock movements actions - Fix: [ bug #2891 ] Category hooks do not work - Fix: [ bug #2696 ] Adding complementary attribute fails if code is numerics +- Fix: [ bug #3074 ] Accruals accounting use payment date instead of commitment date in turnover reports for salaries ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 1e09ea0a8fe..7089652d3d3 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -543,17 +543,23 @@ if ($mysoc->tva_assuj == 'franchise') // Non assujeti * Salaries */ +if ($modecompta == 'CREANCES-DETTES') { + $column = 'p.datev'; +} else { + $column = 'p.datep'; +} + print ''.$langs->trans("Salaries").''; -$sql = "SELECT p.label as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount, u.firstname, u.lastname, p.fk_user"; +$sql = "SELECT p.label as nom, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount, u.firstname, u.lastname, p.fk_user"; $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 = ".$conf->entity; if (! empty($date_start) && ! empty($date_end)) - $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + $sql.= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'"; $sql.= " GROUP BY u.rowid, p.label, p.datep, p.fk_user"; $sql.= " ORDER BY u.firstname"; - + dol_syslog("get payment salaries sql=".$sql); $result=$db->query($sql); $subtotal_ht = 0; diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index fdc9b0472f0..32294b61bea 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -473,9 +473,16 @@ $reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$acti /* * Salaries */ + +if ($modecompta == 'CREANCES-DETTES') { + $column = 'p.datev'; +} else { + $column = 'p.datep'; +} + $subtotal_ht = 0; $subtotal_ttc = 0; -$sql = "SELECT p.label as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount"; +$sql = "SELECT p.label as nom, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; $sql.= " WHERE p.entity = ".$conf->entity; $sql.= " GROUP BY p.label, dm"; From 0d897a1307273f3fa6937eda017513badbfa5f1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Mon, 20 Jul 2015 18:30:45 +0200 Subject: [PATCH 04/55] NEW: log hooks loading This will help debugging bad hooks behavior. --- htdocs/core/class/hookmanager.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index d1c5547cccc..a497b3cb7e2 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -95,6 +95,7 @@ class HookManager $pathroot = ''; // Include actions class overwriting hooks + dol_syslog('Loading hook:' . $actionfile, LOG_INFO); $resaction=dol_include_once($path.$actionfile); if ($resaction) { From 58acc315918f8709d01d459d382ad4249fb735c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Mon, 20 Jul 2015 19:54:13 +0200 Subject: [PATCH 05/55] Qual: & should not be used in attributes --- htdocs/main.inc.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 830a8b0eb11..80fdbef6610 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1060,14 +1060,14 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs } } } - $themeparam='?lang='.$langs->defaultlang.'&theme='.$conf->theme.(GETPOST('optioncss')?'&optioncss='.GETPOST('optioncss','alpha',1):'').'&userid='.$user->id.'&entity='.$conf->entity; - $themeparam.=($ext?'&'.$ext:''); - if (! empty($_SESSION['dol_resetcache'])) $themeparam.='&dol_resetcache='.$_SESSION['dol_resetcache']; - if (GETPOST('dol_hide_topmenu')) { $themeparam.='&dol_hide_topmenu='.GETPOST('dol_hide_topmenu','int'); } - if (GETPOST('dol_hide_leftmenu')) { $themeparam.='&dol_hide_leftmenu='.GETPOST('dol_hide_leftmenu','int'); } - if (GETPOST('dol_optimize_smallscreen')) { $themeparam.='&dol_optimize_smallscreen='.GETPOST('dol_optimize_smallscreen','int'); } - if (GETPOST('dol_no_mouse_hover')) { $themeparam.='&dol_no_mouse_hover='.GETPOST('dol_no_mouse_hover','int'); } - if (GETPOST('dol_use_jmobile')) { $themeparam.='&dol_use_jmobile='.GETPOST('dol_use_jmobile','int'); $conf->dol_use_jmobile=GETPOST('dol_use_jmobile','int'); } + $themeparam='?lang='.$langs->defaultlang.'&theme='.$conf->theme.(GETPOST('optioncss')?'&optioncss='.GETPOST('optioncss','alpha',1):'').'&userid='.$user->id.'&entity='.$conf->entity; + $themeparam.=($ext?'&'.$ext:''); + if (! empty($_SESSION['dol_resetcache'])) $themeparam.='&dol_resetcache='.$_SESSION['dol_resetcache']; + if (GETPOST('dol_hide_topmenu')) { $themeparam.='&dol_hide_topmenu='.GETPOST('dol_hide_topmenu','int'); } + if (GETPOST('dol_hide_leftmenu')) { $themeparam.='&dol_hide_leftmenu='.GETPOST('dol_hide_leftmenu','int'); } + if (GETPOST('dol_optimize_smallscreen')) { $themeparam.='&dol_optimize_smallscreen='.GETPOST('dol_optimize_smallscreen','int'); } + if (GETPOST('dol_no_mouse_hover')) { $themeparam.='&dol_no_mouse_hover='.GETPOST('dol_no_mouse_hover','int'); } + if (GETPOST('dol_use_jmobile')) { $themeparam.='&dol_use_jmobile='.GETPOST('dol_use_jmobile','int'); $conf->dol_use_jmobile=GETPOST('dol_use_jmobile','int'); } //print 'themepath='.$themepath.' themeparam='.$themeparam;exit; print ''."\n"; if (! empty($conf->global->MAIN_FIX_FLASH_ON_CHROME)) print ''."\n".''."\n"; From 428bd14b55153547aa44a1b8022d26f702eb6f00 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 21 Jul 2015 10:49:47 +0200 Subject: [PATCH 06/55] Merge branch '3.5' of github.com:Dolibarr/dolibarr into 3.5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Veuillez entrer un message de validation pour expliquer en quoi cette fusion est # nécessaire, surtout si cela fusionne une branche amont mise à jour dans une branche de sujet. # # Les lignes commençant par '#' seront ignorées, et un message vide # abandonne la validation. --- ChangeLog | 5 + htdocs/compta/facture/stats/index.php | 9 +- .../class/rejetprelevement.class.php | 31 +- htdocs/contact/exportimport.php | 123 ++++--- htdocs/contact/info.php | 23 +- htdocs/contact/ldap.php | 284 +++++++-------- htdocs/contact/perso.php | 340 +++++++++--------- htdocs/contact/vcard.php | 130 +++---- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/menus/standard/eldy.lib.php | 8 +- htdocs/societe/info.php | 31 +- htdocs/societe/soc.php | 2 + 12 files changed, 512 insertions(+), 476 deletions(-) diff --git a/ChangeLog b/ChangeLog index ab5fa93f635..6165077d1ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,11 @@ Fix: [ bug #2861 ] Undefined variable $res when migrating Fix: [ bug #2837 ] Product list table column header does not match column body Fix: [ bug #2835 ] Customer prices of a product shows incorrect history order Fix: [ bug #2814 ] JPEG photos are not displayed in Product photos page +Fix: [ bug #2715 ] Statistics page has broken layout with long thirdparty names +Fix: [ bug #2570 ] [Contacts] Page should not process if ID is invalid +Fix: [ bug #3268 ] SQL error when accessing thirdparty log page without a socid parameter +Fix: [ bug #3180 ] formObjectOptions hook when editing thirdparty card does not print result +Fix: [ bug #1791 ] Margin menu not available if any Finance module is not enabled ***** ChangeLog for 3.5.6 compared to 3.5.5 ***** Fix: Avoid missing class error for fetch_thirdparty method #1973 diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 51747fe04d2..08c3750d0e4 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -217,6 +217,13 @@ complete_head_from_modules($conf,$langs,null,$head,$h,$type); dol_fiche_head($head,'byyear',$langs->trans("Statistics")); +$tmp_companies = $form->select_thirdparty_list($socid,'socid',$filter,1, 0, 0, array(), '', 1); +//Array passed as an argument to Form::selectarray to build a proper select input +$companies = array(); + +foreach ($tmp_companies as $value) { + $companies[$value['value']] = $value['label']; +} print '
'; @@ -232,7 +239,7 @@ print '
'; print ''.$langs->trans("ThirdParty").''; if ($mode == 'customer') $filter='s.client in (1,2,3)'; if ($mode == 'supplier') $filter='s.fournisseur = 1'; - print $form->select_company($socid,'socid',$filter,1); + print $form->selectarray('socid', $companies, $socid, 1, 0, 0, 'style="width: 100%"'); print ''; // User print ''.$langs->trans("CreatedBy").''; diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php index 77bafae3603..aae942468dd 100644 --- a/htdocs/compta/prelevement/class/rejetprelevement.class.php +++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php @@ -87,7 +87,7 @@ class RejetPrelevement dol_syslog("RejetPrelevement::Create id $id"); $bankaccount = $conf->global->PRELEVEMENT_ID_BANKACCOUNT; - $facs = $this->getListInvoices(); + $facs = $this->getListInvoices(1); $this->db->begin(); @@ -132,7 +132,7 @@ class RejetPrelevement for ($i = 0; $i < $num; $i++) { $fac = new Facture($this->db); - $fac->fetch($facs[$i]); + $fac->fetch($facs[$i][0]); // Make a negative payment $pai = new Paiement($this->db); @@ -144,7 +144,7 @@ class RejetPrelevement * PHP installs sends only the part integer negative */ - $pai->amounts[$facs[$i]] = price2num($fac->total_ttc * -1); + $pai->amounts[$facs[$i][0]] = price2num($facs[$i][1] * -1); $pai->datepaye = $date_rejet; $pai->paiementid = 3; // type of payment: withdrawal $pai->num_paiement = $fac->ref; @@ -152,7 +152,7 @@ class RejetPrelevement if ($pai->create($this->user) < 0) // we call with no_commit { $error++; - dol_syslog("RejetPrelevement::Create Error creation payment invoice ".$facs[$i]); + dol_syslog("RejetPrelevement::Create Error creation payment invoice ".$facs[$i][0]); } else { @@ -269,22 +269,24 @@ class RejetPrelevement } /** - * Retrieve the list of invoices + * Retrieve the list of invoices + * @param int $amounts If you want to get the amount of the order for each invoice * - * @return void + * @return Array List of invoices related to the withdrawal line + * @TODO A withdrawal line is today linked to one and only one invoice. So the function should return only one object ? */ - private function getListInvoices() + private function getListInvoices($amounts=0) { global $conf; $arr = array(); //Returns all invoices of a withdrawal - $sql = "SELECT f.rowid as facid"; + $sql = "SELECT f.rowid as facid, pl.amount"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_facture as pf"; - $sql.= ", ".MAIN_DB_PREFIX."facture as f"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON (pf.fk_facture = f.rowid)"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_lignes as pl ON (pf.fk_prelevement_lignes = pl.rowid)"; $sql.= " WHERE pf.fk_prelevement_lignes = ".$this->id; - $sql.= " AND pf.fk_facture = f.rowid"; $sql.= " AND f.entity = ".$conf->entity; $resql=$this->db->query($sql); @@ -298,7 +300,14 @@ class RejetPrelevement while ($i < $num) { $row = $this->db->fetch_row($resql); - $arr[$i] = $row[0]; + if (!$amounts) $arr[$i] = $row[0]; + else + { + $arr[$i] = array( + $row[0], + $row[1] + ); + } $i++; } } diff --git a/htdocs/contact/exportimport.php b/htdocs/contact/exportimport.php index 5149eed9efb..c76655f5099 100644 --- a/htdocs/contact/exportimport.php +++ b/htdocs/contact/exportimport.php @@ -33,81 +33,80 @@ $id = GETPOST('id', 'int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); +$contact = new Contact($db); + /* * View */ +$form = new Form($db); + $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); llxHeader('',$title,'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'); -$form = new Form($db); - -$contact = new Contact($db); -$contact->fetch($id, $user); - - -$head = contact_prepare_head($contact); - -dol_fiche_head($head, 'exportimport', $title, 0, 'contact'); - - -/* - * Fiche en mode visu - */ -print ''; - -$linkback = ''.$langs->trans("BackToList").''; - -// Ref -print ''; - -// Name -print ''; -print ''; - -// Company -if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) +if ($id > 0) { - if ($contact->socid > 0) - { - $objsoc = new Societe($db); - $objsoc->fetch($contact->socid); + $contact->fetch($id, $user); - print ''; - } - else - { - print ''; - } + $head = contact_prepare_head($contact); + + dol_fiche_head($head, 'exportimport', $title, 0, 'contact'); + + + /* + * Fiche en mode visu + */ + print '
'.$langs->trans("Ref").''; -print $form->showrefnav($contact, 'id', $linkback); -print '
'.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$contact->lastname.''.$langs->trans("Firstname").''.$contact->firstname.'
'.$langs->trans("Company").''.$objsoc->getNomUrl(1).'
'.$langs->trans("Company").''; - print $langs->trans("ContactNotLinkedToCompany"); - print '
'; + + $linkback = ''.$langs->trans("BackToList").''; + + // Ref + print ''; + + // Name + print ''; + print ''; + + // Company + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + if ($contact->socid > 0) + { + $objsoc = new Societe($db); + $objsoc->fetch($contact->socid); + + print ''; + } + else + { + print ''; + } + } + + // Civility + print ''; + + print '
'.$langs->trans("Ref").''; + print $form->showrefnav($contact, 'id', $linkback); + print '
'.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$contact->lastname.''.$langs->trans("Firstname").''.$contact->firstname.'
'.$langs->trans("Company").''.$objsoc->getNomUrl(1).'
'.$langs->trans("Company").''; + print $langs->trans("ContactNotLinkedToCompany"); + print '
'.$langs->trans("UserTitle").''; + print $contact->getCivilityLabel(); + print '
'; + + print '
'; + + print '
'; + + print $langs->trans("ExportCardToFormat").': '; + print ''; + print img_picto($langs->trans("VCard"),'vcard.png').' '; + print $langs->trans("VCard"); + print ''; } -// Civility -print ''.$langs->trans("UserTitle").''; -print $contact->getCivilityLabel(); -print ''; - -print ''; - -print '
'; - -print '
'; - -print $langs->trans("ExportCardToFormat").': '; -print ''; -print img_picto($langs->trans("VCard"),'vcard.png').' '; -print $langs->trans("VCard"); -print ''; - - - - $db->close(); llxFooter(); -?> diff --git a/htdocs/contact/info.php b/htdocs/contact/info.php index 3ac6747bb6b..5d4904faa87 100644 --- a/htdocs/contact/info.php +++ b/htdocs/contact/info.php @@ -35,6 +35,8 @@ $contactid = GETPOST("id",'int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'contact', $contactid, 'socpeople&societe'); +$contact = new Contact($db); + /* @@ -43,25 +45,26 @@ $result = restrictedArea($user, 'contact', $contactid, 'socpeople&societe'); llxHeader('',$langs->trans("ContactsAddresses"),'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'); +if ($contactid > 0) +{ + $result = $contact->fetch($contactid, $user); -$contact = new Contact($db); -$contact->fetch($contactid, $user); -$contact->info($contactid); + $contact->info($contactid); -$head = contact_prepare_head($contact); + $head = contact_prepare_head($contact); -dol_fiche_head($head, 'info', $langs->trans("ContactsAddresses"), 0, 'contact'); + dol_fiche_head($head, 'info', $langs->trans("ContactsAddresses"), 0, 'contact'); -print '
'; -print '
'; + print '
'; + print '
'; -dol_print_object_info($contact); + dol_print_object_info($contact); -print "
"; + print "
"; +} llxFooter(); $db->close(); -?> diff --git a/htdocs/contact/ldap.php b/htdocs/contact/ldap.php index f284ee1834d..79e6246fc60 100644 --- a/htdocs/contact/ldap.php +++ b/htdocs/contact/ldap.php @@ -40,37 +40,40 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); $contact = new Contact($db); -$contact->fetch($id, $user); - -/* - * Actions - */ - -if ($action == 'dolibarr2ldap') +if ($id > 0) { - $message=""; + $contact->fetch($id, $user); - $db->begin(); + /* + * Actions + */ - $ldap=new Ldap(); - $result=$ldap->connect_bind(); - - $info=$contact->_load_ldap_info(); - $dn=$contact->_load_ldap_dn($info); - $olddn=$dn; // We can say that old dn = dn as we force synchro - - $result=$ldap->update($dn,$info,$user,$olddn); - - if ($result >= 0) + if ($action == 'dolibarr2ldap') { - $message.='
'.$langs->trans("ContactSynchronized").'
'; - $db->commit(); - } - else - { - $message.='
'.$ldap->error.'
'; - $db->rollback(); + $message=""; + + $db->begin(); + + $ldap=new Ldap(); + $result=$ldap->connect_bind(); + + $info=$contact->_load_ldap_info(); + $dn=$contact->_load_ldap_dn($info); + $olddn=$dn; // We can say that old dn = dn as we force synchro + + $result=$ldap->update($dn,$info,$user,$olddn); + + if ($result >= 0) + { + $message.='
'.$langs->trans("ContactSynchronized").'
'; + $db->commit(); + } + else + { + $message.='
'.$ldap->error.'
'; + $db->rollback(); + } } } @@ -79,138 +82,139 @@ if ($action == 'dolibarr2ldap') * View */ +$form = new Form($db); + $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); llxHeader('',$title,'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'); -$form = new Form($db); - -$head = contact_prepare_head($contact); - -dol_fiche_head($head, 'ldap', $title, 0, 'contact'); - - -print ''; - -// Ref -print ''; - -// Name -print ''; -print ''; - -// Company -if ($contact->socid > 0) +if ($id > 0) { - $objsoc = new Societe($db); - $objsoc->fetch($contact->socid); + $head = contact_prepare_head($contact); - print ''; -} -else -{ - print '
'.$langs->trans("Ref").''; -print $form->showrefnav($contact,'id'); -print '
'.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$contact->lastname.''.$langs->trans("Firstname").''.$contact->firstname.'
'.$langs->trans("Company").''.$objsoc->getNomUrl(1).'
'.$langs->trans("Company").''; - print $langs->trans("ContactNotLinkedToCompany"); + dol_fiche_head($head, 'ldap', $title, 0, 'contact'); + + + print ''; + + // Ref + print ''; -} -// Civility -print ''; + // Name + print ''; + print ''; -// LDAP DN -print '\n"; - -// LDAP Cle -print '\n"; - -// LDAP Server -print '\n"; -print '\n"; -print '\n"; - -print '
'.$langs->trans("Ref").''; + print $form->showrefnav($contact,'id'); print '
'.$langs->trans("UserTitle").''; -print $contact->getCivilityLabel(); -print '
'.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$contact->lastname.''.$langs->trans("Firstname").''.$contact->firstname.'
LDAP '.$langs->trans("LDAPContactDn").''.$conf->global->LDAP_CONTACT_DN."
LDAP '.$langs->trans("LDAPNamingAttribute").''.$conf->global->LDAP_KEY_CONTACTS."
LDAP '.$langs->trans("LDAPPrimaryServer").''.$conf->global->LDAP_SERVER_HOST."
LDAP '.$langs->trans("LDAPSecondaryServer").''.$conf->global->LDAP_SERVER_HOST_SLAVE."
LDAP '.$langs->trans("LDAPServerPort").''.$conf->global->LDAP_SERVER_PORT."
'; - -print ''; - - -dol_htmloutput_mesg($message); - - -/* - * Barre d'actions - */ - -print '
'; - -if (! empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') -{ - print ''.$langs->trans("ForceSynchronize").''; -} - -print "
\n"; - -if (! empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') print "
\n"; - - - -// Affichage attributs LDAP -print_titre($langs->trans("LDAPInformationsForThisContact")); - -print ''; - -print ''; -print ''; -print ''; -print ''; - -// Lecture LDAP -$ldap=new Ldap(); -$result=$ldap->connect_bind(); -if ($result > 0) -{ - $info=$contact->_load_ldap_info(); - $dn=$contact->_load_ldap_dn($info,1); - $search = "(".$contact->_load_ldap_dn($info,2).")"; - $records=$ldap->getAttribute($dn,$search); - - //var_dump($records); - - // Affichage arbre - if (count($records) && $records != false && (! isset($records['count']) || $records['count'] > 0)) + // Company + if ($contact->socid > 0) { - if (! is_array($records)) - { - print ''; - } - else - { - $result=show_ldap_content($records,0,$records['count'],true); - } + $objsoc = new Societe($db); + $objsoc->fetch($contact->socid); + + print ''; } else { - print ''; + print ''; } - $ldap->unbind(); - $ldap->close(); + // Civility + print ''; + + // LDAP DN + print '\n"; + + // LDAP Cle + print '\n"; + + // LDAP Server + print '\n"; + print '\n"; + print '\n"; + + print '
'.$langs->trans("LDAPAttributes").''.$langs->trans("Value").'
'.$langs->trans("ErrorFailedToReadLDAP").'
'.$langs->trans("Company").''.$objsoc->getNomUrl(1).'
'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')
'.$langs->trans("Company").''; + print $langs->trans("ContactNotLinkedToCompany"); + print '
'.$langs->trans("UserTitle").''; + print $contact->getCivilityLabel(); + print '
LDAP '.$langs->trans("LDAPContactDn").''.$conf->global->LDAP_CONTACT_DN."
LDAP '.$langs->trans("LDAPNamingAttribute").''.$conf->global->LDAP_KEY_CONTACTS."
LDAP '.$langs->trans("LDAPPrimaryServer").''.$conf->global->LDAP_SERVER_HOST."
LDAP '.$langs->trans("LDAPSecondaryServer").''.$conf->global->LDAP_SERVER_HOST_SLAVE."
LDAP '.$langs->trans("LDAPServerPort").''.$conf->global->LDAP_SERVER_PORT."
'; + + print ''; + + + dol_htmloutput_mesg($message); + + + /* + * Barre d'actions + */ + + print '
'; + + if (! empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') + { + print ''.$langs->trans("ForceSynchronize").''; + } + + print "
\n"; + + if (! empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') print "
\n"; + + + + // Affichage attributs LDAP + print_titre($langs->trans("LDAPInformationsForThisContact")); + + print ''; + + print ''; + print ''; + print ''; + print ''; + + // Lecture LDAP + $ldap=new Ldap(); + $result=$ldap->connect_bind(); + if ($result > 0) + { + $info=$contact->_load_ldap_info(); + $dn=$contact->_load_ldap_dn($info,1); + $search = "(".$contact->_load_ldap_dn($info,2).")"; + $records=$ldap->getAttribute($dn,$search); + + //var_dump($records); + + // Affichage arbre + if (count($records) && $records != false && (! isset($records['count']) || $records['count'] > 0)) + { + if (! is_array($records)) + { + print ''; + } + else + { + $result=show_ldap_content($records,0,$records['count'],true); + } + } + else + { + print ''; + } + + $ldap->unbind(); + $ldap->close(); + } + else + { + dol_print_error('',$ldap->error); + } + + + print '
'.$langs->trans("LDAPAttributes").''.$langs->trans("Value").'
'.$langs->trans("ErrorFailedToReadLDAP").'
'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')
'; + } -else -{ - dol_print_error('',$ldap->error); -} - - -print '
'; - - $db->close(); llxFooter(); -?> diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index 86462d05fae..bd74fc75ef8 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -38,210 +38,213 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); $object = new Contact($db); -/* - * Action - */ +$result = $object->fetch($id, $user); -if ($action == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer) +if ($id > 0) { - $ret = $object->fetch($id); + /* + * Action + */ - // Note: Correct date should be completed with location to have exact GM time of birth. - $object->birthday = dol_mktime(0,0,0,$_POST["birthdaymonth"],$_POST["birthdayday"],$_POST["birthdayyear"]); - $object->birthday_alert = $_POST["birthday_alert"]; + if ($action == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer) + { + // Note: Correct date should be completed with location to have exact GM time of birth. + $object->birthday = dol_mktime(0,0,0,$_POST["birthdaymonth"],$_POST["birthdayday"],$_POST["birthdayyear"]); + $object->birthday_alert = $_POST["birthday_alert"]; - $result = $object->update_perso($id, $user); - if ($result > 0) - { - $object->old_name=''; - $object->old_firstname=''; - } - else - { - $error = $object->error; - } + $result = $object->update_perso($id, $user); + if ($result > 0) + { + $object->old_name=''; + $object->old_firstname=''; + } + else + { + $error = $object->error; + } + } } - /* * View */ +$form = new Form($db); + $now=dol_now(); $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); llxHeader('',$title,'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'); -$form = new Form($db); - -$object->fetch($id, $user); - -$head = contact_prepare_head($object); - -dol_fiche_head($head, 'perso', $title, 0, 'contact'); - -if ($action == 'edit') +if ($id > 0) { - /* - * Fiche en mode edition - */ + $head = contact_prepare_head($object); - print '
'; - print ''; - print ''; - print ''; + dol_fiche_head($head, 'perso', $title, 0, 'contact'); - print ''; - - // Ref - print ''; - - // Name - print ''; - print ''; - - // Company - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + if ($action == 'edit') { - if ($object->socid > 0) + /* + * Fiche en mode edition + */ + + print ''; + print ''; + print ''; + print ''; + + print '
'.$langs->trans("Ref").''; - print $object->id; - print '
'.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$object->lastname.''.$langs->trans("Firstname").''.$object->firstname.'
'; + + // Ref + print ''; + + // Name + print ''; + print ''; + + // Company + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { - $objsoc = new Societe($db); - $objsoc->fetch($object->socid); + if ($object->socid > 0) + { + $objsoc = new Societe($db); + $objsoc->fetch($object->socid); - print ''; - } - else - { - print ''; - } - } - - // Civility - print ''; - - // Date To Birth - print ''; - - print ''; - } - else - { - print ''; - } - print ''; - - print "
'.$langs->trans("Ref").''; + print $object->id; + print '
'.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$object->lastname.''.$langs->trans("Firstname").''.$object->firstname.'
'.$langs->trans("Company").''.$objsoc->getNomUrl(1).'
'.$langs->trans("Company").''; - print $langs->trans("ContactNotLinkedToCompany"); - print '
'.$langs->trans("UserTitle").''; - print $object->getCivilityLabel(); - print '
'.$langs->trans("DateToBirth").''; - $form=new Form($db); - print $form->select_date($object->birthday,'birthday',0,0,1,"perso"); - print ''.$langs->trans("Alert").': '; - if (! empty($object->birthday_alert)) - { - print '

"; - - print '
'; - print ''; - print '   '; - print ''; - print '
'; - - print "
"; -} -else -{ - /* - * Fiche en mode visu - */ - print ''; - - $linkback = ''.$langs->trans("BackToList").''; - - // Ref - print ''; - - // Name - print ''; - print ''; - - // Company - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - if ($object->socid > 0) - { - $objsoc = new Societe($db); - $objsoc->fetch($object->socid); - - print ''; + print ''; + } + else + { + print ''; + } } - else - { - print ''; - } - } + // Civility + print ''; - // Civility - print ''; - - // Date To Birth - print ''; - if (! empty($object->birthday)) - { - include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - - print ''; + + print ''; + } + else + { + print ''; + } + print ''; + + print "
'.$langs->trans("Ref").''; - print $form->showrefnav($object, 'id', $linkback); - print '
'.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$object->lastname.''.$langs->trans("Firstname").''.$object->firstname.'
'.$langs->trans("Company").''.$objsoc->getNomUrl(1).'
'.$langs->trans("Company").''.$objsoc->getNomUrl(1).'
'.$langs->trans("Company").''; + print $langs->trans("ContactNotLinkedToCompany"); + print '
'.$langs->trans("Company").''; - print $langs->trans("ContactNotLinkedToCompany"); - print '
'.$langs->trans("UserTitle").''; + print $object->getCivilityLabel(); + print '
'.$langs->trans("UserTitle").''; - print $object->getCivilityLabel(); - print '
'.$langs->trans("DateToBirth").''.dol_print_date($object->birthday,"day"); - - print '   '; - //var_dump($birthdatearray); - $ageyear=convertSecondToTime($now-$object->birthday,'year')-1970; - $agemonth=convertSecondToTime($now-$object->birthday,'month')-1; - if ($ageyear >= 2) print '('.$ageyear.' '.$langs->trans("DurationYears").')'; - else if ($agemonth >= 2) print '('.$agemonth.' '.$langs->trans("DurationMonths").')'; - else print '('.$agemonth.' '.$langs->trans("DurationMonth").')'; - - - print '   -   '; - if ($object->birthday_alert) print $langs->trans("BirthdayAlertOn"); - else print $langs->trans("BirthdayAlertOff"); + // Date To Birth + print '
'.$langs->trans("DateToBirth").''; + $form=new Form($db); + print $form->select_date($object->birthday,'birthday',0,0,1,"perso"); print ''.$langs->trans("Alert").': '; + if (! empty($object->birthday_alert)) + { + print '

"; + + print '
'; + print ''; + print '   '; + print ''; + print '
'; + + print ""; } else { - print ''.$langs->trans("DateToBirth").''.$langs->trans("Unknown").""; - } - print ""; + /* + * Fiche en mode visu + */ + print ''; - print "
"; + $linkback = ''.$langs->trans("BackToList").''; -} + // Ref + print ''.$langs->trans("Ref").''; + print $form->showrefnav($object, 'id', $linkback); + print ''; -dol_fiche_end(); + // Name + print ''.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$object->lastname.''; + print ''.$langs->trans("Firstname").''.$object->firstname.''; -if ($action != 'edit') -{ - // Barre d'actions - if ($user->societe_id == 0) - { - print '
'; - - if ($user->rights->societe->contact->creer) + // Company + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { - print ''.$langs->trans('Modify').''; + if ($object->socid > 0) + { + $objsoc = new Societe($db); + $objsoc->fetch($object->socid); + + print ''.$langs->trans("Company").''.$objsoc->getNomUrl(1).''; + } + + else + { + print ''.$langs->trans("Company").''; + print $langs->trans("ContactNotLinkedToCompany"); + print ''; + } } - print "
"; + // Civility + print ''.$langs->trans("UserTitle").''; + print $object->getCivilityLabel(); + print ''; + + // Date To Birth + print ''; + if (! empty($object->birthday)) + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + + print ''.$langs->trans("DateToBirth").''.dol_print_date($object->birthday,"day"); + + print '   '; + //var_dump($birthdatearray); + $ageyear=convertSecondToTime($now-$object->birthday,'year')-1970; + $agemonth=convertSecondToTime($now-$object->birthday,'month')-1; + if ($ageyear >= 2) print '('.$ageyear.' '.$langs->trans("DurationYears").')'; + else if ($agemonth >= 2) print '('.$agemonth.' '.$langs->trans("DurationMonths").')'; + else print '('.$agemonth.' '.$langs->trans("DurationMonth").')'; + + + print '   -   '; + if ($object->birthday_alert) print $langs->trans("BirthdayAlertOn"); + else print $langs->trans("BirthdayAlertOff"); + print ''; + } + else + { + print ''.$langs->trans("DateToBirth").''.$langs->trans("Unknown").""; + } + print ""; + + print ""; + + } + + dol_fiche_end(); + + if ($action != 'edit') + { + // Barre d'actions + if ($user->societe_id == 0) + { + print '
'; + + if ($user->rights->societe->contact->creer) + { + print ''.$langs->trans('Modify').''; + } + + print "
"; + } } } @@ -249,4 +252,3 @@ if ($action != 'edit') llxFooter(); $db->close(); -?> diff --git a/htdocs/contact/vcard.php b/htdocs/contact/vcard.php index 76d73133e0f..6e439b7a575 100644 --- a/htdocs/contact/vcard.php +++ b/htdocs/contact/vcard.php @@ -35,70 +35,72 @@ $id = GETPOST('id', 'int'); $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); $contact = new Contact($db); -$result=$contact->fetch($id); -$physicalperson=1; - -$company = new Societe($db); -if ($contact->socid) +if ($id > 0) { - $result=$company->fetch($contact->socid); - //print "ee"; + $result=$contact->fetch($id); + + $physicalperson=1; + + $company = new Societe($db); + if ($contact->socid) + { + $result=$company->fetch($contact->socid); + //print "ee"; + } + + // We create VCard + $v = new vCard(); + $v->setProdId('Dolibarr '.DOL_VERSION); + + $v->setUid('DOLIBARR-CONTACTID-'.$contact->id); + $v->setName($contact->lastname, $contact->firstname, "", "", ""); + $v->setFormattedName($contact->getFullName($langs)); + + // By default, all informations are for work (except phone_perso and phone_mobile) + $v->setPhoneNumber($contact->phone_pro, "PREF;WORK;VOICE"); + $v->setPhoneNumber($contact->phone_mobile, "CELL;VOICE"); + $v->setPhoneNumber($contact->fax, "WORK;FAX"); + + $v->setAddress("", "", $contact->address, $contact->town, "", $contact->zip, ($contact->country_code?$contact->country_id:''), "WORK;POSTAL"); + $v->setLabel("", "", $contact->address, $contact->town, "", $contact->zip, ($contact->country_code?$contact->country_id:''), "WORK"); + $v->setEmail($contact->email,'internet,pref'); + $v->setNote($contact->note); + + $v->setTitle($contact->poste); + + // Data from linked company + if ($company->id) + { + $v->setURL($company->url, "WORK"); + if (! $contact->phone_pro) $v->setPhoneNumber($company->phone, "WORK;VOICE"); + if (! $contact->fax) $v->setPhoneNumber($company->fax, "WORK;FAX"); + if (! $contact->zip) $v->setAddress("", "", $company->address, $company->town, "", $company->zip, $company->country_code, "WORK;POSTAL"); + if ($company->email != $contact->email) $v->setEmail($company->email,'internet'); + // Si contact lie a un tiers non de type "particulier" + if ($contact->typent_code != 'TE_PRIVATE') $v->setOrg($company->nom); + } + + // Personal informations + $v->setPhoneNumber($contact->phone_perso, "HOME;VOICE"); + if ($contact->birthday) $v->setBirthday($contact->birthday); + + $db->close(); + + + // Renvoi la VCard au navigateur + + $output = $v->getVCard(); + + $filename =trim(urldecode($v->getFileName())); // "Nom prenom.vcf" + $filenameurlencoded = dol_sanitizeFileName(urlencode($filename)); + //$filename = dol_sanitizeFileName($filename); + + + header("Content-Disposition: attachment; filename=\"".$filename."\""); + header("Content-Length: ".dol_strlen($output)); + header("Connection: close"); + header("Content-Type: text/x-vcard; name=\"".$filename."\""); + + print $output; } - -// We create VCard -$v = new vCard(); -$v->setProdId('Dolibarr '.DOL_VERSION); - -$v->setUid('DOLIBARR-CONTACTID-'.$contact->id); -$v->setName($contact->lastname, $contact->firstname, "", "", ""); -$v->setFormattedName($contact->getFullName($langs)); - -// By default, all informations are for work (except phone_perso and phone_mobile) -$v->setPhoneNumber($contact->phone_pro, "PREF;WORK;VOICE"); -$v->setPhoneNumber($contact->phone_mobile, "CELL;VOICE"); -$v->setPhoneNumber($contact->fax, "WORK;FAX"); - -$v->setAddress("", "", $contact->address, $contact->town, "", $contact->zip, ($contact->country_code?$contact->country_id:''), "WORK;POSTAL"); -$v->setLabel("", "", $contact->address, $contact->town, "", $contact->zip, ($contact->country_code?$contact->country_id:''), "WORK"); -$v->setEmail($contact->email,'internet,pref'); -$v->setNote($contact->note); - -$v->setTitle($contact->poste); - -// Data from linked company -if ($company->id) -{ - $v->setURL($company->url, "WORK"); - if (! $contact->phone_pro) $v->setPhoneNumber($company->phone, "WORK;VOICE"); - if (! $contact->fax) $v->setPhoneNumber($company->fax, "WORK;FAX"); - if (! $contact->zip) $v->setAddress("", "", $company->address, $company->town, "", $company->zip, $company->country_code, "WORK;POSTAL"); - if ($company->email != $contact->email) $v->setEmail($company->email,'internet'); - // Si contact lie a un tiers non de type "particulier" - if ($contact->typent_code != 'TE_PRIVATE') $v->setOrg($company->nom); -} - -// Personal informations -$v->setPhoneNumber($contact->phone_perso, "HOME;VOICE"); -if ($contact->birthday) $v->setBirthday($contact->birthday); - -$db->close(); - - -// Renvoi la VCard au navigateur - -$output = $v->getVCard(); - -$filename =trim(urldecode($v->getFileName())); // "Nom prenom.vcf" -$filenameurlencoded = dol_sanitizeFileName(urlencode($filename)); -//$filename = dol_sanitizeFileName($filename); - - -header("Content-Disposition: attachment; filename=\"".$filename."\""); -header("Content-Length: ".dol_strlen($output)); -header("Connection: close"); -header("Content-Type: text/x-vcard; name=\"".$filename."\""); - -print $output; - -?> diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ce0d8babbc6..289a2d607c3 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -836,7 +836,7 @@ class Form $out.= ''; } - array_push($outarray, array('key'=>$obj->rowid, 'value'=>$obj->name, 'label'=>$obj->name)); + array_push($outarray, array('key'=>$obj->rowid, 'value'=>$obj->rowid, 'label'=>$label)); $i++; if (($i % 10) == 0) $out.="\n"; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 83fcfca04bc..860acd993a0 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -134,9 +134,11 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0) } // Financial - $tmpentry=array('enabled'=>(! empty($conf->comptabilite->enabled) || ! empty($conf->accounting->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->deplacement->enabled) || ! empty($conf->don->enabled) || ! empty($conf->tax->enabled)), - 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->plancompte->lire) || ! empty($user->rights->facture->lire) || ! empty($user->rights->deplacement->lire) || ! empty($user->rights->don->lire) || ! empty($user->rights->tax->charges->lire)), - 'module'=>'comptabilite|accounting|facture|deplacement|don|tax'); + $tmpentry = array( + 'enabled' => (!empty($conf->comptabilite->enabled) || !empty($conf->accounting->enabled) || !empty($conf->facture->enabled) || !empty($conf->deplacement->enabled) || !empty($conf->don->enabled) || !empty($conf->tax->enabled) || !empty($conf->margin->enabled)), + 'perms' => (!empty($user->rights->compta->resultat->lire) || !empty($user->rights->accounting->plancompte->lire) || !empty($user->rights->facture->lire) || !empty($user->rights->deplacement->lire) || !empty($user->rights->don->lire) || !empty($user->rights->tax->charges->lire) || !empty($user->rights->margins->liretous)), + 'module' => 'comptabilite|accounting|facture|deplacement|don|tax' + ); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) { diff --git a/htdocs/societe/info.php b/htdocs/societe/info.php index 8f0d0836ed4..d4c030f7664 100644 --- a/htdocs/societe/info.php +++ b/htdocs/societe/info.php @@ -40,6 +40,7 @@ $result = restrictedArea($user, 'societe', $socid, '&societe'); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('infothirdparty')); +$soc = new Societe($db); /* @@ -59,27 +60,27 @@ $error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->e $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('',$langs->trans("ThirdParty"),$help_url); -$soc = new Societe($db); -$soc->fetch($socid); -$soc->info($socid); +if ($socid > 0) +{ + $result = $soc->fetch($socid); -/* - * Affichage onglets - */ -$head = societe_prepare_head($soc); + $soc->info($socid); -dol_fiche_head($head, 'info', $langs->trans("ThirdParty"),0,'company'); + /* + * Affichage onglets + */ + $head = societe_prepare_head($soc); + + dol_fiche_head($head, 'info', $langs->trans("ThirdParty"), 0, 'company'); + print '
'; + dol_print_object_info($soc); + print '
'; -print '
'; -dol_print_object_info($soc); -print '
'; - -print ''; - + dol_fiche_end(); +} llxFooter(); $db->close(); -?> diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index b24179328fc..99e5da3beb8 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -999,6 +999,7 @@ else // Other attributes $parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit'); @@ -1407,6 +1408,7 @@ else // Other attributes $parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit'); From 646ad48bd068d7070b809ac84729ce0d9ed579f6 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 21 Jul 2015 10:50:07 +0200 Subject: [PATCH 07/55] Better fix for not numeric qty or discount --- htdocs/comm/propal/class/propal.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 60cbaa6ae0d..1a800dbf944 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2876,11 +2876,12 @@ class PropaleLigne extends CommonObject if (empty($this->total_localtax2)) $this->total_localtax2=0; if (empty($this->rang)) $this->rang=0; if (empty($this->remise)) $this->remise=0; - if (empty($this->remise_percent)) $this->remise_percent=0; + if (empty($this->remise_percent) || ! is_numeric($this->remise_percent)) $this->remise_percent=0; if (empty($this->info_bits)) $this->info_bits=0; if (empty($this->special_code)) $this->special_code=0; if (empty($this->fk_parent_line)) $this->fk_parent_line=0; if (empty($this->fk_fournprice)) $this->fk_fournprice=0; + if (! is_numeric($this->qty)) $this->qty = 0; if (empty($this->pa_ht)) $this->pa_ht=0; @@ -2910,14 +2911,14 @@ class PropaleLigne extends CommonObject $sql.= " ".($this->fk_product?"'".$this->fk_product."'":"null").","; $sql.= " '".$this->product_type."',"; $sql.= " ".($this->fk_remise_except?"'".$this->fk_remise_except."'":"null").","; - $sql.= " '".price2num($this->qty)."',"; + $sql.= " ".price2num($this->qty).","; $sql.= " ".price2num($this->tva_tx).","; $sql.= " ".price2num($this->localtax1_tx).","; $sql.= " ".price2num($this->localtax2_tx).","; $sql.= " '".$this->localtax1_type."',"; $sql.= " '".$this->localtax2_type."',"; $sql.= " ".($this->subprice?price2num($this->subprice):"null").","; - $sql.= " '".price2num($this->remise_percent)."',"; + $sql.= " ".price2num($this->remise_percent).","; $sql.= " ".(isset($this->info_bits)?"'".$this->info_bits."'":"null").","; $sql.= " ".price2num($this->total_ht).","; $sql.= " ".price2num($this->total_tva).","; From f18c983ba5ed89f91e0e7c3ece3ac197f7890954 Mon Sep 17 00:00:00 2001 From: Gauthier Date: Tue, 21 Jul 2015 10:24:54 +0200 Subject: [PATCH 08/55] NEW : print event type on third party card tab agenda list (only if AGENDA_USE_EVENT_TYPE = 1) Conflicts: htdocs/core/lib/company.lib.php --- htdocs/core/lib/company.lib.php | 52 ++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 92b5676746c..c979f734b5e 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -897,7 +897,7 @@ function show_addresses($conf,$langs,$db,$object,$backtopage='') */ function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0) { - global $bc,$user; + global $bc,$user,$conf; // Check parameters if (! is_object($object)) dol_print_error('','BadParameter'); @@ -915,12 +915,22 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0) $out.="\n"; $out.=''; $out.=''; - $out.=''; - $out.=''; + $out.=''; $out.=''; @@ -965,7 +975,7 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0) $var = !$var; $obj = $db->fetch_object($result); - + $actionstatic->fetch($obj->id); $datep=$db->jdate($obj->dp); $datep2=$db->jdate($obj->dp2); @@ -999,8 +1009,13 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0) // Title of event //$out.=''; - $out.=''; - + $out.=''; + + if($conf->global->AGENDA_USE_EVENT_TYPE) { + $out.= ''; + } // Contact pour cette action if (empty($objcon->id) && $obj->fk_contact > 0) { @@ -1063,7 +1078,7 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0) */ function show_actions_done($conf,$langs,$db,$object,$objcon='',$noprint=0) { - global $bc,$user; + global $bc,$user,$conf; // Check parameters if (! is_object($object)) dol_print_error('','BadParameter'); @@ -1202,12 +1217,22 @@ function show_actions_done($conf,$langs,$db,$object,$objcon='',$noprint=0) $out.="\n"; $out.='
'; + if($conf->global->AGENDA_USE_EVENT_TYPE) $out.=''; + else $out.=''; if (get_class($object) == 'Societe') $out.=''; $out.=$langs->trans("ActionsToDoShort"); if (get_class($object) == 'Societe') $out.=''; $out.=''; + + if($conf->global->AGENDA_USE_EVENT_TYPE) { + $out.=''; + $out.=$langs->trans("Type"); + $out.=''; + } else { + $out.=''; + } + $out.='
'.dol_trunc($obj->label,40).''.$actionstatic->getNomUrl(1,120).''.$actionstatic->getNomUrl(1,120).''; + $out.=$actionstatic->type; + $out.='
'; $out.=''; - $out.=''; - $out.=''; + $out.=''; $out.=''; @@ -1215,7 +1240,7 @@ function show_actions_done($conf,$langs,$db,$object,$objcon='',$noprint=0) { $var=!$var; $out.=""; - + $actionstatic->fetch($histo[$key]['id']); // Champ date $out.=''; - + + if($conf->global->AGENDA_USE_EVENT_TYPE) { + $out.=''; + } // Title of event //$out.=''; From 7398104f33fcf342231cf86312bc10dc3f5331b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Mon, 20 Jul 2015 19:58:37 +0200 Subject: [PATCH 09/55] Qual: Ignore logo by assistive technology. http://www.w3.org/TR/WCAG20-TECHS/H67.html --- htdocs/core/tpl/login.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index fc62c5b145f..aa5d2597059 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -81,7 +81,7 @@ $(document).ready(function () {
- +
From bd937070d2e42d0da4c50a5770b811d490f2b667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Mon, 20 Jul 2015 20:13:11 +0200 Subject: [PATCH 10/55] Accessibility: added login form hidden labels --- htdocs/core/tpl/login.tpl.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index aa5d2597059..128c4be5de0 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -93,6 +93,7 @@ $(document).ready(function () {
'; print ''; print ''; + print ''; print ''; print ''; - print '\n"; + print "\n"; $facturefournisseur_static = new FactureFournisseur($db); $product_static = new Product($db); @@ -234,6 +262,7 @@ if ($result) { print ''; print ''; print ''; + print ''; print ''; print ''; print ' '; - print_liste_field_titre($langs->trans("RowId"), $_SERVER["PHP_SELF"],"p.rowid","",$param,'',$sortfield,$sortorder); - print '  '; +print ''; +print ''; +print ''; + +print '
'; + if($conf->global->AGENDA_USE_EVENT_TYPE) $out.=''; + else $out.=''; if (get_class($object) == 'Societe') $out.=''; $out.=$langs->trans("ActionsDoneShort"); if (get_class($object) == 'Societe') $out.=''; $out.=''; + + if($conf->global->AGENDA_USE_EVENT_TYPE) { + $out.=''; + $out.=$langs->trans("Type"); + $out.=''; + } else { + $out.=''; + } + $out.='
'; $out.=dol_print_date($histo[$key]['datestart'],'dayhour'); @@ -1251,7 +1276,12 @@ function show_actions_done($conf,$langs,$db,$object,$objcon='',$noprint=0) $out.=dol_trunc($libelle,120); } $out.=''; + $out.=$actionstatic->type; + $out.=''.dol_trunc($histo[$key]['note'], 40).'
+ " name="username" class="flat input-icon-user" size="20" value="" tabindex="1" autofocus="autofocus" /> @@ -101,6 +102,7 @@ $(document).ready(function () {
+ " name="password" class="flat input-icon-password" type="password" size="20" value="" tabindex="2" autocomplete="off" /> From f63f66d6819f4b096748df89d04977d4ce89a853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Mon, 20 Jul 2015 20:31:19 +0200 Subject: [PATCH 11/55] Qual: prefer CSS centering --- htdocs/core/tpl/login.tpl.php | 8 ++++---- htdocs/theme/eldy/style.css.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 128c4be5de0..99db1ca9b18 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -50,7 +50,7 @@ $(document).ready(function () { -
+
% '; + print ''; print ''; - print "
' . dol_trunc($objp->product_label, 24) . '' . nl2br(dol_trunc($objp->description, 32)) . '' . price($objp->total_ht) . '' . price($objp->tva_tx) . '' . $codeCompta . '' . $objp->rowid . ''; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 02057b31255..3e1622558cb 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent s @@ -41,15 +41,24 @@ $langs->load("main"); $langs->load("accountancy"); $action = GETPOST('action'); + +//Select Box $codeventil = GETPOST('codeventil', 'array'); $mesCasesCochees = GETPOST('mesCasesCochees', 'array'); + +//Search Getpost +$search_invoice = GETPOST('search_invoice','alpha'); $search_ref = GETPOST('search_ref','alpha'); $search_label = GETPOST('search_label','alpha'); $search_desc = GETPOST('search_desc','alpha'); +$search_amount = GETPOST('search_amount','alpha'); +$search_account = GETPOST('search_account','alpha'); +$search_vat = GETPOST('search_vat','alpha'); +//Getpost Order and column and limit page $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); -//Should move to top with all GETPOST + $page = GETPOST('page'); if ($page < 0) $page = 0; @@ -62,18 +71,8 @@ if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { $limit = $conf->liste_limit; } $offset = $limit * $page; -//End Should move to top with all GETPOST - -// TODO : remove comment -//elarifr we can not use only -//$sql .= " ORDER BY l.rowid"; -// f.datef will order like FA08 FA09 FA10 FA05 FA06 FA07 FA04... -// f.ref will not order properly invoice / avoir / accompte you can have All AC then All AV and all FA -// l.rowid when an invoice is edited rowid are added at end of table & facturedet.rowid are not ordered -//if (! $sortfield) $sortfield="l.rowid"; if (! $sortfield) $sortfield="f.datef, f.ref, l.rowid"; -//if (! $sortorder) $sortorder="DESC"; if (! $sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { $sortorder = " DESC "; @@ -103,6 +102,9 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $search_ref=''; $search_label=''; $search_desc=''; + $search_amount=''; + $search_account=''; + $search_vat=''; } /* @@ -110,9 +112,6 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both */ llxHeader('', $langs->trans("Ventilation")); -//debug -//print_r($aarowid_s); -//print_r($aarowid_p); print ''; -//TODO For select box print ''; + $(function () { + $(\'#select-all\').click(function(event) { + // Iterate each checkbox + $(\':checkbox\').each(function() { + this.checked = true; + }); + }); + $(\'#unselect-all\').click(function(event) { + // Iterate each checkbox + $(\':checkbox\').each(function() { + this.checked = false; + }); + }); + }); + '; -/* - * Action - */ -//TODO -/* -if ($action == 'ventil') { - print '
' . $langs->trans("Processing") . '...
'; - if (! empty($codeventil_buy) && ! empty($mesCasesCochees)) { - if (! empty($codeventil_sell) && ! empty($mesCasesCochees)) { - } else { - print '
' . $langs->trans("AnyLineVentilate") . '
'; - } - print '
' . $langs->trans("EndProcessing") . '
'; -} -*/ -//do we really need to exclude old product not tosell / tobuy ? -//$sql = "SELECT p.rowid, p.ref , p.label, p.description , p.accountancy_code_sell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type , p.tosell , p.tobuy "; -//$sql .= " WHERE p.accountancy_code_sell IS NULL AND p.tosell = 1 OR p.accountancy_code_buy IS NULL AND p.tobuy = 1"; -//$sql .= " WHERE p.accountancy_code_sell ='' AND p.tosell = 1 OR p.accountancy_code_buy ='' AND p.tobuy = 1"; $sql = "SELECT p.rowid, p.ref , p.label, p.description , p.accountancy_code_sell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type"; $sql .= " FROM " . MAIN_DB_PREFIX . "product as p"; -//$sql .= " , " . MAIN_DB_PREFIX . "accountingaccount as aa"; $sql .= " WHERE ("; $sql .= " p.accountancy_code_sell ='' OR p.accountancy_code_sell IS NULL OR p.accountancy_code_buy ='' OR p.accountancy_code_buy IS NULL"; -//Search on correct pcg version + $pcgver = $conf->global->CHARTOFACCOUNTS; $sql .= " OR (p.accountancy_code_sell IS NOT NULL AND p.accountancy_code_sell != '' AND p.accountancy_code_sell NOT IN - (SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))"; - //(SELECT account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa WHERE fk_pcg_version='PCG99-BASE'))"; + (SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))"; $sql .= " OR (p.accountancy_code_buy IS NOT NULL AND p.accountancy_code_buy != '' AND p.accountancy_code_buy NOT IN - (SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))"; - //(SELECT account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa WHERE fk_pcg_version='PCG99-BASE'))"; + (SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))"; $sql .= ")"; //Add search filter like if (strlen(trim($search_ref))) { - $sql .= " AND (p.ref like '" . $search_ref . "%')"; + $sql .= " AND (p.ref like '" . $search_ref . "%')"; } if (strlen(trim($search_label))) { - $sql .= " AND (p.label like '" . $search_label . "%')"; + $sql .= " AND (p.label like '" . $search_label . "%')"; } if (strlen(trim($search_desc))) { - $sql .= " AND (p.description like '%" . $search_desc . "%')"; + $sql .= " AND (p.description like '%" . $search_desc . "%')"; } $sql.= $db->order($sortfield,$sortorder); @@ -249,176 +238,170 @@ $sql .= $db->plimit($limit + 1, $offset); dol_syslog("/accountancy/admin/productaccount.php:: sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); if ($result) { - $num_lines = $db->num_rows($result); - $i = 0; + $num_lines = $db->num_rows($result); + $i = 0; /* - - * View */ - print_barre_liste($langs->trans("ProductAccountingAccountSelect"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines); + print_barre_liste($langs->trans("ProductAccountingAccountSelect"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines); - print '
' . $langs->trans("DescProductAccountingAccount") . '
'; +print ''; +print ''; +print "\n"; +print ''; +print '\n"; +print ''; +print '\n"; + +print "
'.$langs->trans('OptionMode').''.$langs->trans('Description').'
'.$langs->trans('Accountancy_code_sell').''.nl2br($langs->trans('OptionModeProductSell')); +print "
'.$langs->trans('Accountancy_code_buy').''.nl2br($langs->trans('OptionModeProductBuy'))."
\n"; + +print '

'; + +print "
\n"; -//DEBUG -//print $sql; - print '
'; -// print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print '
' . $langs->trans("ChangeAccount") . '
'; - print $langs->trans("Accountancy_code_buy") . ': ' . $form->select_account($account_number_buy, 'account_number_buy', 1,'', 0, 1); - print '
'; - print '
'; - print '
' . $langs->trans("ChangeAccount") . '
'; - print $langs->trans("Accountancy_code_sell") . ': ' . $form->select_account($account_number_sell, 'account_number_sell', 1, '', 0, 1); - print '
'; - print '
'; - //TODO change button - print ''; - print '
'; - print ''; - print ''; -// print ''; -// print ''; -// print ''; - print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"],"p.ref","",$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"],"p.label","",$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"],"l.description","",$param,'',$sortfield,$sortorder); - print ''; - print ''; - print ''; - print ''; - print_liste_field_titre(''); -// print_liste_field_titre(''); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ' '; + print_liste_field_titre($langs->trans("RowId"), $_SERVER["PHP_SELF"],"p.rowid","",$param,'',$sortfield,$sortorder); + print '  '; - print ''; - print ''; -// print ''; - print ''; - - $var = true; - - while ( $i < min($num_lines, 250) ) { - $obj = $db->fetch_object($result); - $var = ! $var; - - $compta_prodsell = $obj->accountancy_code_sell; - if (empty($compta_prodsell)) { - if ($obj->product_type == 0) { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodsell_id = $aarowid_prodsell; - } else { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodsell_id = $aarowid_servsell; - } - } - - $compta_prodbuy = $obj->accountancy_code_buy; - if (empty($compta_prodbuy)) { - if ($obj->product_type == 0) { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodbuy_id = $aarowid_prodbuy; - } else { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodbuy_id = $aarowid_servbuy; - } - } - - $product_static = new Product($db); - - print ""; -//debug -print ''; + print '
' . $langs->trans("Ref") . '' . $langs->trans("Label") . '' . $langs->trans("Description") . '' . $langs->trans("Accountancy_code_buy") . '' . $langs->trans("Accountancy_code_buy_suggest") . '' . $langs->trans("Accountancy_code_sell") . '' . $langs->trans("Accountancy_code_sell_suggest") . '' . $langs->trans("Ventilate") . '
/'.'
%%' . $langs->trans("DescProductAccountingAccount") . ' '; - print ''; -// print ''; - print ' '; - print ''; -// print ''; - print ' 
Compte Suggeres compta_prodbuy=' . $compta_prodbuy . ' -- compta_prodbuy_id' . $compta_prodbuy_id . '-- compta_prodsell:' . $compta_prodsell . '-- compta_prodsell_id' . $compta_prodsell_id . '
'; + print ''; + print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"],"p.ref","",$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"],"p.label","",$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"],"l.description","",$param,'',$sortfield,$sortorder); + IF ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') { + print ''; + print ''; + } + else { + print ''; + print ''; + } + print_liste_field_titre(''); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print ""; - print ""; - // Ref produit as link - $product_static->ref = $obj->ref; - $product_static->id = $obj->rowid; - $product_static->type = $obj->type; - print ''; + print ''; + print ''; + print ''; + + $var = true; + + while ( $i < min($num_lines, 250) ) { + $obj = $db->fetch_object($result); + $var = ! $var; + + $compta_prodsell = $obj->accountancy_code_sell; + + if ($obj->product_type == 0) { + $compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell_id = $aarowid_prodsell; + } else { + $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell_id = $aarowid_servsell; + } + + + $compta_prodbuy = $obj->accountancy_code_buy; + + if ($obj->product_type == 0) { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_prodbuy; + } else { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_servbuy; + } + + + $product_static = new Product($db); + + print ""; - print ''; + print ""; + print ""; + // Ref produit as link + $product_static->ref = $obj->ref; + $product_static->id = $obj->rowid; + $product_static->type = $obj->type; + print ''; + print ''; //TODO ADJUST DESCRIPTION SIZE -// print ''; - //TODO: we shoul set a user defined value to adjust user square / wide screen size - $trunclengh = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; - print ''; +// print ''; + //TODO: we shoul set a user defined value to adjust user square / wide screen size + $trunclengh = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; + print ''; - //acountingaccount buy - print ''; + //acountingaccount buy + + IF ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') { + print ''; //TODO: replace by select -// print ''; - //TODO: we shoul set a user defined value to adjust user square / wide screen size - //$trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; - print ''; - - //acountingaccount sel - print ''; +// print ''; + //TODO: we shoul set a user defined value to adjust user square / wide screen size + //$trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; + print ''; + } + Else { + //acountingaccount sel + print ''; //TODO: replace by select - //TODO: we shoul set a user defined value to adjust user square / wide screen size - //$trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; - print ''; - //action edit & select box - print ''; - print ''; - //Checkbox select - print ''; + //TODO: we shoul set a user defined value to adjust user square / wide screen size + //$trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; + print ''; + } + + //Checkbox select + print ''; - print ""; - $i ++; - } + print ""; + $i ++; + } + print '
' . $langs->trans("Accountancy_code_buy") . '' . $langs->trans("Accountancy_code_buy_suggest") . '' . $langs->trans("Accountancy_code_sell") . '' . $langs->trans("Accountancy_code_sell_suggest") . '' . $langs->trans("Ventilate") . '
/'.'
%%
'; - if ($product_static->id) - print $product_static->getNomUrl(1); - else - print '- '; - print ' '; + print ''; + print ' '; + print ''; + print '
' . $obj->label . '
'; + if ($product_static->id) + print $product_static->getNomUrl(1); + else + print '- '; + print '' . $obj->label . '' . $obj->description . '' . nl2br(dol_trunc($obj->description, $trunclengh)) . '' . $obj->description . '' . nl2br(dol_trunc($obj->description, $trunclengh)) . '' . $obj->accountancy_code_buy . '' . $obj->accountancy_code_buy . '' . $compta_prodbuy . ''; - print $form->select_account($compta_prodbuy_id, 'codeventil[]', 1); - print '' . $obj->accountancy_code_sell . '' . $compta_prodbuy . ''; + print $form->select_account($compta_prodbuy_id, 'codeventil[]', 1); + print '' . $obj->accountancy_code_sell . ''; - print $form->select_account($compta_prodsell_id, 'codeventil[]', 1); - print '' . $obj->rowid . ''; - print img_edit(); - print ''; - print ''; + print $form->select_account($compta_prodsell_id, 'codeventil[]', 1); + print ''; + print '
'; + print '
'; + print ''; - $db->free($result); + + + $db->free($result); } else { -// print $db->error(); - dol_print_error($db); + dol_print_error($db); } -print ""; + llxFooter(); $db->close(); \ No newline at end of file From 01671d02d1a7dae4ec3031a6986863d5665678ba Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Fri, 7 Aug 2015 00:39:44 +0200 Subject: [PATCH 35/55] New pdf for project - listing of elements --- .../project/doc/pdf_beluga.modules.php | 618 ++++++++++++++++++ 1 file changed, 618 insertions(+) create mode 100644 htdocs/core/modules/project/doc/pdf_beluga.modules.php diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php new file mode 100644 index 00000000000..7bca394d161 --- /dev/null +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -0,0 +1,618 @@ + + * Copyright (C) 2015 Charlie Benke + + * 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 . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/project/doc/pdf_beluga.modules.php + * \ingroup project + * \brief Fichier de la classe permettant de generer les projets au modele beluga + * \author Charlie Benke + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; + +if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; +if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; +if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; +if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; +if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + + + +/** + * Classe permettant de generer les projets au modele Baleine + */ + +class pdf_beluga extends ModelePDFProjects +{ + var $emetteur; // Objet societe qui emet + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + global $conf,$langs,$mysoc; + + $langs->load("main"); + $langs->load("projects"); + $langs->load("companies"); + + $this->db = $db; + $this->name = "beluga"; + $this->description = $langs->trans("DocumentModelBeluga"); + + // Dimension page pour format A4 + $this->type = 'pdf'; + $formatarray=pdf_getFormat(); + $this->page_largeur = $formatarray['width']; + $this->page_hauteur = $formatarray['height']; + $this->format = array($this->page_largeur,$this->page_hauteur); + $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; + $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; + $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; + $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + + $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION + $this->option_codeproduitservice = 1; // Affiche code produit-service + + // Recupere emmetteur + $this->emetteur=$mysoc; + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined + + // Defini position des colonnes + $this->posxref=$this->marge_gauche+1; + $this->posxdate=$this->marge_gauche+25; + $this->posxsociety=$this->marge_gauche+45; + $this->posxamountht=$this->marge_gauche+115; + $this->posxamountttc=$this->marge_gauche+140; + $this->posxstatut=$this->marge_gauche+165; + } + + + /** + * Fonction generant le projet sur le disque + * + * @param Project $object Object project a generer + * @param Translate $outputlangs Lang output object + * @return int 1 if OK, <=0 if KO + */ + function write_file($object,$outputlangs) + { + global $user,$langs,$conf; + +$formproject=new FormProjets($this->db); + + if (! is_object($outputlangs)) $outputlangs=$langs; + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + + $outputlangs->load("main"); + $outputlangs->load("dict"); + $outputlangs->load("companies"); + $outputlangs->load("projects"); + + if ($conf->projet->dir_output) + { + //$nblignes = count($object->lines); // This is set later with array of tasks + + $objectref = dol_sanitizeFileName($object->ref); + $dir = $conf->projet->dir_output; + if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; + $file = $dir . "/" . $objectref . ".pdf"; + + if (! file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); + return 0; + } + } + + if (file_exists($dir)) + { + // Add pdfgeneration hook + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('pdfgeneration')); + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + global $action; + $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + + $pdf=pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $heightforinfotot = 50; // Height reserved to output the info and total part + $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + $pdf->SetAutoPageBreak(1,0); + + if (class_exists('TCPDF')) + { + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + } + $pdf->SetFont(pdf_getPDFFont($outputlangs)); + + // Complete object by loading several other informations + $task = new Task($this->db); + $tasksarray = $task->getTasksArray(0,0,$object->id); + + $object->lines=$tasksarray; + $nblignes=count($object->lines); + + $pdf->Open(); + $pagenb=0; + $pdf->SetDrawColor(128,128,128); + + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); + $pdf->SetSubject($outputlangs->transnoentities("Project")); + $pdf->SetCreator("Dolibarr ".DOL_VERSION); + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project")); + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + + // New page + $pdf->AddPage(); + $pagenb++; + $this->_pagehead($pdf, $object, 1, $outputlangs); + $pdf->SetFont('','', $default_font_size - 1); + $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->SetTextColor(0,0,0); + + $tab_top = 50; + $tab_height = 200; + $tab_top_newpage = 40; + $tab_height_newpage = 210; + + // Affiche notes + if (! empty($object->note_public)) + { + $pdf->SetFont('','', $default_font_size - 1); + $pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($object->note_public), 0, 1); + $nexY = $pdf->GetY(); + $height_note=$nexY-($tab_top-2); + + // Rect prend une longueur en 3eme param + $pdf->SetDrawColor(192,192,192); + $pdf->Rect($this->marge_gauche, $tab_top-3, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + + $tab_height = $tab_height - $height_note; + $tab_top = $nexY+6; + } + else + { + $height_note=0; + } + + $iniY = $tab_top + 7; + $curY = $tab_top + 7; + $nexY = $tab_top + 7; + +$listofreferent=array( +'propal'=>array( + 'name'=>"Proposals", + 'title'=>"ListProposalsAssociatedProject", + 'class'=>'Propal', + 'table'=>'propal', + 'datefieldname'=>'datep', + 'test'=>$conf->propal->enabled && $user->rights->propale->lire), +'order'=>array( + 'name'=>"CustomersOrders", + 'title'=>"ListOrdersAssociatedProject", + 'class'=>'Commande', + 'table'=>'commande', + 'datefieldname'=>'date_commande', + 'test'=>$conf->commande->enabled && $user->rights->commande->lire), +'invoice'=>array( + 'name'=>"CustomersInvoices", + 'title'=>"ListInvoicesAssociatedProject", + 'class'=>'Facture', + 'margin'=>'add', + 'table'=>'facture', + 'datefieldname'=>'datef', + 'test'=>$conf->facture->enabled && $user->rights->facture->lire), +'invoice_predefined'=>array( + 'name'=>"PredefinedInvoices", + 'title'=>"ListPredefinedInvoicesAssociatedProject", + 'class'=>'FactureRec', + 'table'=>'facture_rec', + 'datefieldname'=>'datec', + 'test'=>$conf->facture->enabled && $user->rights->facture->lire), +'order_supplier'=>array( + 'name'=>"SuppliersOrders", + 'title'=>"ListSupplierOrdersAssociatedProject", + 'class'=>'CommandeFournisseur', + 'table'=>'commande_fournisseur', + 'datefieldname'=>'date_commande', + 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire), +'invoice_supplier'=>array( + 'name'=>"BillsSuppliers", + 'title'=>"ListSupplierInvoicesAssociatedProject", + 'class'=>'FactureFournisseur', + 'margin'=>'minus', + 'table'=>'facture_fourn', + 'datefieldname'=>'datef', + 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire), +'contract'=>array( + 'name'=>"Contracts", + 'title'=>"ListContractAssociatedProject", + 'class'=>'Contrat', + 'table'=>'contrat', + 'datefieldname'=>'date_contrat', + 'test'=>$conf->contrat->enabled && $user->rights->contrat->lire), +'intervention'=>array( + 'name'=>"Interventions", + 'title'=>"ListFichinterAssociatedProject", + 'class'=>'Fichinter', + 'table'=>'fichinter', + 'datefieldname'=>'date_valid', + 'disableamount'=>1, + 'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire), +'trip'=>array( + 'name'=>"TripsAndExpenses", + 'title'=>"ListTripAssociatedProject", + 'class'=>'Deplacement', + 'table'=>'deplacement', + 'datefieldname'=>'dated', + 'margin'=>'minus', + 'disableamount'=>1, + 'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire), +'agenda'=>array( + 'name'=>"Agenda", + 'title'=>"ListActionsAssociatedProject", + 'class'=>'ActionComm', + 'table'=>'actioncomm', + 'datefieldname'=>'datep', + 'disableamount'=>1, + 'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->lire) +); + + +foreach ($listofreferent as $key => $value) +{ + $title=$value['title']; + $classname=$value['class']; + $tablename=$value['table']; + $datefieldname=$value['datefieldname']; + $qualified=$value['test']; + + if ($qualified) + { + $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee); + $num=count($elementarray); +if ($num> 0) +{ + $nexY = $pdf->GetY()+5; + $curY = $nexY; + $pdf->SetXY($this->posxref, $curY); + $pdf->MultiCell($this->posxstatut-$this->posxref, 3, $outputlangs->transnoentities($title), 0, 'L'); + + + $selectList=$formproject->select_element($tablename,$project->thirdparty->id); + $nexY = $pdf->GetY()+1; + $curY = $nexY; + $pdf->SetXY($this->posxref, $curY); + $pdf->MultiCell($this->posxdate-$this->posxref, 3, $outputlangs->transnoentities("Ref"), 1, 'L'); + $pdf->SetXY($this->posxdate, $curY); + $pdf->MultiCell($this->posxsociety-$this->posxdate, 3, $outputlangs->transnoentities("Date"), 1, 'C'); + $pdf->SetXY($this->posxsociety, $curY); + $pdf->MultiCell($this->posxamountht-$this->posxsociety, 3, $outputlangs->transnoentities("ThirdParty"), 1, 'L'); + if (empty($value['disableamount'])) + { + $pdf->SetXY($this->posxamountht, $curY); + $pdf->MultiCell($this->posxamountttc-$this->posxamountht, 3, $outputlangs->transnoentities("AmountHT"), 1, 'R'); + $pdf->SetXY($this->posxamountttc, $curY); + $pdf->MultiCell($this->posxstatut-$this->posxamountttc, 3, $outputlangs->transnoentities("AmountTTC"), 1, 'R'); + } + else + { + $pdf->SetXY($this->posxamountht, $curY); + $pdf->MultiCell($this->posxstatut-$this->posxamountht, 3, "", 1, 'R'); + } + $pdf->SetXY($this->posxstatut, $curY); + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxstatut, 3, $outputlangs->transnoentities("Statut"), 1, 'R'); + + + if (is_array($elementarray) && count($elementarray)>0) + { + $nexY = $pdf->GetY(); + $curY = $nexY; + + $total_ht = 0; + $total_ttc = 0; + $num=count($elementarray); + for ($i = 0; $i < $num; $i++) + { + $element = new $classname($this->db); + $element->fetch($elementarray[$i]); + $element->fetch_thirdparty(); + //print $classname; + + $qualifiedfortotal=true; + if ($key == 'invoice') + { + if ($element->close_code == 'replaced') $qualifiedfortotal=false; // Replacement invoice + } + + $pdf->SetXY($this->posxref, $curY); + $pdf->MultiCell($this->posxdate-$this->posxref, 3, $element->ref, 1, 'L'); + + + // Date + if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') $date=$element->date_commande; + else + { + $date=$element->date; + if (empty($date)) $date=$element->datep; + if (empty($date)) $date=$element->date_contrat; + if (empty($date)) $date=$element->datev; //Fiche inter + } + + $pdf->SetXY($this->posxdate, $curY); + $pdf->MultiCell($this->posxsociety-$this->posxdate, 3, dol_print_date($date,'day'), 1, 'C'); + + $pdf->SetXY($this->posxsociety, $curY); + if (is_object($element->thirdparty)) + $pdf->MultiCell($this->posxamountht-$this->posxsociety, 3, $element->thirdparty->name, 1, 'L'); + + + // Amount without tax + if (empty($value['disableamount'])) + { + $pdf->SetXY($this->posxamountht, $curY); + $pdf->MultiCell($this->posxamountttc-$this->posxamountht, 3, + (isset($element->total_ht)?price($element->total_ht):' '), 1, 'R'); + $pdf->SetXY($this->posxamountttc, $curY); + $pdf->MultiCell($this->posxstatut-$this->posxamountttc, 3, + (isset($element->total_ttc)?price($element->total_ttc):' '), 1, 'R'); + } + else + { + $pdf->SetXY($this->posxamountht, $curY); + $pdf->MultiCell($this->posxstatut-$this->posxamountht, 3, "", 1, 'R'); + } + + // Status + if ($element instanceof CommonInvoice) { + //This applies for Facture and FactureFournisseur + $outputstatut= $element->getLibStatut(1, $element->getSommePaiement()); + } else { + $outputstatut = $element->getLibStatut(1); + } + $pdf->SetXY($this->posxstatut, $curY); + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxstatut, 3, + $outputstatut, 1, 'R',false, 1, '', '', true, 0, true); + + if ($qualifiedfortotal) + { + $total_ht = $total_ht + $element->total_ht; + $total_ttc = $total_ttc + $element->total_ttc; + } +$nexY = $pdf->GetY(); + $curY = $nexY; + } + + + if (empty($value['disableamount'])) + { + $curY = $nexY; + $pdf->SetXY($this->posxref, $curY); + $pdf->MultiCell($this->posxamountttc-$this->posxref, 3, "TOTAL", 1, 'L'); + $pdf->SetXY($this->posxamountht, $curY); + $pdf->MultiCell($this->posxamountttc-$this->posxamountht, 3, + (isset($element->total_ht)?price($total_ht):' '), 1, 'R'); + $pdf->SetXY($this->posxamountttc, $curY); + $pdf->MultiCell($this->posxstatut-$this->posxamountttc, 3, + (isset($element->total_ttc)?price($total_ttc):' '), 1, 'R'); + $pdf->SetXY($this->posxstatut, $curY); + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxstatut, 3, + $outputlangs->transnoentities("Nb")." ".$num, 1, 'L'); + } + $nexY = $pdf->GetY()+5; + $curY = $nexY; + } + } +} +} + + + + /* + * Pied de page + */ + $this->_pagefoot($pdf,$object,$outputlangs); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); + + $pdf->Close(); + + $pdf->Output($file,'F'); + + // Add pdfgeneration hook + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('pdfgeneration')); + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + global $action; + $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + + return 1; // Pas d'erreur + } + else + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); + return 0; + } + } + + $this->error=$langs->transnoentities("ErrorConstantNotDefined","LIVRAISON_OUTPUTDIR"); + return 0; + } + + + /** + * Show table for lines + * + * @param PDF $pdf Object PDF + * @param string $tab_top Top position of table + * @param string $tab_height Height of table (rectangle) + * @param int $nexY Y + * @param Translate $outputlangs Langs object + * @param int $hidetop Hide top bar of array + * @param int $hidebottom Hide bottom bar of array + * @return void + */ + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) + { + global $conf,$mysoc; + + $default_font_size = pdf_getPDFFontSize($outputlangs); + + $pdf->SetDrawColor(128,128,128); + + // Rect prend une longueur en 3eme param + $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height); + // line prend une position y en 3eme param + $pdf->line($this->marge_gauche, $tab_top+6, $this->page_largeur-$this->marge_droite, $tab_top+6); + + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('','', $default_font_size); + + $pdf->SetXY($this->posxref, $tab_top+1); + $pdf->MultiCell($this->posxlabel-$this->posxref,3, $outputlangs->transnoentities("Tasks"),'','L'); + + $pdf->SetXY($this->posxlabel, $tab_top+1); + $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L'); + + $pdf->SetXY($this->posxworkload, $tab_top+1); + $pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R'); + + $pdf->SetXY($this->posxprogress, $tab_top+1); + $pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R'); + + $pdf->SetXY($this->posxdatestart, $tab_top+1); + $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, '', 0, 'C'); + + $pdf->SetXY($this->posxdateend, $tab_top+1); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C'); + + } + + /** + * Show top header of page. + * + * @param PDF $pdf Object PDF + * @param Object $object Object to show + * @param int $showaddress 0=no, 1=yes + * @param Translate $outputlangs Object lang for output + * @return void + */ + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + { + global $langs,$conf,$mysoc; + + $default_font_size = pdf_getPDFFontSize($outputlangs); + + pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); + + $pdf->SetTextColor(0,0,60); + $pdf->SetFont('','B', $default_font_size + 3); + + $posx=$this->page_largeur-$this->marge_droite-100; + $posy=$this->marge_haute; + + $pdf->SetXY($this->marge_gauche,$posy); + + // Logo + $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; + if ($mysoc->logo) + { + if (is_readable($logo)) + { + $height=pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + } + else + { + $pdf->SetTextColor(200,0,0); + $pdf->SetFont('','B', $default_font_size - 2); + $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); + $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); + } + } + else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); + + $pdf->SetFont('','B', $default_font_size + 3); + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); + $pdf->SetFont('','', $default_font_size + 2); + + $posy+=6; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R'); + $posy+=6; + $pdf->SetXY($posx,$posy); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R'); + + $pdf->SetTextColor(0,0,60); + + } + + /** + * Show footer of page. Need this->emetteur object + * + * @param PDF $pdf PDF + * @param Object $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return void + */ + function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) + { + $showdetails=0; + return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); + } +} From 5177c5f22766e63a1df6984d7b32d2d71c3ecd84 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 7 Aug 2015 09:27:46 +0200 Subject: [PATCH 36/55] fix #3338 broken links on shippment card --- htdocs/expedition/shipment.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 42764223f3e..07b7cd70a13 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003-2006 Rodolphe Quiedeville * Copyright (C) 2005-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2012-2015 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 @@ -329,7 +329,7 @@ if ($id > 0 || ! empty($ref)) print $langs->trans('AvailabilityPeriod'); print ''; if ($action != 'editavailability') - print 'id . '">' . img_edit($langs->trans('SetAvailability'), 1) . ''; + print 'id . '">' . img_edit($langs->trans('SetAvailability'), 1) . ''; print ''; print ''; if ($action == 'editavailability') { @@ -345,7 +345,7 @@ if ($id > 0 || ! empty($ref)) print $langs->trans('Source'); print ''; if ($action != 'editdemandreason') - print 'id . '">' . img_edit($langs->trans('SetDemandReason'), 1) . ''; + print 'id . '">' . img_edit($langs->trans('SetDemandReason'), 1) . ''; print ''; print ''; if ($action == 'editdemandreason') { From 9f2b4c503e1bd14fb7235b3e078b447a8307cafa Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 7 Aug 2015 09:57:43 +0200 Subject: [PATCH 37/55] Fix #3236 --- htdocs/langs/en_US/printing.lang | 1 + htdocs/printing/admin/printing.php | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/printing.lang b/htdocs/langs/en_US/printing.lang index b4956e59c01..ce287f91dfe 100644 --- a/htdocs/langs/en_US/printing.lang +++ b/htdocs/langs/en_US/printing.lang @@ -10,6 +10,7 @@ PrintTestDesc=List of Printers. FileWasSentToPrinter=File %s was sent to printer NoActivePrintingModuleFound=No active module to print document PleaseSelectaDriverfromList=Please select a driver from list. +PleaseConfigureDriverfromList=Please configure the selected driver from list. SetupDriver=Driver setup TestDriver=Test TargetedPrinter=Targeted printer diff --git a/htdocs/printing/admin/printing.php b/htdocs/printing/admin/printing.php index 36727048fc4..408d7cdfa87 100644 --- a/htdocs/printing/admin/printing.php +++ b/htdocs/printing/admin/printing.php @@ -229,7 +229,12 @@ if ($mode == 'test' && $user->admin) $langs->load($driver); $printer = new $classname($db); //print '
'.print_r($printer, true).'
'; - print $printer->listAvailablePrinters(); + if ($printer->getlist_available_printers) { + print $printer->listAvailablePrinters(); + } + else { + print $langs->trans('PleaseConfigureDriverfromList'); + } } else { print $langs->trans('PleaseSelectaDriverfromList'); From ef6b96b4c7394a6b70991be2ea8a8ad9abcec943 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 7 Aug 2015 10:12:10 +0200 Subject: [PATCH 38/55] Fix #3236 --- htdocs/langs/en_US/printing.lang | 1 + htdocs/printing/admin/printing.php | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/printing.lang b/htdocs/langs/en_US/printing.lang index b4956e59c01..ce287f91dfe 100644 --- a/htdocs/langs/en_US/printing.lang +++ b/htdocs/langs/en_US/printing.lang @@ -10,6 +10,7 @@ PrintTestDesc=List of Printers. FileWasSentToPrinter=File %s was sent to printer NoActivePrintingModuleFound=No active module to print document PleaseSelectaDriverfromList=Please select a driver from list. +PleaseConfigureDriverfromList=Please configure the selected driver from list. SetupDriver=Driver setup TestDriver=Test TargetedPrinter=Targeted printer diff --git a/htdocs/printing/admin/printing.php b/htdocs/printing/admin/printing.php index 36727048fc4..d848b0befce 100644 --- a/htdocs/printing/admin/printing.php +++ b/htdocs/printing/admin/printing.php @@ -229,7 +229,12 @@ if ($mode == 'test' && $user->admin) $langs->load($driver); $printer = new $classname($db); //print '
'.print_r($printer, true).'
'; - print $printer->listAvailablePrinters(); + if (count($printer->getlist_available_printers)) { + print $printer->listAvailablePrinters(); + } + else { + print $langs->trans('PleaseConfigureDriverfromList'); + } } else { print $langs->trans('PleaseSelectaDriverfromList'); From 12b83fd3e8ec3ee5b79f6ce52469c5504dec193d Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 7 Aug 2015 12:45:27 +0200 Subject: [PATCH 39/55] Fix #3304 --- htdocs/core/modules/modBarcode.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modBarcode.class.php b/htdocs/core/modules/modBarcode.class.php index c9ba87250bb..13af745e004 100644 --- a/htdocs/core/modules/modBarcode.class.php +++ b/htdocs/core/modules/modBarcode.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2005-2008 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2015 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 @@ -99,7 +100,7 @@ class modBarcode extends DolibarrModules 'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>200, 'enabled'=>'$conf->barcode->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'perms'=>'$user->rights->barcode->lire_advance', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both $r++; @@ -111,7 +112,7 @@ class modBarcode extends DolibarrModules 'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>300, 'enabled'=>'$conf->barcode->enabled && $leftmenu=="modulesadmintools"', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'perms'=>'$user->rights->barcode->creer_advance', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both $r++; From 0afd27e3c245617ddc2fdfeef1c36fb36f23871f Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 7 Aug 2015 13:29:11 +0200 Subject: [PATCH 40/55] New : % of evolution on stats --- htdocs/comm/propal/stats/index.php | 6 ++++++ htdocs/commande/stats/index.php | 6 ++++++ htdocs/compta/facture/stats/index.php | 6 ++++++ htdocs/core/class/stats.class.php | 3 +++ 4 files changed, 21 insertions(+) diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index 898f228fdb2..2622a6c239f 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -266,8 +266,11 @@ print ''; print ''; print ''; print ''; +print ''; print ''; +print ''; print ''; +print ''; print ''; $oldyear=0; @@ -287,8 +290,11 @@ foreach ($data as $val) print ''; print ''; print ''; + print ''; print ''; + print ''; print ''; + print ''; print ''; $oldyear=$year; } diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 71558be0e57..fd384524597 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -279,8 +279,11 @@ print '
'.$langs->trans("Year").''.$langs->trans("NbOfProposals").'%'.$langs->trans("AmountTotal").'%'.$langs->trans("AmountAverage").'%
0?'&userid='.$userid:'').'">'.$year.''.$val['nb'].''.round($val['nb_diff']).''.price(price2num($val['total'],'MT'),1).''.round($val['total_diff']).''.price(price2num($val['avg'],'MT'),1).''.round($val['avg_diff']).'
'; print ''; print ''; print ''; +print ''; print ''; +print ''; print ''; +print ''; print ''; $oldyear=0; @@ -302,8 +305,11 @@ foreach ($data as $val) print ''; print ''; print ''; + print ''; print ''; + print ''; print ''; + print ''; print ''; $oldyear=$year; } diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 4eeea76abc0..afd17ed2f17 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -263,8 +263,11 @@ print '
'.$langs->trans("Year").''.$langs->trans("NbOfOrders").'%'.$langs->trans("AmountTotal").'%'.$langs->trans("AmountAverage").'%
0?'&userid='.$userid:'').'">'.$year.''.$val['nb'].''.round($val['nb_diff']).''.price(price2num($val['total'],'MT'),1).''.round($val['total_diff']).''.price(price2num($val['avg'],'MT'),1).''.round($val['avg_diff']).'
'; print ''; print ''; print ''; +print ''; print ''; +print ''; print ''; +print ''; print ''; $oldyear=0; @@ -284,8 +287,11 @@ foreach ($data as $val) print ''; print ''; print ''; + print ''; print ''; + print ''; print ''; + print ''; print ''; $oldyear=$year; } diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index 9a459f33e41..8ef77f3d282 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -383,8 +383,11 @@ abstract class Stats $row = $this->db->fetch_object($resql); $result[$i]['year'] = $row->year; $result[$i]['nb'] = $row->nb; + if($i>0) $result[$i-1]['nb_diff'] = ($result[$i-1]['nb'] - $row->nb) / $row->nb * 100; $result[$i]['total'] = $row->total; + if($i>0) $result[$i-1]['total_diff'] = ($result[$i-1]['total'] - $row->total) / $row->total * 100; $result[$i]['avg'] = $row->avg; + if($i>0) $result[$i-1]['avg_diff'] = ($result[$i-1]['avg'] - $row->avg) / $row->avg * 100; $i++; } $this->db->free($resql); From 0d1b4e6911341eae77fe5ca6b26e43d496a5c859 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 7 Aug 2015 17:09:36 +0200 Subject: [PATCH 41/55] Update fr_FR and es_ES printing message. Transifex works only for develop branch... --- htdocs/langs/es_ES/printing.lang | 1 + htdocs/langs/fr_FR/printing.lang | 1 + 2 files changed, 2 insertions(+) diff --git a/htdocs/langs/es_ES/printing.lang b/htdocs/langs/es_ES/printing.lang index adaeafcf55d..d9ad1655e53 100644 --- a/htdocs/langs/es_ES/printing.lang +++ b/htdocs/langs/es_ES/printing.lang @@ -10,6 +10,7 @@ PrintTestDesc=Listado de Impresoras. FileWasSentToPrinter=El archivo %s ha sido enviado a la impresora NoActivePrintingModuleFound=Sin módulo activo para imprimir documentos PleaseSelectaDriverfromList=Seleccione un driver del listado. +PleaseConfigureDriverfromList=Configure el driver seleccionado del listado. SetupDriver=Configuración driver TestDriver=Prueba TargetedPrinter=Impresora destino diff --git a/htdocs/langs/fr_FR/printing.lang b/htdocs/langs/fr_FR/printing.lang index 2044852a879..eab55c121fa 100644 --- a/htdocs/langs/fr_FR/printing.lang +++ b/htdocs/langs/fr_FR/printing.lang @@ -10,6 +10,7 @@ PrintTestDesc=Liste des imprimantes FileWasSentToPrinter=Le fichier %s a été envoyé à l'imprimante NoActivePrintingModuleFound=Pas de module actif pour imprimer le document PleaseSelectaDriverfromList=Sélection un driver dans la liste +PleaseConfigureDriverfromList=Configurer le driver sélectionné dans la liste. SetupDriver=Configuration du driver TestDriver=Test TargetedPrinter=Imprimante cible From 841cc0fe5e41463d56cee3e92b0cb3271545f758 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 7 Aug 2015 17:52:21 +0200 Subject: [PATCH 42/55] Fix #3355 --- htdocs/contrat/card.php | 8 ++++++-- htdocs/contrat/class/contrat.class.php | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 4cea0fb8c5e..e4dad139339 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -3,12 +3,12 @@ * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2010-2015 Juanjo Menent * Copyright (C) 2013 Christophe Battarel * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Ferran Marcet * Copyright (C) 2014 Marcos García - * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 Jean-François Ferry * * 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 @@ -783,6 +783,10 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra } } } elseif ($action=='setref') { + $result = $object->fetch($id); + if ($result < 0) { + setEventMessage($object->errors, 'errors'); + } $object->ref=GETPOST('ref','alpha'); $result = $object->update($user); diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index ce02649674b..eea23be7ae8 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2008 Raphael Bertrand - * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2010-2015 Juanjo Menent * Copyright (C) 2013 Christophe Battarel * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Marcos García @@ -1147,7 +1147,7 @@ class Contrat extends CommonObject if (isset($this->note_private)) $this->note_private=trim($this->note_private); if (isset($this->note_public)) $this->note_public=trim($this->note_public); if (isset($this->import_key)) $this->import_key=trim($this->import_key); - if (isset($this->extraparams)) $this->extraparams=trim($this->extraparams); + //if (isset($this->extraparams)) $this->extraparams=trim($this->extraparams); @@ -1174,8 +1174,8 @@ class Contrat extends CommonObject $sql.= " fk_user_cloture=".(isset($this->fk_user_cloture)?$this->fk_user_cloture:"null").","; $sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").","; $sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").","; - $sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").","; - $sql.= " extraparams=".(isset($this->extraparams)?"'".$this->db->escape($this->extraparams)."'":"null").""; + $sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").""; + //$sql.= " extraparams=".(isset($this->extraparams)?"'".$this->db->escape($this->extraparams)."'":"null").""; $sql.= " WHERE rowid=".$this->id; From fd6f7dfa61f05ff109964a4a3c247de694c858e4 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 7 Aug 2015 18:01:13 +0200 Subject: [PATCH 43/55] Fix #3355 --- htdocs/contrat/card.php | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index e4dad139339..0a7acee88ea 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -782,21 +782,33 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra exit; } } -} elseif ($action=='setref') { - $result = $object->fetch($id); - if ($result < 0) { - setEventMessage($object->errors, 'errors'); + else { + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id); + exit; } - $object->ref=GETPOST('ref','alpha'); +} elseif ($action=='setref') { + $cancelbutton = GETPOST('cancel'); - $result = $object->update($user); - if ($result < 0) { - setEventMessage($object->errors,'errors'); - $action='editref'; - } else { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } + if (!$cancelbutton) { + $result = $object->fetch($id); + if ($result < 0) { + setEventMessage($object->errors, 'errors'); + } + $object->ref = GETPOST('ref', 'alpha'); + + $result = $object->update($user); + if ($result < 0) { + setEventMessage($object->errors, 'errors'); + $action = 'editref'; + } else { + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + exit; + } + } + else { + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id); + exit; + } } // Generation doc (depuis lien ou depuis cartouche doc) From a11962454fc680d52657e92f52f0d794bc150dfa Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 7 Aug 2015 18:18:07 +0200 Subject: [PATCH 44/55] Best way to change ref and ref_supplier --- htdocs/contrat/card.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 0a7acee88ea..1d2e3355b24 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -762,7 +762,6 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra setEventMessage($object->error,'errors'); } } elseif ($action=='setref_supplier') { - $cancelbutton = GETPOST('cancel'); if (!$cancelbutton) { @@ -771,9 +770,8 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra if ($result < 0) { setEventMessage($object->errors, 'errors'); } - $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); - $result = $object->update($user); + $result = $object->setValueFrom('ref_supplier',GETPOST('ref_supplier','alpha')); if ($result < 0) { setEventMessage($object->errors, 'errors'); $action = 'editref_supplier'; @@ -794,9 +792,8 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra if ($result < 0) { setEventMessage($object->errors, 'errors'); } - $object->ref = GETPOST('ref', 'alpha'); - $result = $object->update($user); + $result = $object->setValueFrom('ref',GETPOST('ref','alpha'));; if ($result < 0) { setEventMessage($object->errors, 'errors'); $action = 'editref'; From cccc543065f86ab4389993aaa07c6ca9a20cf60e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 9 Aug 2015 13:16:55 +0200 Subject: [PATCH 45/55] =?UTF-8?q?Fix:=20[=20bug=20#3288=20]=C2=A0Tasks=20b?= =?UTF-8?q?ox=20is=20not=20properly=20drawn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Close #3288 --- ChangeLog | 1 + htdocs/core/boxes/box_task.php | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e4815781cd0..a744b804407 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,7 @@ FIX [ bug 1925 ] "Link to order" option in supplier invoices is not working prop FIX [ bug #3198 ] Trigger LINECONTRACT_INSERT passes Contrat as $object instead of ContratLigne FIX: Not showing delivery date on rouget pdf FIX: Not showing task extrafields when creating from left menu +FIX [ bug #3288 ] Tasks box is not properly drawn NEW: Created new ContratLigne::insert function diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index fec676d8265..b0070e2a4f3 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -120,12 +120,13 @@ class box_task extends ModeleBoxes // Add the sum à the bottom of the boxes - $this->info_box_contents[$i][0] = array('tr' => 'class="liste_total"', 'td' => 'align="left" colspan="2" ', 'text' => $langs->trans("Total")." ".$textHead); + $this->info_box_contents[$i][0] = array('tr' => 'class="liste_total"', 'td' => 'align="left"', 'text' => $langs->trans("Total")." ".$textHead); + $this->info_box_contents[$i][1] = array('td' => '', 'text' => ""); $this->info_box_contents[$i][2] = array('td' => 'align="right" ', 'text' => number_format($totalnb, 0, ',', ' ')." ".$langs->trans("Tasks")); $this->info_box_contents[$i][3] = array('td' => 'align="right" ', 'text' => ConvertSecondToTime($totalplannedtot,'all',25200,5)); $this->info_box_contents[$i][4] = array('td' => 'align="right" ', 'text' => ConvertSecondToTime($totaldurationtot,'all',25200,5)); $this->info_box_contents[$i][5] = array('td' => '', 'text' => ""); - + } /** From e725d44565e245c470eb1306ca57ac716e4d34ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 9 Aug 2015 13:24:23 +0200 Subject: [PATCH 46/55] Fix [ bug #3286 ]: Payment types are not translated to English Close #3286 --- htdocs/langs/en_US/bills.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 10a8c5fecc4..5dfd5151df4 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -327,8 +327,8 @@ PaymentTypeCB=Credit card PaymentTypeShortCB=Credit card PaymentTypeCHQ=Check PaymentTypeShortCHQ=Check -PaymentTypeTIP=TIP -PaymentTypeShortTIP=TIP +PaymentTypeTIP=Deposit +PaymentTypeShortTIP=Deposit PaymentTypeVAD=On line payment PaymentTypeShortVAD=On line payment PaymentTypeTRA=Bill payment From 94ac0f53057143f925033e9054faabac536663b0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 9 Aug 2015 13:25:09 +0200 Subject: [PATCH 47/55] Fix: remove custom dir creation --- build/perl/virtualmin/dolibarr.pl | 52 +++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/build/perl/virtualmin/dolibarr.pl b/build/perl/virtualmin/dolibarr.pl index f105a89bc4d..a8241055d0f 100644 --- a/build/perl/virtualmin/dolibarr.pl +++ b/build/perl/virtualmin/dolibarr.pl @@ -1,7 +1,7 @@ #---------------------------------------------------------------------------- # \file dolibarr.pl # \brief Dolibarr script install for Virtualmin Pro -# \author (c)2009-2012 Regis Houssin +# \author (c)2009-2015 Regis Houssin #---------------------------------------------------------------------------- @@ -30,8 +30,7 @@ return "Regis Houssin"; # script_dolibarr_versions() sub script_dolibarr_versions { - # TODO Replace this with version of Dolibar we want to install - return ( "x.y.z", "3.6.0"); +return ( "3.7.2", "3.6.3", "3.5.6" ); } sub script_dolibarr_category @@ -57,6 +56,26 @@ local ($d, $ver) = @_; return ("mysql", "postgres"); } +# script_dolibarr_depends(&domain, version) +sub script_dolibarr_depends +{ +local ($d, $ver, $sinfo, $phpver) = @_; +local @rv; + +if ($ver >= 3.6) { + # Check for PHP 5.3+ + local $phpv = &get_php_version($phpver || 5, $d); + if (!$phpv) { + push(@rv, "Could not work out exact PHP version"); + } + elsif ($phpv < 5.3) { + push(@rv, "Dolibarr requires PHP version 5.3 or later"); + } + } + +return @rv; +} + # script_dolibarr_params(&domain, version, &upgrade-info) # Returns HTML for table rows for options for installing dolibarr sub script_dolibarr_params @@ -78,8 +97,7 @@ else { $rv .= &ui_table_row("Database for Dolibarr tables", &ui_database_select("db", undef, \@dbs, $d, "dolibarr")); $rv .= &ui_table_row("Install sub-directory under $hdir", - &ui_opt_textbox("dir", "dolibarr", 30, - "At top level")); + &ui_opt_textbox("dir", &substitute_scriptname_template("dolibarr", $d), 30, "At top level")); if ($d->{'ssl'} && $ver >= 3.0) { $rv .= &ui_table_row("Force https connection?", &ui_yesno_radio("forcehttps", 0)); @@ -159,7 +177,8 @@ if ($opts->{'newdb'} && !$upgrade) { local ($dbtype, $dbname) = split(/_/, $opts->{'db'}, 2); local $dbuser = $dbtype eq "mysql" ? &mysql_user($d) : &postgres_user($d); local $dbpass = $dbtype eq "mysql" ? &mysql_pass($d) : &postgres_pass($d, 1); -local $dbphptype = $dbtype eq "mysql" ? "mysqli" : "pgsql"; +local $dbphptype = $dbtype eq "mysql" && $version >= 3.6 ? "mysql" : + $dbtype eq "mysql" ? "mysqli" : "pgsql"; local $dbhost = &get_database_host($dbtype); local $dberr = &check_script_db_connection($dbtype, $dbname, $dbuser, $dbpass); return (0, "Database connection failed : $dberr") if ($dberr); @@ -201,12 +220,10 @@ if ($opts->{'path'} =~ /\w/) { if (!$upgrade) { local $cdef = "$opts->{'dir'}/conf/conf.php.example"; &run_as_domain_user($d, "cp ".quotemeta($cdef)." ".quotemeta($cfile)); - &set_ownership_permissions(undef, undef, 0777, $cfiledir); - &set_ownership_permissions(undef, undef, 0666, $cfile); + &set_permissions_as_domain_user($d, 0777, $cfiledir); + &set_permissions_as_domain_user($d, 0666, $cfile); &run_as_domain_user($d, "mkdir ".quotemeta($docdir)); - &set_ownership_permissions(undef, undef, 0777, $docdir); - &run_as_domain_user($d, "mkdir ".quotemeta($altdir)); - &set_ownership_permissions(undef, undef, 0777, $altdir); + &set_permissions_as_domain_user($d, 0777, $docdir); } else { # Preserve old config file, documents and custom directory @@ -289,8 +306,8 @@ else { local $dinstall = "$opts->{'dir'}/install"; $dinstall =~ s/\/$//; $out = &run_as_domain_user($d, "rm -rf ".quotemeta($dinstall)); - &set_ownership_permissions(undef, undef, 0644, $cfile); - &set_ownership_permissions(undef, undef, 0755, $cfiledir); + &set_permissions_as_domain_user($d, 0644, $cfile); + &set_permissions_as_domain_user($d, 0755, $cfiledir); } # Return a URL for the user @@ -309,6 +326,7 @@ local $ipage = $opts->{'path'}."/install/".$page.".php"; local ($iout, $ierror); &post_http_connection($d, $ipage, $params, \$iout, \$ierror); +print STDERR $iout; if ($ierror) { return $ierror; @@ -329,10 +347,10 @@ local $derr = &delete_script_install_directory($d, $opts); return (0, $derr) if ($derr); # Remove all llx_ tables from the database -# 3 times because of constraints -&cleanup_script_database($d, $opts->{'db'}, "llx_"); -&cleanup_script_database($d, $opts->{'db'}, "llx_"); -&cleanup_script_database($d, $opts->{'db'}, "llx_"); +# 4 times because of constraints +for(my $i=0; $i<4; $i++) { + &cleanup_script_database($d, $opts->{'db'}, "llx_"); + } # Take out the DB if ($opts->{'newdb'}) { From a24f29ba8bea857787f013c054f1de75df6762b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 9 Aug 2015 13:37:05 +0200 Subject: [PATCH 48/55] Fix [ bug #3341 ]: Missing translation in /compta/paiement_charge.php Close #3341 --- ChangeLog | 1 + htdocs/compta/paiement_charge.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 1394e58a1f3..5054b4edb24 100644 --- a/ChangeLog +++ b/ChangeLog @@ -41,6 +41,7 @@ English Dolibarr ChangeLog - Fix: [ bug #2696 ] Adding complementary attribute fails if code is numerics - Fix: [ bug #3074 ] Accruals accounting use payment date instead of commitment date in turnover reports for salaries - Fix: Not showing product supplier reference when page break +- Fix: [ bug #3341 ] Missing translation in /compta/paiement_charge.php ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index a54a0bcd935..a660259d706 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -178,7 +178,7 @@ if ($_GET["action"] == 'create') print '
'.$langs->trans("Year").''.$langs->trans("NumberOfBills").'%'.$langs->trans("AmountTotal").'%'.$langs->trans("AmountAverage").'%
0?'&userid='.$userid:'').'">'.$year.''.$val['nb'].''.round($val['nb_diff']).''.price(price2num($val['total'],'MT'),1).''.round($val['total_diff']).''.price(price2num($val['avg'],'MT'),1).''.round($val['avg_diff']).'
'; - print ""; + print ""; print ''; print '\n"; From 2f921b643119158db9330afaeb8274c805378cbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 9 Aug 2015 13:46:48 +0200 Subject: [PATCH 49/55] Fix [ bug #3342 ]: Taxes dictionary page does not accept localized decimals for localtax2 rate Close #3342 --- ChangeLog | 1 + htdocs/admin/dict.php | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1394e58a1f3..5eee4306ba6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -41,6 +41,7 @@ English Dolibarr ChangeLog - Fix: [ bug #2696 ] Adding complementary attribute fails if code is numerics - Fix: [ bug #3074 ] Accruals accounting use payment date instead of commitment date in turnover reports for salaries - Fix: Not showing product supplier reference when page break +- Fix: [ bug #3342 ] Taxes dictionary page does not accept localized decimals for localtax2 rate ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 4a4e66e4ea5..38f991faf52 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -516,7 +516,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $i=0; foreach ($listfieldinsert as $f => $value) { - if ($value == 'price' || preg_match('/^amount/i',$value)) { + if ($value == 'price' || preg_match('/^amount/i',$value) || preg_match('/^localtax/i',$value) || $value == 'taux') { $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU'); } else if ($value == 'entity') { @@ -564,7 +564,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $i = 0; foreach ($listfieldmodify as $field) { - if ($field == 'price' || preg_match('/^amount/i',$field)) { + if ($field == 'price' || preg_match('/^amount/i',$field) || preg_match('/^localtax/i',$field) || $field == 'taux') { $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU'); } else if ($field == 'entity') { @@ -1080,17 +1080,20 @@ if ($id) $align="center"; } else if ($fieldlist[$field]=='localtax1') { + $valuetoshow = price($valuetoshow, 0, $langs, 0, 0); if ($obj->localtax1 == 0) $valuetoshow = ''; $align="right"; } else if ($fieldlist[$field]=='localtax2') { + $valuetoshow = price($valuetoshow, 0, $langs, 0, 0); if ($obj->localtax2 == 0) $valuetoshow = ''; $align="right"; } else if (in_array($fieldlist[$field],array('taux','localtax1','localtax2'))) { + $valuetoshow = price($valuetoshow, 0, $langs, 0, 0); $align="right"; } else if (in_array($fieldlist[$field],array('recuperableonly'))) From 8a1c5450c2b74952ae8f156d211a55b3e9f273c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 9 Aug 2015 18:26:12 +0200 Subject: [PATCH 50/55] Fixed minor problem with error alert when creating user --- htdocs/user/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 563dbece92d..737af4baa27 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -255,7 +255,7 @@ if ($action == 'add' && $canadduser) $langs->load("errors"); $db->rollback(); if (is_array($object->errors) && count($object->errors)) setEventMessage($object->errors,'errors'); - else setEventMessage($object->error); + else setEventMessage($object->error, 'errors'); $action="create"; // Go back to create page } @@ -320,7 +320,7 @@ if ($action == 'update' && ! $_POST["cancel"]) $result=$tmpuser->fetch(0, GETPOST("login")); if ($result > 0) { - setEventMessage($langs->trans("ErrorLoginAlreadyExists"), 'errors'); + setEventMessage($langs->trans("ErrorLoginAlreadyExists", GETPOST('login')), 'errors'); $action="edit"; // Go back to create page $error++; } From 2500e26072d2409344858cedf1452373e5b13619 Mon Sep 17 00:00:00 2001 From: Darkjeff Date: Mon, 10 Aug 2015 10:29:05 +0200 Subject: [PATCH 51/55] update product account clean sql if buy or sell --- htdocs/accountancy/admin/productaccount.php | 25 +++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 8d79a81e8e3..7a33a698cd1 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -1,7 +1,7 @@ - * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2014 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Ari Elbaz (elarifr) @@ -102,6 +102,7 @@ if ($action == 'update') { } if ($action == $langs->trans("Change_Account")) +//todo check sql { print '
' . $langs->trans("Processing") . '...
'; if (! empty($codeventil) && ! empty($mesCasesCochees)) @@ -120,7 +121,7 @@ if ($action == $langs->trans("Change_Account")) { $maLigneCourante = explode("_", $maLigneCochee); $monId = $maLigneCourante[0]; - $monNumLigne = $maLigneCourante[2]; + $monNumLigne = $maLigneCourante[1]; $monCompte = $mesCodesVentilChoisis[$monNumLigne]; $sql = " UPDATE " . MAIN_DB_PREFIX . "product"; @@ -212,15 +213,25 @@ print ''; - -$sql = "SELECT p.rowid, p.ref , p.label, p.description , p.accountancy_code_sell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type"; +$sql = "SELECT p.rowid, p.ref , p.label, p.description , p.accountancy_code_sell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type"; $sql .= " FROM " . MAIN_DB_PREFIX . "product as p"; $sql .= " WHERE ("; $pcgver = $conf->global->CHARTOFACCOUNTS; IF ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') { -$sql .= " p.accountancy_code_buy ='' OR p.accountancy_code_buy IS NULL"; -$sql .= " OR (p.accountancy_code_buy IS NOT NULL AND p.accountancy_code_buy != '' AND p.accountancy_code_buy NOT IN + $sql .= " p.accountancy_code_buy ='' OR p.accountancy_code_buy IS NULL"; + $sql .= " OR (p.accountancy_code_buy IS NOT NULL AND p.accountancy_code_buy != '' AND p.accountancy_code_buy NOT IN (SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))"; - } - ELSE { -$sql .= " p.accountancy_code_sell ='' OR p.accountancy_code_sell IS NULL "; -$sql .= " OR (p.accountancy_code_sell IS NOT NULL AND p.accountancy_code_sell != '' AND p.accountancy_code_sell NOT IN +} else { + $sql .= " p.accountancy_code_sell ='' OR p.accountancy_code_sell IS NULL "; + $sql .= " OR (p.accountancy_code_sell IS NOT NULL AND p.accountancy_code_sell != '' AND p.accountancy_code_sell NOT IN (SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))"; - } +} $sql .= ")"; - - - -//Add search filter like +// Add search filter like if (strlen(trim($search_ref))) { $sql .= " AND (p.ref like '" . $search_ref . "%')"; } @@ -242,7 +231,7 @@ if (strlen(trim($search_label))) { if (strlen(trim($search_desc))) { $sql .= " AND (p.description like '%" . $search_desc . "%')"; } -$sql.= $db->order($sortfield,$sortorder); +$sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($limit + 1, $offset); @@ -251,71 +240,65 @@ $result = $db->query($sql); if ($result) { $num_lines = $db->num_rows($result); $i = 0; - -/* + + /* * View */ print_barre_liste($langs->trans("ProductAccountingAccountSelect"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines); - -print '
'; -print ''; -print ''; - -print '
Charge
".$langs->trans('Charge')."
'.$langs->trans("Ref").''.$chid.'
'.$langs->trans("Type")."".$charge->type_libelle."
'; -print ''; -print ''; -print "\n"; -print ''; -print '\n"; -print ''; -print '\n"; - -print "
'.$langs->trans('OptionMode').''.$langs->trans('Description').'
'.$langs->trans('Accountancy_code_sell').''.nl2br($langs->trans('OptionModeProductSell')); -print "
'.$langs->trans('Accountancy_code_buy').''.nl2br($langs->trans('OptionModeProductBuy'))."
\n"; - -print '

'; - -print "
\n"; - - - - - - - print '' . $langs->trans("DescProductAccountingAccount") . ' '; - print_liste_field_titre($langs->trans("RowId"), $_SERVER["PHP_SELF"],"p.rowid","",$param,'',$sortfield,$sortorder); - print '  '; - - - - - + + print ''; + print ''; + print ''; + print ''; print ''; - print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"],"p.ref","",$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"],"p.label","",$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"],"l.description","",$param,'',$sortfield,$sortorder); - IF ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') { - print ''; - print ''; + print ''; + print "\n"; + print ''; + print '\n"; + print ''; + print '\n"; + + print "
' . $langs->trans("Accountancy_code_buy") . '' . $langs->trans("Accountancy_code_buy_suggest") . '' . $langs->trans('OptionMode') . '' . $langs->trans('Description') . '
' . $langs->trans('Accountancy_code_sell') . '' . nl2br($langs->trans('OptionModeProductSell')); + print "
' . $langs->trans('Accountancy_code_buy') . '' . nl2br($langs->trans('OptionModeProductBuy')) . "
\n"; + + print '
'; + + print "
\n"; + + if (! empty($msg)) { + print $msg; } - else { - print '' . $langs->trans("Accountancy_code_sell") . ''; - print '' . $langs->trans("Accountancy_code_sell_suggest") . ''; + + // print '' . $langs->trans("DescProductAccountingAccount") . ' '; + // print_liste_field_titre($langs->trans("RowId"), $_SERVER["PHP_SELF"], "p.rowid", "", $param, '', $sortfield, $sortorder); + print '  '; + + print ''; + print ''; + print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder); + if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { + print ''; + // print_liste_field_titre(''); + print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; - - print ''; - print ''; + print ''; print ''; @@ -327,30 +310,28 @@ print "
\n"; $compta_prodsell = $obj->accountancy_code_sell; - if ($obj->product_type == 0) { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodsell_id = $aarowid_prodsell; - } else { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodsell_id = $aarowid_servsell; - } - + if ($obj->product_type == 0) { + $compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell_id = $aarowid_prodsell; + } else { + $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell_id = $aarowid_servsell; + } $compta_prodbuy = $obj->accountancy_code_buy; - if ($obj->product_type == 0) { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodbuy_id = $aarowid_prodbuy; - } else { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodbuy_id = $aarowid_servbuy; - } - + if ($obj->product_type == 0) { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_prodbuy; + } else { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_servbuy; + } $product_static = new Product($db); print ""; - + print ""; print ""; // Ref produit as link @@ -363,56 +344,51 @@ print "
\n"; else print '- '; print ''; - print ''; -//TODO ADJUST DESCRIPTION SIZE -// print ''; - //TODO: we shoul set a user defined value to adjust user square / wide screen size + print ''; + // TODO ADJUST DESCRIPTION SIZE + // print ''; + // TODO: we shoul set a user defined value to adjust user square / wide screen size $trunclengh = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; print ''; - - //acountingaccount buy - IF ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') { - print ''; -//TODO: replace by select -// print ''; - //TODO: we shoul set a user defined value to adjust user square / wide screen size - //$trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; - print ''; - } - Else { - - //acountingaccount sel - print ''; -//TODO: replace by select - //TODO: we shoul set a user defined value to adjust user square / wide screen size - //$trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; - print ''; + // acountingaccount buy + + if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { + print ''; + // TODO: replace by select + // print ''; + // TODO: we shoul set a user defined value to adjust user square / wide screen size + // $trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; + print ''; + } else { + + // acountingaccount sel + print ''; + // TODO: replace by select + // TODO: we shoul set a user defined value to adjust user square / wide screen size + // $trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; + print ''; } - //Checkbox select + // Checkbox select print ''; - + print ''; + print ""; $i ++; } - print '
' . $langs->trans("Accountancy_code_buy") . ''; + print '' . $langs->trans("Accountancy_code_buy_suggest") . ''; + } else { + print '' . $langs->trans("Accountancy_code_sell") . ''; + print '' . $langs->trans("Accountancy_code_sell_suggest") . ''; } - print_liste_field_titre(''); - print '' . $langs->trans("Ventilate") . '
/'.'
' . $langs->trans("Ventilate") . '
/' . '
%% '; - print ''; + + print ' '; + print ''; print ' '; - print ''; + print ''; print '
'. dol_trunc($obj->label, 24) . '' . $obj->description . '' . dol_trunc($obj->label, 24) . '' . $obj->description . '' . nl2br(dol_trunc($obj->description, $trunclengh)) . '' . $obj->accountancy_code_buy . '' . $compta_prodbuy . ''; - print $form->select_account($compta_prodbuy_id, 'codeventil[]', 1); - print '' . $obj->accountancy_code_sell . ''; - print $form->select_account($compta_prodsell_id, 'codeventil[]', 1); - print '' . $obj->accountancy_code_buy . '' . $compta_prodbuy . ''; + print $form->select_account($compta_prodbuy_id, 'codeventil_'.$product_static->id, 1); + print '' . $obj->accountancy_code_sell . ''; + print $form->select_account($compta_prodsell_id, 'codeventil_'.$product_static->id, 1); + print ''; - print '
'; - print '
'; - print ''; - - + print ''; + print '
'; + print ''; $db->free($result); } else { dol_print_error($db); } - - llxFooter(); $db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 0c79820ea44..988eecfab84 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -65,8 +65,10 @@ class AccountingAccount extends CommonObject * @param string $account_number Account number * @return int <0 if KO, >0 if OK */ - function fetch($rowid = null, $account_number = null) + function fetch($rowid = null, $account_number = null, $limittocurentchart=0) { + global $conf; + if ($rowid || $account_number) { $sql = "SELECT rowid, datec, tms, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, fk_user_author, fk_user_modif, active"; $sql.= " FROM " . MAIN_DB_PREFIX . "accountingaccount WHERE"; @@ -75,7 +77,9 @@ class AccountingAccount extends CommonObject } elseif ($account_number) { $sql .= " account_number = '" . $account_number . "'"; } - + if (!empty($limittocurentchart)) { + $sql .=' AND fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS.')'; + } dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { @@ -101,7 +105,8 @@ class AccountingAccount extends CommonObject return 0; } } else { - dol_print_error($this->db); + $this->error="Error " . $this->db->lasterror(); + $this->errors[] = "Error " . $this->db->lasterror(); } } return -1; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index d3a4547c38b..6d82c324fd6 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -24,14 +24,13 @@ * \ingroup Accounting Expert * \brief Ventilation page from customers invoices */ - require '../../main.inc.php'; // Class -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; // Langs $langs->load("compta"); @@ -42,24 +41,25 @@ $langs->load("accountancy"); $action = GETPOST('action'); -//Select Box +// Select Box $codeventil = GETPOST('codeventil', 'array'); $mesCasesCochees = GETPOST('mesCasesCochees', 'array'); -//Search Getpost -$search_invoice = GETPOST('search_invoice','alpha'); -$search_ref = GETPOST('search_ref','alpha'); -$search_label = GETPOST('search_label','alpha'); -$search_desc = GETPOST('search_desc','alpha'); -$search_amount = GETPOST('search_amount','alpha'); -$search_account = GETPOST('search_account','alpha'); -$search_vat = GETPOST('search_vat','alpha'); +// Search Getpost +$search_invoice = GETPOST('search_invoice', 'alpha'); +$search_ref = GETPOST('search_ref', 'alpha'); +$search_label = GETPOST('search_label', 'alpha'); +$search_desc = GETPOST('search_desc', 'alpha'); +$search_amount = GETPOST('search_amount', 'alpha'); +$search_account = GETPOST('search_account', 'alpha'); +$search_vat = GETPOST('search_vat', 'alpha'); -//Getpost Order and column and limit page -$sortfield = GETPOST('sortfield','alpha'); -$sortorder = GETPOST('sortorder','alpha'); -$page = GETPOST('page'); -if ($page < 0) $page = 0; +// Getpost Order and column and limit page +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); +$page = GETPOST('page','int'); +if ($page < 0) + $page = 0; if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { $limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION; @@ -70,7 +70,8 @@ if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { } $offset = $limit * $page; -if (! $sortfield) $sortfield="f.datef, f.facnumber, l.rowid"; +if (! $sortfield) + $sortfield = "f.datef, f.facnumber, l.rowid"; if (! $sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { @@ -91,23 +92,23 @@ $aarowid_s = $accounting->fetch('', ACCOUNTING_SERVICE_SOLD_ACCOUNT); $aarowid_p = $accounting->fetch('', ACCOUNTING_PRODUCT_SOLD_ACCOUNT); // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) -{ - $search_ref=''; - $search_invoice=''; - $search_label=''; - $search_desc=''; - $search_amount=''; - $search_account=''; - $search_vat=''; +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) { + $search_ref = ''; + $search_invoice = ''; + $search_label = ''; + $search_desc = ''; + $search_amount = ''; + $search_account = ''; + $search_vat = ''; } + /* * View */ llxHeader('', $langs->trans("Ventilation")); -print '