diff --git a/ChangeLog b/ChangeLog index 57673bac498..d6e412ec06e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,14 @@ English Dolibarr ChangeLog ***** ChangeLog for 3.7 compared to 3.6.* ***** For users: +- New: Add permissions to read all trips and expenses. +- New: Can filter on date into tab "Referring object" of a project. +- New: Module notification has been enhanced: + EMail use now language of target contact. + Can also define a fixed email for notifications. +- New: Feature to link manually an order to an invoice does not disappear once + link has been done. +- New: Can set a color on user card (visible into agenda view). - New: extrafields for projects and tasks are exported to ODT documents. - New: Add number of active notification into tab title (like we do for notes and documents) - New: Can add product into category from category card. @@ -62,9 +70,14 @@ For users: - New: Add option MAIN_GENERATE_INVOICES_WITH_PICTURE to show picture onto PDF like MAIN_GENERATE_PROPOSALS_WITH_PICTURE dir for proposals. - New: Add more search field in list of cheque deposits. -- New: Add feature to order to invoice on supplier part +- New: Add feature to order to invoice on supplier part. +- New : Use of MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR to use disk cache for big excel export. +- New: Direct invoice creation from predefined invoice. +- New: Add dunning into accountancy report. +- New: Add favorite button into country dictionary to put value on top select list - Upgrade phpexcel lib to 1.7.8 - New : Use of MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR to use disk cache for big excel export +- New : Option on extrafields to have them always editable regardless of the document status - Fix: [ bug #1487 ] PAYMENT_DELETE trigger does not intercept trigger action - Fix: [ bug #1470, #1472, #1473] User trigger problem - Fix: [ bug #1489, #1491 ] Intervention trigger problem @@ -82,8 +95,7 @@ For users: - Fix: [ bug #1506, #1507 ] ECM trigger error problem - Fix: [ bug #1469 ] Triggers CONTACT_MODIFY and CONTACT_DELETE duplicates error message - Fix: [ bug #1537 ] Difference between societe.nom and adherent.societe. -- New: Direct invoice creation from predefined invoice -- New: Add dunning into accountancy report + For users, new experimental module (need to set feature level of instance to experimental to see them): - New: Module Accounting Expert to manage accountancy Special Thanks to developpers : @@ -120,6 +132,8 @@ For developers: - New: renamed table llx_c_pays to llx_c_country & libelle field to label. - New: Added hook "formConfirm" and "doActions" for fichinter card - New: Can search list of thirdparties from web service on part of name. +- New: Function getCurrencyAmount is marked as deprecated. Use function price to output a price + including currency symbol. - Qual: Renamed table llx_c_civilite into llx_c_civility, field civilite into label in the same table, and field civilite into civility in other table. @@ -131,6 +145,8 @@ For developers: WARNING: Following changes may create regression for some external modules, but was necessary to make Dolibarr better: +- If you can't see trips and expenses records, check that you have the new permission "read all + trips and expenses". - Deprecated module "oscommerce" were removed. - Changed the way parameters are provided to scripts sync_xxx_ldap2dolibarr.php - Some field into database were renamed from "libelle" to "label". @@ -146,6 +162,10 @@ Dolibarr better: - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice - Fix: bug 1588 : relative discount - Fix: label of input method not tranlated. +- Fix: box of customer and propsects were not correctly disabled. +- Fix: right and error management #1961 +- Fix: Fix Error when trying to clone an Order #1943 +- Fix: [ bug #1618 ] PHP Error thrown when saving a barcode ***** ChangeLog for 3.6.1 compared to 3.6.* ***** For users: diff --git a/build/debian/control b/build/debian/control index fc0cee30319..164b919e066 100755 --- a/build/debian/control +++ b/build/debian/control @@ -3,7 +3,7 @@ Section: web Priority: optional Maintainer: Laurent Destailleur (eldy) # Uploaders: Laurent Destailleur (eldy) # Only if differs from Maintainer -Standards-Version: 3.9.4 +Standards-Version: 3.9.6 Homepage: http://www.dolibarr.org Build-Depends: debhelper (>= 9), po-debconf # This package need at least debian 7 or ubuntu 13.04 or any distribution based on this version @@ -16,7 +16,8 @@ Depends: libapache2-mod-php5 | libapache2-mod-php5filter | php5-cgi | php5-fpm | php5-mysql | php5-mysqli, php5-curl, php5-gd, php5-ldap, php5-geoip, # Required PHP libraries php-pear, php-mail-mime, -# php-tcpdf, libfpdi-php, libfpdf-tpl-php, php-fpdf, +# php-tcpdf, libfpdi-php, +# libfpdf-tpl-php, php-fpdf, # libphp-adodb, # libnusoap-php, # libphp-pclzip, @@ -26,9 +27,10 @@ Depends: libapache2-mod-php5 | libapache2-mod-php5filter | php5-cgi | php5-fpm | # fonts-dejavu-core | ttf-dejavu-core, xdg-utils, mysql-server, + mysql-client, ${misc:Depends}, ${perl:Depends} -Recommends: mysql-client, apache2 | lighttpd | httpd +Recommends: apache2 | lighttpd | httpd Suggests: www-browser Description: Web based software to manage a company or foundation Dolibarr ERP & CRM is an easy to use open source/free software for small diff --git a/build/debian/copyright b/build/debian/copyright index 73109152034..080965c31a3 100644 --- a/build/debian/copyright +++ b/build/debian/copyright @@ -1,7 +1,7 @@ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: Dolibarr Upstream-Contact: Laurent Destailleur -Source: http://sourceforge.net/projects/dolibarr/files/ +Source: http://www.dolibarr.org/files/stable/standard/ Files: * Copyright: 2002-2009, Rodolphe Quiedeville diff --git a/dev/fixperms.sh b/dev/fixperms.sh index 731e45cf703..5844e8b2916 100755 --- a/dev/fixperms.sh +++ b/dev/fixperms.sh @@ -25,4 +25,6 @@ then find ./htdocs -type f -iname "*.php" -exec chmod a-x {} \; chmod a+x ./scripts/*/*.php chmod a+x ./scripts/*/*.sh + chmod g-w ./scripts/*/*.php + chmod g-w ./scripts/*/*.sh fi diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 1ec3d71c664..62e54c17948 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -159,7 +159,7 @@ if ($conf->use_javascript_ajax) print '
'; print ''; print ''; - print ''; print ''; print ''."\n"; -// Show each trigger +// Show each trigger (list is in c_action_trigger) if (! empty($triggers)) { foreach ($triggers as $trigger) diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index c88d7717084..c12e913e9c1 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -65,8 +65,9 @@ if ($action == 'add') $sql.= " FROM ".MAIN_DB_PREFIX."user_param"; $sql.= " WHERE param = 'MAIN_BOXES_".$db->escape(GETPOST("pos","alpha"))."' AND value = '1'"; $sql.= " AND entity = ".$conf->entity; - $resql = $db->query($sql); + dol_syslog("boxes.php search fk_user to activate box for", LOG_DEBUG); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -227,8 +228,8 @@ $actives = array(); $sql = "SELECT b.rowid, b.box_id, b.position, b.box_order,"; $sql.= " bd.rowid as boxid"; $sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as bd"; -$sql.= " WHERE b.entity = ".$conf->entity; -$sql.= " AND b.box_id = bd.rowid"; +$sql.= " WHERE b.box_id = bd.rowid"; +$sql.= " AND b.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; $sql.= " AND b.fk_user=0"; $sql.= " ORDER by b.position, b.box_order"; @@ -237,6 +238,8 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); + + // Check record to know if we must recalculate sort order $i = 0; $decalage=0; $var=false; @@ -310,7 +313,6 @@ if ($resql) $db->free($resql); } - // Available boxes to activate $boxtoadd=InfoBox::listBoxes($db,'available',-1,null,$actives); @@ -372,7 +374,7 @@ print '
'.$langs->trans("Statistics").'
'; + print '
'; $SommeA=0; $SommeB=0; diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index c7cb4258935..5ad9673a16f 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -154,7 +154,7 @@ print '
'.$langs->trans("ActionsEvents").''.$langs->trans("All").'/'.$langs->trans("None").''; print '
'; // Activated boxes $boxactivated=InfoBox::listBoxes($db,'activated',-1,null); - +//var_dump($boxactivated); print "
\n\n"; print_titre($langs->trans("BoxesActivated")); diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index c774faf5caa..96dff7755af 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -117,7 +117,7 @@ if ( ($action == 'update' && empty($_POST["cancel"])) } else dol_syslog($imgThumbMini); } - else dol_syslog($langs->trans("ErrorImageFormatNotSupported"),LOG_WARNING); + else dol_syslog("ErrorImageFormatNotSupported",LOG_WARNING); } else if (preg_match('/^ErrorFileIsInfectedWithAVirus/',$result)) { @@ -133,9 +133,10 @@ if ( ($action == 'update' && empty($_POST["cancel"])) } } else - { + { $error++; - setEventMessage($langs->trans("ErrorOnlyPngJpgSupported"),'errors'); + $langs->load("errors"); + setEventMessage($langs->trans("ErrorBadImageFormat"),'errors'); } } } @@ -158,7 +159,7 @@ if ( ($action == 'update' && empty($_POST["cancel"])) // Local taxes dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION",$_POST["optionlocaltax1"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION",$_POST["optionlocaltax2"],'chaine',0,'',$conf->entity); - + if($_POST["optionlocaltax1"]=="localtax1on") { if(!isset($_REQUEST['lt1'])) @@ -226,13 +227,15 @@ if ($action == 'addthumb') else { $error++; - setEventMessage($langs->trans("ErrorImageFormatNotSupported"),'errors'); - dol_syslog($langs->transnoentities("ErrorImageFormatNotSupported"),LOG_WARNING); + $langs->load("errors"); + setEventMessage($langs->trans("ErrorBadImageFormat"),'errors'); + dol_syslog($langs->transnoentities("ErrorBadImageFormat"),LOG_WARNING); } } else { $error++; + $langs->load("errors"); setEventMessage($langs->trans("ErrorFileDoesNotExists",$_GET["file"]),'errors'); dol_syslog($langs->transnoentities("ErrorFileDoesNotExists",$_GET["file"]),LOG_WARNING); } @@ -601,7 +604,7 @@ if ($action == 'edit' || $action == 'updateedit') $formcompany->select_localtax(1,$conf->global->MAIN_INFO_VALUE_LOCALTAX1, "lt1"); } print ''; - + print ''.$langs->trans("CalcLocaltax").': '; $opcions=array($langs->transcountry("CalcLocaltax1",$mysoc->country_code),$langs->transcountry("CalcLocaltax2",$mysoc->country_code),$langs->transcountry("CalcLocaltax3",$mysoc->country_code)); print $form->selectarray("clt1", $opcions, $conf->global->MAIN_INFO_LOCALTAX_CALC1); @@ -1003,7 +1006,7 @@ else if($conf->global->MAIN_INFO_VALUE_LOCALTAX1!=0) { print ''.$langs->trans("LTRate").': '. $conf->global->MAIN_INFO_VALUE_LOCALTAX1 .''; - } + } print ''.$langs->trans("CalcLocaltax").': '; if($conf->global->MAIN_INFO_LOCALTAX_CALC1==0) { @@ -1016,7 +1019,7 @@ else else if($conf->global->MAIN_INFO_LOCALTAX_CALC1==2){ print $langs->transcountry("CalcLocaltax3",$mysoc->country_code); } - + print ''; print ""; print "\n"; @@ -1054,7 +1057,7 @@ else if($conf->global->MAIN_INFO_VALUE_LOCALTAX2!=0) { print ''.$langs->trans("LTRate").': '. $conf->global->MAIN_INFO_VALUE_LOCALTAX2 .''; - } + } print ''.$langs->trans("CalcLocaltax").': '; if($conf->global->MAIN_INFO_LOCALTAX_CALC2==0) { @@ -1068,7 +1071,7 @@ else { print $langs->transcountry("CalcLocaltax3",$mysoc->country_code); } - + print ''; print ""; print "\n"; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 7a84470b320..d81f306be9e 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -131,7 +131,7 @@ $tabsql=array(); $tabsql[1] = "SELECT f.rowid as rowid, f.code, f.libelle, c.code as country_code, c.label as country, f.active FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_country as c WHERE f.fk_pays=c.rowid"; $tabsql[2] = "SELECT d.rowid as rowid, d.code_departement as code, d.nom as libelle, d.fk_region as region_id, r.nom as region, c.code as country_code, c.label as country, d.active FROM ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid and r.active=1 and c.active=1"; $tabsql[3] = "SELECT r.rowid as rowid, r.code_region as code, r.nom as libelle, r.fk_pays as country_id, c.code as country_code, c.label as country, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE r.fk_pays=c.rowid and c.active=1"; -$tabsql[4] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_country"; +$tabsql[4] = "SELECT rowid as rowid, code, label, active, favorite FROM ".MAIN_DB_PREFIX."c_country"; $tabsql[5] = "SELECT c.rowid as rowid, c.code as code, c.label, c.active FROM ".MAIN_DB_PREFIX."c_civility AS c"; $tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.type, a.active, a.module, a.color, a.position FROM ".MAIN_DB_PREFIX."c_actioncomm AS a"; $tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, a.deductible, c.code as country_code, c.label as country, a.fk_pays as country_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_pays=c.rowid and c.active=1"; @@ -387,13 +387,14 @@ if ($id == 11) $langs->load("bills"); $langs->load("interventions"); $elementList = array( - 'proposal' => $langs->trans('Proposal'), - 'order' => $langs->trans('Order'), - 'invoice' => $langs->trans('Bill'), + '' => '', +// 'proposal' => $langs->trans('Proposal'), +// 'order' => $langs->trans('Order'), +// 'invoice' => $langs->trans('Bill'), 'invoice_supplier' => $langs->trans('SupplierBill'), 'order_supplier' => $langs->trans('SupplierOrder'), - 'intervention' => $langs->trans('InterventionCard'), - 'contract' => $langs->trans('Contract'), +// 'intervention' => $langs->trans('InterventionCard'), +// 'contract' => $langs->trans('Contract'), 'project' => $langs->trans('Project'), 'project_task' => $langs->trans('Task'), 'agenda' => $langs->trans('Agenda'), @@ -402,10 +403,11 @@ if ($id == 11) 'propal' => $langs->trans('Proposal'), 'commande' => $langs->trans('Order'), 'facture' => $langs->trans('Bill'), - 'facture_fourn' => $langs->trans('SupplierBill'), +// 'facture_fourn' => $langs->trans('SupplierBill'), 'fichinter' => $langs->trans('InterventionCard') ); if (! empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) $elementList["societe"] = $langs->trans('ThirdParty'); + asort($elementList); $sourceList = array( 'internal' => $langs->trans('Internal'), 'external' => $langs->trans('External') @@ -677,6 +679,46 @@ if ($action == $acts[1]) } } +// favorite +if ($action == 'activate_favorite') +{ + if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } + else { $rowidcol="rowid"; } + + if ($rowid) { + $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$rowid."'"; + } + elseif ($_GET["code"]) { + $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".$_GET["code"]."'"; + } + + $result = $db->query($sql); + if (!$result) + { + dol_print_error($db); + } +} + +// disable favorite +if ($action == 'disable_favorite') +{ + if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } + else { $rowidcol="rowid"; } + + if ($rowid) { + $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$rowid."'"; + } + elseif ($_GET["code"]) { + $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".$_GET["code"]."'"; + } + + $result = $db->query($sql); + if (!$result) + { + dol_print_error($db); + } +} + /* * View @@ -709,6 +751,7 @@ if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$_GET["code"].'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1); } +//var_dump($elementList); /* * Show a dictionary @@ -813,7 +856,7 @@ if ($id) } if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; } - print ''; + print ''; print ''; print ' '; print ''; @@ -928,8 +971,11 @@ if ($id) print getTitleFieldOfList($valuetoshow,0,$_SERVER["PHP_SELF"],($sortable?$fieldlist[$field]:''),($page?'page='.$page.'&':'').'&id='.$id,"","align=".$align,$sortfield,$sortorder); } } - print getTitleFieldOfList($langs->trans("Status"),0,$_SERVER["PHP_SELF"],"active",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder); - print ' '; + // Favorite - Only activated on country dictionary + if ($id == 4) print getTitleFieldOfList($langs->trans("Favorite"),0,$_SERVER["PHP_SELF"],"favorite",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder); + + print getTitleFieldOfList($langs->trans("Status"),0,$_SERVER["PHP_SELF"],"active",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder); + print ' '; print ''; // Lines with values @@ -1142,6 +1188,16 @@ if ($id) $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?$obj->code:'').'&id='.$id.'&'; + // Favorite + // Only activated on country dictionary + if ($id == 4) + { + print ''; + if ($iserasable) print ''.$actl[$obj->favorite].''; + else print $langs->trans("AlwaysActive"); + print ''; + } + // Active print ''; if ($isdisable) print ''.$actl[$obj->active].''; diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index ca68c54c805..14aeba65c29 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -32,6 +32,7 @@ $langs->load("other"); $langs->load("orders"); $langs->load("propal"); $langs->load("bills"); +$langs->load("errors"); // Security check if (!$user->admin) @@ -39,19 +40,32 @@ if (!$user->admin) $action = GETPOST("action"); + /* * Actions */ if ($action == 'setvalue' && $user->admin) { - $result=dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM",$_POST["email_from"],'chaine',0,'',$conf->entity); - if ($result >= 0) + $result=dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM", $_POST["email_from"], 'chaine', 0, '', $conf->entity); + if ($result < 0) $error++; + + if (! $error) + { + foreach($_POST as $key => $val) + { + if (! preg_match('/^NOTIFICATION_FIXEDEMAIL_/',$key)) continue; + //print $key.' - '.$val.'
'; + $result=dolibarr_set_const($db, $key, $val, 'chaine', 0, '', $conf->entity); + } + } + + if (! $error) { setEventMessage($langs->trans("SetupSaved")); } else - { + { setEventMessage($langs->trans("Error"),'errors'); } } @@ -67,7 +81,7 @@ llxHeader(); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("NotificationSetup"),$linkback,'setup'); -print $langs->trans("NotificationsDesc").'

'; +print $langs->trans("NotificationsDesc").'

'; print '
'; print ''; @@ -83,19 +97,13 @@ print "\n"; $var=!$var; print ''; print $langs->trans("NotificationEMailFrom").''; -print ''; -if (! empty($conf->global->NOTIFICATION_EMAIL_FROM) && ! isValidEmail($conf->global->NOTIFICATION_EMAIL_FROM)) print ' '.img_warning($langs->trans("BadEMail")); +print ''; +if (! empty($conf->global->NOTIFICATION_EMAIL_FROM) && ! isValidEmail($conf->global->NOTIFICATION_EMAIL_FROM)) print ' '.img_warning($langs->trans("ErrorBadEMail")); print ''; print ''; print '
'; -print '
'; - -print '
'; -print '
'; - - print_fiche_titre($langs->trans("ListOfAvailableNotifications"),'',''); print ''; @@ -103,6 +111,7 @@ print ''; print ''; print ''; print ''; +print ''; print "\n"; // Load array of available notifications @@ -123,10 +132,21 @@ foreach($listofnotifiedevents as $notifiedevent) print ''; print ''; print ''; + $param='NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code']; + print ''; print ''; } print '
'.$langs->trans("Module").''.$langs->trans("Code").''.$langs->trans("Label").''.$langs->trans("FixedEmailTarget").'
'.$elementLabel.''.$notifiedevent['code'].''.$label.''; + if (! empty($conf->global->$param) && ! isValidEmail($conf->global->$param)) print ' '.img_warning($langs->trans("ErrorBadEMail")); + print '
'; -$db->close(); +print '
'; + +print '
'; + +print ''; + llxFooter(); + +$db->close(); diff --git a/htdocs/cashdesk/affContenu.php b/htdocs/cashdesk/affContenu.php index 543006baedf..9940e70cc93 100644 --- a/htdocs/cashdesk/affContenu.php +++ b/htdocs/cashdesk/affContenu.php @@ -43,15 +43,9 @@ else $obj_facturation = new Facturation(); } -print '
'; -require ('tpl/liste_articles.tpl.php'); - -$obj_facturation->prixTotalHt($lst_total_ht); -$obj_facturation->prixTotalTtc($lst_total_ttc); - -print '
'; +// Left area with selected articles (shopping cart) print '
'; $page=GETPOST('menu','alpha'); @@ -75,4 +69,18 @@ else print '
'; + + + + +// Right area with selected articles (shopping cart) +print '
'; + +require ('tpl/liste_articles.tpl.php'); +$obj_facturation->prixTotalHt($lst_total_ht); +$obj_facturation->prixTotalTtc($lst_total_ttc); + +print '
'; + + $_SESSION['serObjFacturation'] = serialize($obj_facturation); diff --git a/htdocs/cashdesk/css/style.css b/htdocs/cashdesk/css/style.css index c71dd9b78bc..0972527a73b 100644 --- a/htdocs/cashdesk/css/style.css +++ b/htdocs/cashdesk/css/style.css @@ -30,23 +30,24 @@ p { .conteneur { background: #fff; text-align: left; - width: 770px; + max-width: 770px; margin: 10px auto; + border: 2px solid #000; } .conteneur_img_gauche { - background: url("../img/bg_conteneur_gauche.png") top left repeat-y; + /* background: url("../img/bg_conteneur_gauche.png") top left repeat-y; */ } .conteneur_img_droite { - background: url("../img/bg_conteneur_droite.png") top right repeat-y; + /* background: url("../img/bg_conteneur_droite.png") top right repeat-y; */ } /* ------------------- Header ------------------- */ .entete { height: 15px; margin: 0; - background: url('../img/bg_entete.png') no-repeat left top; + /* background: url('../img/bg_entete.png') no-repeat left top; */ } .entete span { @@ -57,7 +58,6 @@ p { .menu_principal { margin: 0 20px 20px 15px; font-size: 14px; - width: 735px; height: 84px; background: #CCCCCC; background-image: linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(40,40,40,.3) 100%); @@ -80,20 +80,21 @@ p { .menu li { float: left; + padding-right: 10px; } .menu_choix1,.menu_choix2 { font-size: 1.4em; text-align: left; - width: 180px; } .menu_choix1 a,.menu_choix2 a { display: block; color: #fff; text-decoration: none; - width: 100px; + padding-top: 18px; padding-left: 54px; + font-size: 14px; height: 48px; background: url('../img/new.png') top left no-repeat; } @@ -115,7 +116,6 @@ p { text-align: right; font-style: italic; font-weight: normal; - width: 340px; display: block; color: #333; text-decoration: none; @@ -126,11 +126,13 @@ p { font-weight: normal; text-decoration: none; } - +li.menu_choix0 { + float: right; +} /* ------------------- R�capitulatif des articles ------------------- */ .liste_articles { - width: 215px; + min-width: 215px; float: right; margin-top: 8px; margin-right: 20px; @@ -219,7 +221,7 @@ p.titre { float: left; margin: 0 15px; padding: 0; - width: 495px; + max-width: 500px; } .titre1 { @@ -237,7 +239,6 @@ p.titre { .cadre_facturation { border: 2px solid #ddd; margin-bottom: 15px; - padding: 10px 10px; } .principal p { @@ -374,7 +375,7 @@ p.titre { .pied { clear: both; height: 15px; - background: url('../img/bg_pied.png') no-repeat bottom left; + /* background: url('../img/bg_pied.png') no-repeat bottom left; */ } /* ------------------- Param�tres communs (messages d'erreur, informations, etc...) ------------------- */ diff --git a/htdocs/cashdesk/facturation.php b/htdocs/cashdesk/facturation.php index a168fba5b7b..dd722805eb6 100644 --- a/htdocs/cashdesk/facturation.php +++ b/htdocs/cashdesk/facturation.php @@ -158,9 +158,9 @@ $sql = "SELECT t.rowid, t.taux"; $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t"; $sql.= ", ".MAIN_DB_PREFIX."c_country as c"; $sql.= " WHERE t.fk_pays = c.rowid"; -$sql.= " AND c.active = 1"; +$sql.= " AND t.active = 1"; $sql.= " AND c.code = '".$mysoc->country_code."'"; -//print $request; +//print $sql; $resql = $db->query($sql); if ($resql) diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php index 1a009fcead0..f2258c6473e 100644 --- a/htdocs/cashdesk/tpl/facturation1.tpl.php +++ b/htdocs/cashdesk/tpl/facturation1.tpl.php @@ -111,8 +111,9 @@ $langs->load("cashdesk"); - - + + + currency; ?> @@ -122,9 +123,9 @@ $langs->load("cashdesk"); currency; ?> + diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php index c74eefdc430..e9e11b656b9 100644 --- a/htdocs/categories/categorie.php +++ b/htdocs/categories/categorie.php @@ -621,8 +621,17 @@ function formCategory($db,$object,$typeid,$socid=0,$showclassifyform=1) if ($typeid == 3) $title = $langs->trans("MembersCategoriesShort"); if ($typeid == 4) $title = $langs->trans("ContactCategoriesShort"); + $linktocreate=''; + if ($showclassifyform && $user->rights->categorie->creer) + { + $linktocreate='id.'&type='.$typeid).'">'; + $linktocreate.=$langs->trans("CreateCat").' '; + $linktocreate.=img_picto($langs->trans("Create"),'filenew'); + $linktocreate.=""; + } + print '
'; - print_fiche_titre($title,'',''); + print_fiche_titre($title,$linktocreate,''); // Form to add record into a category if ($showclassifyform) @@ -634,19 +643,10 @@ function formCategory($db,$object,$typeid,$socid=0,$showclassifyform=1) print ''; print ''; print ''; - if ($user->rights->categorie->creer) - { - print ''; - } + print ''; + print ''; print ''; print '
'; - print $langs->trans("ClassifyInCategory").'  '; + print ''.$langs->trans("ClassifyInCategory").'  '; print $form->select_all_categories($typeid,'auto'); - print ''; - print ''; - print 'id.'&type='.$typeid).'">'; - print $langs->trans("CreateCat").' '; - print img_picto($langs->trans("Create"),'filenew'); - print ""; - print '
'; print ''; @@ -679,10 +679,7 @@ function formCategory($db,$object,$typeid,$socid=0,$showclassifyform=1) print ""; // Categorie - print ""; - //$c->id=; - //print $c->getNomUrl(1); - print img_object('','category').' '.$way.""; + print "".img_object('','category').' '.$way.""; // Link to delete from category print ''; diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index eceeb2890bc..76a19c91d7d 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -171,7 +171,7 @@ $nbofentries=(count($data) - 1); if ($nbofentries > 0) { - print ''; + print ''; tree_recur($data,$data[0],0); print ''; } diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index df0a359dd56..b31f686c9fe 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -66,7 +66,7 @@ class ActionComm extends CommonObject var $note; // Description var $userassigned = array(); // Array of user ids - var $userownerid; // Id of user owner + var $userownerid; // Id of user owner var $userdoneid; // Id of user done var $usertodo; // Object user of owner // deprecated var $userdone; // Object user that did action // deprecated @@ -853,8 +853,8 @@ class ActionComm extends CommonObject } /** - * Renvoie nom clicable (avec eventuellement le picto) - * Utilise $this->id, $this->code et $this->label + * Return URL of event + * Use $this->id, $this->type_code, $this->label and $this->type_label * * @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul * @param int $maxlength Nombre de caracteres max dans libelle @@ -865,39 +865,34 @@ class ActionComm extends CommonObject */ function getNomUrl($withpicto=0,$maxlength=0,$classname='',$option='',$overwritepicto='') { - global $langs; + global $conf,$langs; $result=''; if ($option=='birthday') $lien = ''; else $lien = ''; $lienfin=''; $label=$this->label; - if (empty($label)) $label=$this->libelle; // Fro backward compatibility - //print 'rrr'.$this->libelle; + if (empty($label)) $label=$this->libelle; // For backward compatibility + //print 'rrr'.$this->libelle.'-'.$withpicto; if ($withpicto == 2) { $libelle=$label; - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle=$langs->trans("Action".$this->type_code); + if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle=$langs->transnoentities("Action".$this->type_code); $libelleshort=''; } - else if (empty($this->libelle)) - { - $libelle=$label; - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle=$langs->trans("Action".$this->type_code); - $libelleshort=dol_trunc($label, $maxlength); - } else { - $libelle=$label; - $libelleshort=dol_trunc($label,$maxlength); + $libelle=(empty($this->libelle)?$label:$this->libelle.(($label && $label != $this->libelle)?' '.$label:'')); + if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($libelle)) $libelle=($langs->transnoentities("Action".$this->type_code) != "Action".$this->type_code)?$langs->transnoentities("Action".$this->type_code):$this->type_label; + $libelleshort=dol_trunc($libelle,$maxlength); } if ($withpicto) { - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) + if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) // Add code into () { - $libelle.=(($this->type_code && $libelle!=$langs->trans("Action".$this->type_code) && $langs->trans("Action".$this->type_code)!="Action".$this->type_code)?' ('.$langs->trans("Action".$this->type_code).')':''); + $libelle.=(($this->type_code && $libelle!=$langs->transnoentities("Action".$this->type_code) && $langs->transnoentities("Action".$this->type_code)!="Action".$this->type_code)?' ('.$langs->transnoentities("Action".$this->type_code).')':''); } $result.=$lien.img_object($langs->trans("ShowAction").': '.$libelle,($overwritepicto?$overwritepicto:'action')).$lienfin; } diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 2db6936e1d3..4630d486ebf 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -414,7 +414,7 @@ $sql.= ' a.percent,'; $sql.= ' a.fk_user_author,a.fk_user_action,a.fk_user_done,'; $sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,'; $sql.= ' a.fk_soc, a.fk_contact,'; -$sql.= ' ca.code'; +$sql.= ' ca.code as type_code, ca.libelle as type_label'; $sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; if ($usergroup > 0) $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ugu"; @@ -483,12 +483,20 @@ if ($resql) { $obj = $db->fetch_object($resql); + // Discard auto action if option is on + if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') + { + $i++; + continue; + } + // Create a new object action $event=new ActionComm($db); $event->id=$obj->id; $event->datep=$db->jdate($obj->datep); // datep and datef are GMT date $event->datef=$db->jdate($obj->datep2); - $event->type_code=$obj->code; + $event->type_code=$obj->type_code; + $event->type_label=$obj->type_label; $event->libelle=$obj->label; $event->percentage=$obj->percent; $event->authorid=$obj->fk_user_author; // user id of creator @@ -876,6 +884,7 @@ if (count($listofextcals)) $maxnbofchar=18; $cachethirdparties=array(); $cachecontacts=array(); +$cacheusers=array(); // Define theme_datacolor array $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/graph-color.php"; @@ -1028,7 +1037,7 @@ else // View by day $today=0; $todayarray=dol_getdate($now,'fast'); if ($todayarray['mday']==$day && $todayarray['mon']==$month && $todayarray['year']==$year) $today=1; - if ($today) $style='cal_today'; + //if ($today) $style='cal_today'; $timestamp=dol_mktime(12,0,0,$month,$day,$year); $arraytimestamp=dol_getdate($timestamp); @@ -1074,7 +1083,7 @@ $db->close(); * @param int $year Year * @param int $monthshown Current month shown in calendar view * @param string $style Style to use for this day - * @param array $eventarray Array of events + * @param array $eventarray Array of events * @param int $maxprint Nb of actions to show each day on month view (0 means no limit) * @param int $maxnbofchar Nb of characters to show for event line * @param string $newparam Parameters on current URL @@ -1087,7 +1096,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa global $user, $conf, $langs; global $action, $filter, $filtera, $filtert, $filterd, $status, $actioncode; // Filters used into search form global $theme_datacolor; - global $cachethirdparties, $cachecontacts, $colorindexused; + global $cachethirdparties, $cachecontacts, $cacheusers, $colorindexused; print '
'."\n"; @@ -1146,11 +1155,17 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa if (in_array($user->id, $keysofuserassigned)) { $nummytasks++; $cssclass='family_mytasks'; - // TODO Set a color using user color - // Must defined rule to choose color of who to use. - // event->ownerid will still contains user id of owner - // event->userassigned will be an array in future. - // $color=$user->color; + + if (empty($cacheusers[$event->userownerid])) + { + $newuser=new User($db); + $newuser->fetch($event->userownerid); + $cacheusers[$event->userownerid]=$newuser; + } + //var_dump($cacheusers[$event->userownerid]->color); + + // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) + if (! empty($cacheusers[$event->userownerid]->color)) $color=$cacheusers[$event->userownerid]->color; } else if ($event->type_code == 'ICALEVENT') { @@ -1171,6 +1186,17 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa else { $numother++; $cssclass='family_other'; + + if (empty($cacheusers[$event->userownerid])) + { + $newuser=new User($db); + $newuser->fetch($event->userownerid); + $cacheusers[$event->userownerid]=$newuser; + } + //var_dump($cacheusers[$event->userownerid]->color); + + // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) + if (! empty($cacheusers[$event->userownerid]->color)) $color=$cacheusers[$event->userownerid]->color; } if ($color == -1) // Color was not forced. Set color according to color index. { @@ -1291,7 +1317,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa print "
\n"; } else - { + { if ($showinfo) { print $langs->trans("EventOnFullDay")."
\n"; diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index fbd63e4006b..c330540cb03 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -44,6 +44,8 @@ $status=GETPOST("status",'alpha'); $type=GETPOST('type'); $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_USE_EVENT_TYPE)?'AC_OTH':'')); $dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth'), GETPOST('dateselectday'), GETPOST('dateselectyear')); +$datestart=dol_mktime(0, 0, 0, GETPOST('datestartmonth'), GETPOST('datestartday'), GETPOST('datestartyear')); +$dateend=dol_mktime(0, 0, 0, GETPOST('dateendmonth'), GETPOST('dateendday'), GETPOST('dateendyear')); if ($actioncode == '') $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE); if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS); @@ -123,13 +125,19 @@ if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) * View */ +$form=new Form($db); + +$nav=''; +$nav.='  
'; +$nav.=$form->select_date($dateselect, 'dateselect', 0, 0, 1, '', 1, 0, 1); +$nav.=' '; +$nav.='
'; + $now=dol_now(); $help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; llxHeader('',$langs->trans("Agenda"),$help_url); -$form=new Form($db); - // Define list of all external calendars $listofextcals=array(); @@ -148,7 +156,7 @@ if ($type) $param.="&type=".$type; $sql = "SELECT s.nom as societe, s.rowid as socid, s.client,"; $sql.= " a.id, a.datep as dp, a.datep2 as dp2,"; $sql.= " a.fk_contact, a.note, a.label, a.percent as percent,"; -$sql.= " c.code as acode, c.libelle,"; +$sql.= " c.code as type_code, c.libelle as type_label,"; $sql.= " ua.login as loginauthor, ua.rowid as useridauthor,"; $sql.= " ut.login as logintodo, ut.rowid as useridtodo,"; //$sql.= " ud.login as logindone, ud.rowid as useriddone,"; @@ -188,8 +196,9 @@ if ($filtera > 0 || $filtert > 0 || $filterd > 0 || $usergroup > 0) if ($usergroup > 0) $sql.= ($filtera>0||$filtert>0||$filterd>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup; $sql.= ")"; } -//if ($dateselect > 0) $sql.= " AND a.datep BETWEEN '".$db->idate($dateselect)."' AND '".$db->idate($dateselect+3600*24-1).'"'; -if ($dateselect > 0) $sql.= " AND a.datep BETWEEN '".$db->idate($dateselect)."' AND '".$db->idate($dateselect+3600*24-1)."'"; +if ($dateselect > 0) $sql.= " AND a.datep2 >= '".$db->idate($dateselect)."' AND a.datep <= '".$db->idate($dateselect+3600*24-1)."'"; +if ($datestart > 0) $sql.= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart+3600*24-1)."'"; +if ($dateend > 0) $sql.= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend+3600*24-1)."'"; $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit + 1, $offset); //print $sql; @@ -236,7 +245,7 @@ if ($resql) } */ - print_barre_liste($newtitle, $page, $_SERVER["PHP_SELF"], $param,$sortfield,$sortorder,$link,$num,0,''); + print_barre_liste($newtitle, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $link, $num, 0, '', 0, $nav); //print '
'; print '
'."\n"; @@ -250,7 +259,7 @@ if ($resql) print_liste_field_titre($langs->trans("DateEnd"),$_SERVER["PHP_SELF"],"a.datep2",$param,'','align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Contact"),$_SERVER["PHP_SELF"],"a.fk_contact",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ActionUserAsk"),$_SERVER["PHP_SELF"],"ua.login",$param,"","",$sortfield,$sortorder); + //print_liste_field_titre($langs->trans("ActionUserAsk"),$_SERVER["PHP_SELF"],"ua.login",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("ActionsOwnedBy"),$_SERVER["PHP_SELF"],"ut.login",$param,"","",$sortfield,$sortorder); //print_liste_field_titre($langs->trans("DoneBy"),$_SERVER["PHP_SELF"],"ud.login",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"a.percent",$param,"",'align="right"',$sortfield,$sortorder); @@ -259,12 +268,14 @@ if ($resql) print ''; print ''; print ''; - print $form->select_date($dateselect, 'dateselect', 0, 0, 1, '', 1, 0, 1); + print $form->select_date($datestart, 'datestart', 0, 0, 1, '', 1, 0, 1); + print ''; + print ''; + print $form->select_date($dateend, 'dateend', 0, 0, 1, '', 1, 0, 1); print ''; print ''; print ''; - print ''; - print ''; + //print ''; print ''; print ''; //print '  '; @@ -281,6 +292,13 @@ if ($resql) { $obj = $db->fetch_object($resql); + // Discard auto action if option is on + if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') + { + $i++; + continue; + } + $var=!$var; print ""; @@ -288,7 +306,8 @@ if ($resql) // Action (type) print ''; $actionstatic->id=$obj->id; - $actionstatic->type_code=$obj->acode; + $actionstatic->type_code=$obj->type_code; + $actionstatic->type_label=$obj->type_label; $actionstatic->libelle=$obj->label; print $actionstatic->getNomUrl(1,28); print ''; @@ -337,6 +356,7 @@ if ($resql) print ''; // User author + /* print ''; if ($obj->useridauthor) { @@ -347,6 +367,7 @@ if ($resql) } else print ' '; print ''; + */ // User to do print ''; diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 51ddb81c0b4..da34983779a 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -395,6 +395,13 @@ if ($resql) { $obj = $db->fetch_object($resql); + // Discard auto action if option is on + if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') + { + $i++; + continue; + } + // Create a new object action $event=new ActionComm($db); $event->id=$obj->id; @@ -710,6 +717,11 @@ if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) print '
 
'; print $langs->trans("Other"); print '
'; + /* TODO Show this if at least one cumulated event + print '
 
'; + print $langs->trans("SeveralEvents"); + print '
'; + */ } // Add js code to manage click on a box @@ -734,7 +746,7 @@ jQuery(document).ready(function() { else if (ids.indexOf(",") > -1) /* There is several events */ { /* alert(\'several events\'); */ - url = "'.DOL_URL_ROOT.'/comm/action/listactions.php?usertodo="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+dateselectday; + url = "'.DOL_URL_ROOT.'/comm/action/listactions.php?usertodo="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day; window.location.href = url; } else /* One event */ diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index b344da39112..6281b1f25f4 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -111,10 +111,14 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once // Action clone object -if ($action == 'confirm_clone' && $confirm == 'yes') { - if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) { +if ($action == 'confirm_clone' && $confirm == 'yes') +{ + if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) + { setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); - } else { + } + else + { if ($object->id > 0) { $result = $object->createFromClone($socid); if ($result > 0) { @@ -129,7 +133,8 @@ if ($action == 'confirm_clone' && $confirm == 'yes') { } // Delete proposal -else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->propal->supprimer) { +else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->propal->supprimer) +{ $result = $object->delete($user); if ($result > 0) { header('Location: ' . DOL_URL_ROOT . '/comm/propal/list.php'); @@ -141,7 +146,8 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->prop } // Remove line -else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->propal->creer) { +else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->propal->creer) +{ $result = $object->deleteline($lineid); // reorder lines if ($result) @@ -164,19 +170,29 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights-> } // Validation -else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->propal->valider) { +else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->propal->valider) +{ $result = $object->valid($user); - if ($result >= 0) { - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { - $outputlangs = new Translate("", $conf); - $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang); - $outputlangs->setDefaultLang($newlang); + if ($result >= 0) + { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + if (empty($model)) { $tmp=getListOfModels($db, 'propal'); $keys=array_keys($tmp); $model=$keys[0]; } + $ret = $object->fetch($id); // Reload to get new records + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } - $ret = $object->fetch($id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } else { $langs->load("errors"); @@ -185,8 +201,9 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->pr } } -else if ($action == 'setdate' && $user->rights->propal->creer) { - $datep = dol_mktime(12, 0, 0, $_POST ['remonth'], $_POST ['reday'], $_POST ['reyear']); +else if ($action == 'setdate' && $user->rights->propal->creer) +{ + $datep = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); if (empty($datep)) { $error ++; @@ -198,23 +215,29 @@ else if ($action == 'setdate' && $user->rights->propal->creer) { if ($result < 0) dol_print_error($db, $object->error); } -} else if ($action == 'setecheance' && $user->rights->propal->creer) { - $result = $object->set_echeance($user, dol_mktime(12, 0, 0, $_POST ['echmonth'], $_POST ['echday'], $_POST ['echyear'])); +} +else if ($action == 'setecheance' && $user->rights->propal->creer) +{ + $result = $object->set_echeance($user, dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear'])); if ($result < 0) dol_print_error($db, $object->error); -} else if ($action == 'setdate_livraison' && $user->rights->propal->creer) { - $result = $object->set_date_livraison($user, dol_mktime(12, 0, 0, $_POST ['liv_month'], $_POST ['liv_day'], $_POST ['liv_year'])); +} +else if ($action == 'setdate_livraison' && $user->rights->propal->creer) +{ + $result = $object->set_date_livraison($user, dol_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year'])); if ($result < 0) dol_print_error($db, $object->error); } // Positionne ref client -else if ($action == 'set_ref_client' && $user->rights->propal->creer) { - $object->set_ref_client($user, $_POST ['ref_client']); +else if ($action == 'set_ref_client' && $user->rights->propal->creer) +{ + $object->set_ref_client($user, $_POST['ref_client']); } // Create proposal -else if ($action == 'add' && $user->rights->propal->creer) { +else if ($action == 'add' && $user->rights->propal->creer) +{ $object->socid = $socid; $object->fetch_thirdparty(); @@ -296,11 +319,11 @@ else if ($action == 'add' && $user->rights->propal->creer) { for($i = 1; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i ++) { - if ($_POST ['idprod' . $i]) { + if ($_POST['idprod' . $i]) { $xid = 'idprod' . $i; $xqty = 'qty' . $i; $xremise = 'remise' . $i; - $object->add_product($_POST [$xid], $_POST [$xqty], $_POST [$xremise]); + $object->add_product($_POST[$xid], $_POST[$xqty], $_POST[$xremise]); } } @@ -464,19 +487,26 @@ else if ($action == 'add' && $user->rights->propal->creer) { { $db->commit(); - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("", $conf); - $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret = $object->fetch($id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + if (empty($model)) { + $tmp=getListOfModels($db, 'propal'); $keys=array_keys($tmp); $model=$keys[0]; + } + + $ret = $object->fetch($id); // Reload to get new records + $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result < 0) dol_print_error($db,$result); + } header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); exit(); @@ -544,7 +574,7 @@ if (GETPOST('removedfile')) { $upload_dir_tmp = $vardir . '/temp'; // TODO Delete only files that was uploaded from email form - dol_remove_file_process($_POST ['removedfile'], 0); + dol_remove_file_process($_POST['removedfile'], 0); $action = 'presend'; } @@ -555,35 +585,35 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G $langs->load('mails'); if ($object->id > 0) { - if ($_POST ['sendto']) { + if ($_POST['sendto']) { // Le destinataire a ete fourni via le champ libre - $sendto = $_POST ['sendto']; + $sendto = $_POST['sendto']; $sendtoid = 0; - } elseif ($_POST ['receiver'] != '-1') { + } elseif ($_POST['receiver'] != '-1') { // Recipient was provided from combo list - if ($_POST ['receiver'] == 'thirdparty') // Id of third party + if ($_POST['receiver'] == 'thirdparty') // Id of third party { $sendto = $object->thirdparty->email; $sendtoid = 0; } else // Id du contact { - $sendto = $object->thirdparty->contact_get_property($_POST ['receiver'], 'email'); - $sendtoid = $_POST ['receiver']; + $sendto = $object->thirdparty->contact_get_property($_POST['receiver'], 'email'); + $sendtoid = $_POST['receiver']; } } if (dol_strlen($sendto)) { $langs->load("commercial"); - $from = $_POST ['fromname'] . ' <' . $_POST ['frommail'] . '>'; - $replyto = $_POST ['replytoname'] . ' <' . $_POST ['replytomail'] . '>'; - $message = $_POST ['message']; - $sendtocc = $_POST ['sendtocc']; + $from = $_POST['fromname'] . ' <' . $_POST['frommail'] . '>'; + $replyto = $_POST['replytoname'] . ' <' . $_POST['replytomail'] . '>'; + $message = $_POST['message']; + $sendtocc = $_POST['sendtocc']; $sendtobcc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO); - $deliveryreceipt = $_POST ['deliveryreceipt']; + $deliveryreceipt = $_POST['deliveryreceipt']; - if (dol_strlen($_POST ['subject'])) - $subject = $_POST ['subject']; + if (dol_strlen($_POST['subject'])) + $subject = $_POST['subject']; else $subject = $langs->transnoentities('Propal') . ' ' . $object->ref; $actiontypecode = 'AC_PROP'; @@ -683,9 +713,9 @@ if ($action == 'modif' && $user->rights->propal->creer) } else if ($action == "setabsolutediscount" && $user->rights->propal->creer) { - if ($_POST ["remise_id"]) { + if ($_POST["remise_id"]) { if ($object->id > 0) { - $result = $object->insert_discount($_POST ["remise_id"]); + $result = $object->insert_discount($_POST["remise_id"]); if ($result < 0) { setEventMessage($object->error, 'errors'); } @@ -723,7 +753,7 @@ else if ($action == 'addline' && $user->rights->propal->creer) { if (is_array($extralabelsline)) { // Get extra fields foreach ($extralabelsline as $key => $value) { - unset($_POST ["options_" . $key]); + unset($_POST["options_" . $key]); } } @@ -895,23 +925,23 @@ else if ($action == 'addline' && $user->rights->propal->creer) { $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - unset($_POST ['prod_entry_mode']); + unset($_POST['prod_entry_mode']); - unset($_POST ['qty']); - unset($_POST ['type']); - unset($_POST ['remise_percent']); - unset($_POST ['price_ht']); - unset($_POST ['price_ttc']); - unset($_POST ['tva_tx']); - unset($_POST ['product_ref']); - unset($_POST ['product_label']); - unset($_POST ['product_desc']); - unset($_POST ['fournprice']); - unset($_POST ['buying_price']); - unset($_POST ['np_marginRate']); - unset($_POST ['np_markRate']); - unset($_POST ['dp_desc']); - unset($_POST ['idprod']); + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['remise_percent']); + unset($_POST['price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); + unset($_POST['np_marginRate']); + unset($_POST['np_markRate']); + unset($_POST['dp_desc']); + unset($_POST['idprod']); unset($_POST['date_starthour']); unset($_POST['date_startmin']); @@ -966,7 +996,7 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa if (is_array($extralabelsline)) { // Get extra fields foreach ($extralabelsline as $key => $value) { - unset($_POST ["options_" . $key]); + unset($_POST["options_" . $key]); } } @@ -1023,18 +1053,18 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - unset($_POST ['qty']); - unset($_POST ['type']); - unset($_POST ['productid']); - unset($_POST ['remise_percent']); - unset($_POST ['price_ht']); - unset($_POST ['price_ttc']); - unset($_POST ['tva_tx']); - unset($_POST ['product_ref']); - unset($_POST ['product_label']); - unset($_POST ['product_desc']); - unset($_POST ['fournprice']); - unset($_POST ['buying_price']); + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['productid']); + unset($_POST['remise_percent']); + unset($_POST['price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); } else { $db->rollback(); @@ -1091,17 +1121,17 @@ else if ($action == 'remove_file' && $user->rights->propal->creer) { // Set project else if ($action == 'classin' && $user->rights->propal->creer) { - $object->setProject($_POST ['projectid']); + $object->setProject($_POST['projectid']); } // Delai de livraison else if ($action == 'setavailability' && $user->rights->propal->creer) { - $result = $object->availability($_POST ['availability_id']); + $result = $object->availability($_POST['availability_id']); } // Origine de la propale else if ($action == 'setdemandreason' && $user->rights->propal->creer) { - $result = $object->demand_reason($_POST ['demand_reason_id']); + $result = $object->demand_reason($_POST['demand_reason_id']); } // Conditions de reglement @@ -1110,11 +1140,11 @@ else if ($action == 'setconditions' && $user->rights->propal->creer) { } else if ($action == 'setremisepercent' && $user->rights->propal->creer) { - $result = $object->set_remise_percent($user, $_POST ['remise_percent']); + $result = $object->set_remise_percent($user, $_POST['remise_percent']); } else if ($action == 'setremiseabsolue' && $user->rights->propal->creer) { - $result = $object->set_remise_absolue($user, $_POST ['remise_absolue']); + $result = $object->set_remise_absolue($user, $_POST['remise_absolue']); } // Mode de reglement @@ -1206,7 +1236,7 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal-> { if ($object->id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $object->add_contact($contactid, $_POST ["type"], $_POST ["source"]); + $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); } if ($result >= 0) { @@ -2008,62 +2038,9 @@ if ($action == 'create') print ''; } - // Other attributes (TODO Move this into an include) - $res = $object->fetch_optionals($object->id, $extralabels); - $parameters = array('colspan' => ' colspan="3"'); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified - // by - // hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - foreach ($extrafields->attribute_label as $key => $label) - { - if ($action == 'edit_extras') - { - $value = (isset($_POST ["options_" . $key]) ? $_POST ["options_" . $key] : $object->array_options ["options_" . $key]); - } - else - { - $value = $object->array_options ["options_" . $key]; - } - if ($extrafields->attribute_type [$key] == 'separate') - { - print $extrafields->showSeparator($key); - } - else - { - print 'attribute_required [$key])) print ' class="fieldrequired"'; - print '>' . $label . ''; - // Convert date into timestamp format - if (in_array($extrafields->attribute_type [$key], array('date','datetime'))) { - $value = isset($_POST ["options_" . $key]) ? dol_mktime($_POST ["options_" . $key . "hour"], $_POST ["options_" . $key . "min"], 0, $_POST ["options_" . $key . "month"], $_POST ["options_" . $key . "day"], $_POST ["options_" . $key . "year"]) : $db->jdate($object->array_options ['options_' . $key]); - } - - if ($action == 'edit_extras' && $user->rights->propal->creer && GETPOST('attribute') == $key) - { - print ''; - print ''; - print ''; - print ''; - print ''; - - print $extrafields->showInputField($key, $value); - - print ''; - - print ''; - } - else - { - print $extrafields->showOutputField($key, $value); - if ($object->statut == 0 && $user->rights->propal->creer) - print '' . img_picto('', 'edit') . ' ' . $langs->trans('Modify') . ''; - } - print '' . "\n"; - } - } - } + // Other attributes + $cols = 3; + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; // Amount HT print '' . $langs->trans('AmountHT') . ''; diff --git a/htdocs/comm/propal/apercu.php b/htdocs/comm/propal/apercu.php index ce80783c731..e575c8f27fc 100644 --- a/htdocs/comm/propal/apercu.php +++ b/htdocs/comm/propal/apercu.php @@ -186,7 +186,7 @@ if ($id > 0 || ! empty($ref)) // Si fichier png PDF d'1 page trouve if (file_exists($fileimage)) { - print ''; + print ''; } // Si fichier png PDF de plus d'1 page trouve elseif (file_exists($fileimagebis)) @@ -199,13 +199,12 @@ elseif (file_exists($fileimagebis)) if (file_exists($dir_output.$preview)) { - print '

'; + print '

'; } } } -print '

'; - -$db->close(); llxFooter(); + +$db->close(); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index cdd5618c6b7..c056e5aa1c5 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1326,67 +1326,77 @@ class Propal extends CommonObject { $num = $this->ref; } + $this->newref = $num; $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; $sql.= " SET ref = '".$num."',"; $sql.= " fk_statut = 1, date_valid='".$this->db->idate($now)."', fk_user_valid=".$user->id; $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; - dol_syslog(get_class($this).'::valid', LOG_DEBUG); - if ($this->db->query($sql)) + dol_syslog(get_class($this)."::valid", LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) + { + dol_print_error($this->db); + $error++; + } + + // Trigger calls + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('PROPAL_VALIDATE',$user); + if ($result < 0) { $error++; } + // End call triggers + } + + if (! $error) { - if (! $notrigger) - { - // Call trigger - $result=$this->call_trigger('PROPAL_VALIDATE',$user); - if ($result < 0) { $error++; } - // End call triggers - } + $this->oldref = $this->ref; - if (! $error) - { - // Rename directory if dir was a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) - { - // Rename of propal directory ($this->ref = old ref, $num = new ref) - // to not lose the linked files - $oldref = dol_sanitizeFileName($this->ref); - $newref = dol_sanitizeFileName($num); - $dirsource = $conf->propal->dir_output.'/'.$oldref; - $dirdest = $conf->propal->dir_output.'/'.$newref; - if (file_exists($dirsource)) - { - dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); + // Rename directory if dir was a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) + { + // Rename of propal directory ($this->ref = old ref, $num = new ref) + // to not lose the linked files + $oldref = dol_sanitizeFileName($this->ref); + $newref = dol_sanitizeFileName($num); + $dirsource = $conf->propal->dir_output.'/'.$oldref; + $dirdest = $conf->propal->dir_output.'/'.$newref; - if (@rename($dirsource, $dirdest)) - { + if (file_exists($dirsource)) + { + dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); + if (@rename($dirsource, $dirdest)) + { + dol_syslog("Rename ok"); + // Rename docs starting with $oldref with $newref + $listoffiles=dol_dir_list($conf->propal->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/')); + foreach($listoffiles as $fileentry) + { + $dirsource=$fileentry['name']; + $dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource); + $dirsource=$fileentry['path'].'/'.$dirsource; + $dirdest=$fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } + } + } + } - dol_syslog("Rename ok"); - // Deleting old PDF in new rep - dol_delete_file($conf->propal->dir_output.'/'.$newref.'/'.$oldref.'*.*'); - } - } - } + $this->ref=$num; + $this->brouillon=0; + $this->statut = 1; + $this->user_valid_id=$user->id; + $this->datev=$now; - $this->ref=$num; - $this->brouillon=0; - $this->statut = 1; - $this->user_valid_id=$user->id; - $this->datev=$now; - - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - return -2; - } + $this->db->commit(); + return 1; } else { - $this->db->rollback(); - return -1; + $this->db->rollback(); + return -1; } } } diff --git a/htdocs/commande/apercu.php b/htdocs/commande/apercu.php index abb2be95076..839ca73d5b9 100644 --- a/htdocs/commande/apercu.php +++ b/htdocs/commande/apercu.php @@ -206,7 +206,7 @@ if ($id > 0 || ! empty($ref)) // Si fichier png PDF d'1 page trouve if (file_exists($fileimage)) { - print ''; + print ''; } // Si fichier png PDF de plus d'1 page trouve elseif (file_exists($fileimagebis)) @@ -219,13 +219,12 @@ elseif (file_exists($fileimagebis)) if (file_exists($dir_output.$preview)) { - print '

'; + print '

'; } } } -print ''; - -$db->close(); llxFooter(); + +$db->close(); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 136ade4df3c..47dfb568c78 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2006 Andre Cianfarani @@ -618,7 +618,7 @@ else if ($action == 'addline' && $user->rights->commande->creer) { $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); - if ($result >= 0) + if ($result >= 0) { if (count($prodcustprice->lines) > 0) { @@ -628,9 +628,9 @@ else if ($action == 'addline' && $user->rights->commande->creer) { $prod->tva_tx = $prodcustprice->lines [0]->tva_tx; } } - else - { - setEventMessage($prodcustprice->error,'errors'); + else + { + setEventMessage($prodcustprice->error,'errors'); } } @@ -908,20 +908,23 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->co if (! $error) { $result = $object->valid($user, $idwarehouse); - if ($result >= 0) { + if ($result >= 0) + { // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + if (empty($model)) { $tmp=getListOfModels($db, 'order'); $keys=array_keys($tmp); $model=$keys[0]; } + $ret = $object->fetch($id); // Reload to get new records + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } } @@ -954,21 +957,23 @@ else if ($action == 'confirm_modif' && $user->rights->commande->creer) { if (! $error) { $result = $object->set_draft($user, $idwarehouse); - if ($result >= 0) { + if ($result >= 0) + { // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $ret = $object->fetch($object->id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + if (empty($model)) { $tmp=getListOfModels($db, 'order'); $keys=array_keys($tmp); $model=$keys[0]; } + $ret = $object->fetch($id); // Reload to get new records + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } } @@ -1148,7 +1153,7 @@ else if ($action == 'update_extras') { /* * Add file in email form -*/ + */ if (GETPOST('addfile')) { require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; @@ -1162,7 +1167,7 @@ if (GETPOST('addfile')) { /* * Remove file in email form -*/ + */ if (GETPOST('removedfile')) { require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; @@ -1177,7 +1182,7 @@ if (GETPOST('removedfile')) { /* * Send mail -*/ + */ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! GETPOST('cancel')) { $langs->load('mails'); @@ -2130,60 +2135,9 @@ if ($action == 'create' && $user->rights->commande->creer) { print ''; } - // Other attributes (TODO Move this into an include) - $parameters = array('colspan' => ' colspan="3"'); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - foreach ($extrafields->attribute_label as $key => $label) - { - if ($action == 'edit_extras') - { - $value = (isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - } - else - { - $value = $object->array_options["options_" . $key]; - } - - if ($extrafields->attribute_type[$key] == 'separate') - { - print $extrafields->showSeparator($key); - } - else - { - print 'attribute_required [$key])) print ' class="fieldrequired"'; - print '>' . $label . ''; - // Convert date into timestamp format - if (in_array($extrafields->attribute_type [$key], array('date','datetime'))) - { - $value = isset($_POST["options_" . $key]) ? dol_mktime($_POST["options_" . $key . "hour"], $_POST["options_" . $key . "min"], 0, $_POST["options_" . $key . "month"], $_POST["options_" . $key . "day"], $_POST["options_" . $key . "year"]) : $db->jdate($object->array_options ['options_' . $key]); - } - - if ($action == 'edit_extras' && $user->rights->commande->creer && GETPOST('attribute') == $key) - { - print '

'; - print ''; - print ''; - print ''; - print ''; - - print $extrafields->showInputField($key, $value); - - print ''; - print '
'; - } - else - { - print $extrafields->showOutputField($key, $value); - if ($object->statut == 0 && $user->rights->commande->creer) - print '' . img_picto('', 'edit') . ' ' . $langs->trans('Modify') . ''; - } - print '' . "\n"; - } - } - } + // Other attributes + $cols = 3; + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; $rowspan = 4; if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 25c8a1d11c3..ce3ec431180 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -183,9 +183,10 @@ class Commande extends CommonOrder * * @param User $user User making status change * @param int $idwarehouse Id of warehouse to use for stock decrease + * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers * @return int <=0 if OK, >0 if KO */ - function valid($user, $idwarehouse=0) + function valid($user, $idwarehouse=0, $notrigger=0) { global $conf,$langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -223,9 +224,10 @@ class Commande extends CommonOrder $num = $this->getNextNumRef($soc); } else - { + { $num = $this->ref; } + $this->newref = $num; // Validate $sql = "UPDATE ".MAIN_DB_PREFIX."commande"; @@ -273,43 +275,49 @@ class Commande extends CommonOrder } } + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('ORDER_VALIDATE',$user); + if ($result < 0) $error++; + // End call triggers + } + if (! $error) { - $this->oldref=''; + $this->oldref = $this->ref; // Rename directory if dir was a temporary ref if (preg_match('/^[\(]?PROV/i', $this->ref)) { - // On renomme repertoire ($this->ref = ancienne ref, $numfa = nouvelle ref) + // On renomme repertoire ($this->ref = ancienne ref, $numfa = nouvelle ref) // in order not to lose the attachments - $comref = dol_sanitizeFileName($this->ref); - $snum = dol_sanitizeFileName($num); - $dirsource = $conf->commande->dir_output.'/'.$comref; - $dirdest = $conf->commande->dir_output.'/'.$snum; + $oldref = dol_sanitizeFileName($this->ref); + $newref = dol_sanitizeFileName($num); + $dirsource = $conf->commande->dir_output.'/'.$oldref; + $dirdest = $conf->commande->dir_output.'/'.$newref; if (file_exists($dirsource)) { dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest); if (@rename($dirsource, $dirdest)) { - $this->oldref = $comref; - dol_syslog("Rename ok"); - // Suppression ancien fichier PDF dans nouveau rep - dol_delete_file($conf->commande->dir_output.'/'.$snum.'/'.$comref.'*.*'); + // Rename docs starting with $oldref with $newref + $listoffiles=dol_dir_list($conf->commande->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/')); + foreach($listoffiles as $fileentry) + { + $dirsource=$fileentry['name']; + $dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource); + $dirsource=$fileentry['path'].'/'.$dirsource; + $dirdest=$fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } } } } } - if (! $error) - { - // Call trigger - $result=$this->call_trigger('ORDER_VALIDATE',$user); - if ($result < 0) $error++; - // End call triggers - } - // Set new ref and current status if (! $error) { @@ -323,7 +331,7 @@ class Commande extends CommonOrder return 1; } else - { + { $this->db->rollback(); return -1; } @@ -898,6 +906,13 @@ class Commande extends CommonOrder $this->date_validation = ''; $this->ref_client = ''; + // Set ref + require_once DOL_DOCUMENT_ROOT ."/core/modules/commande/".$conf->global->COMMANDE_ADDON.'.php'; + $obj = $conf->global->COMMANDE_ADDON; + $modCommande = new $obj; + $this->ref = $modCommande->getNextValue($objsoc,$this); + + // Create clone $result=$this->create($user); if ($result < 0) $error++; diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index 921b1739767..e6961ed97dd 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -233,7 +233,11 @@ foreach ($accounts as $key=>$type) $total[$acc->currency_code] += $solde; } } -if (! $found) print ''.$langs->trans("None").''; +if (! $found) +{ + $var = !$var; + print ''.$langs->trans("None").''; +} // Total foreach ($total as $key=>$solde) { diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 374851ca749..dd6455a3932 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -112,7 +112,7 @@ if ($conf->salaries->enabled) $total = 0 ; print ''; print ''; - print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"s.datev","",$param,'width="120"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"s.datev","",$param,'width="140px"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"s.label","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"s.amount","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("RefPayment"),$_SERVER["PHP_SELF"],"s.rowid","",$param,'',$sortfield,$sortorder); @@ -145,7 +145,7 @@ if ($conf->salaries->enabled) $i++; } - print ''; + print ''; print '"; print ''; print ''; @@ -175,7 +175,7 @@ if ($conf->tax->enabled) print '
'.$langs->trans("Total").'
'.$langs->trans("Total").''.price($total)."  
'; print ''; - print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"cs.date_ech","",$param,'width="120"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"cs.date_ech","",$param,'width="140px"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"c.libelle","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"cs.fk_type","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"cs.amount","",$param,'align="right"',$sortfield,$sortorder); @@ -305,7 +305,7 @@ if ($conf->tax->enabled) $total = 0 ; print '
'; print ''; - print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"pv.datev","",$param,'width="120"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"pv.datev","",$param,'width="140px"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"pv.label","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"pv.amount","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("RefPayment"),$_SERVER["PHP_SELF"],"pv.rowid","",$param,'',$sortfield,$sortorder); @@ -338,7 +338,7 @@ if ($conf->tax->enabled) $i++; } - print ''; + print ''; print '"; print ''; print ''; diff --git a/htdocs/compta/deplacement/class/deplacementstats.class.php b/htdocs/compta/deplacement/class/deplacementstats.class.php index c87b4ea033f..cf5f7fda45a 100644 --- a/htdocs/compta/deplacement/class/deplacementstats.class.php +++ b/htdocs/compta/deplacement/class/deplacementstats.class.php @@ -45,7 +45,7 @@ class DeplacementStats extends Stats * * @param DoliDB $db Database handler * @param int $socid Id third party - * @param int $userid Id user for filter + * @param mixed $userid Id user for filter or array of user ids * @return void */ function __construct($db, $socid=0, $userid=0) @@ -66,7 +66,8 @@ class DeplacementStats extends Stats { $this->where.=" AND fk_soc = ".$this->socid; } - if ($this->userid > 0) $this->where.=' AND fk_user = '.$this->userid; + if (is_array($this->userid) && count($this->userid) > 0) $this->where.=' AND fk_user IN ('.join(',',$this->userid).')'; + else if ($this->userid > 0) $this->where.=' AND fk_user = '.$this->userid; } diff --git a/htdocs/compta/deplacement/index.php b/htdocs/compta/deplacement/index.php index bded8c261e2..37a0f944bb3 100644 --- a/htdocs/compta/deplacement/index.php +++ b/htdocs/compta/deplacement/index.php @@ -54,6 +54,9 @@ $limit = $conf->liste_limit; $tripandexpense_static=new Deplacement($db); +$childids = $user->getAllChildIds(); +$childids[]=$user->id; + //$help_url='EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones'; $help_url=''; llxHeader('',$langs->trans("ListOfFees"),$help_url); @@ -64,6 +67,7 @@ $totalnb=0; $sql = "SELECT count(d.rowid) as nb, sum(d.km) as km, d.type"; $sql.= " FROM ".MAIN_DB_PREFIX."deplacement as d"; $sql.= " WHERE d.entity = ".$conf->entity; +if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',',$childids).')'; $sql.= " GROUP BY d.type"; $sql.= " ORDER BY d.type"; @@ -134,6 +138,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."deplacement as d, ".MAIN_DB_PREFIX."user as u"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE u.rowid = d.fk_user"; $sql.= " AND d.entity = ".$conf->entity; +if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',',$childids).')'; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND d.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND d.fk_soc = ".$socid; $sql.= $db->order("d.tms","DESC"); diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index bc4406448df..bb2c50b42bf 100644 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -58,6 +58,9 @@ $search_ref=GETPOST('search_ref','alpha'); $tripandexpense_static=new Deplacement($db); $userstatic = new User($db); +$childids = $user->getAllChildIds(); +$childids[]=$user->id; + llxHeader(); $sql = "SELECT s.nom, s.rowid as socid,"; // Ou @@ -70,6 +73,7 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON d.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql.= " WHERE d.fk_user = u.rowid"; $sql.= " AND d.entity = ".$conf->entity; +if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',',$childids).')'; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; if (trim($search_ref) != '') @@ -167,6 +171,7 @@ else { dol_print_error($db); } -$db->close(); llxFooter(); + +$db->close(); diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php index 6e702002505..0d0a32a877c 100644 --- a/htdocs/compta/deplacement/stats/index.php +++ b/htdocs/compta/deplacement/stats/index.php @@ -45,6 +45,18 @@ if ($user->societe_id > 0) if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'deplacement', $id,''); +// Other security check +$childids = $user->getAllChildIds(); +$childids[]=$user->id; +if ($userid > 0) +{ + if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous) && ! in_array($userid, $childids)) + { + accessforbidden(); + exit; + } +} + $nowyear=strftime("%Y", dol_now()); $year = GETPOST('year')>0?GETPOST('year'):$nowyear; //$startyear=$year-2; @@ -60,6 +72,7 @@ $mode=GETPOST("mode")?GETPOST("mode"):'customer'; $form=new Form($db); + llxHeader(); $title=$langs->trans("TripsAndExpensesStatistics"); @@ -69,7 +82,14 @@ print_fiche_titre($title, $mesg); dol_mkdir($dir); -$stats = new DeplacementStats($db, $socid, $userid); +$useridtofilter=$userid; // Filter from parameters +if (empty($useridtofilter)) +{ + $useridtofilter=$childids; + if (! empty($user->rights->deplacement->readall) || ! empty($user->rights->deplacement->lire_tous)) $useridtofilter=0; +} + +$stats = new DeplacementStats($db, $socid, $useridtofilter); // Build graphic number of object @@ -220,7 +240,9 @@ print $form->select_company($socid,'socid',$filter,1,1); print ''; // User print ''; // Year print ''; } - // Other attributes (TODO Move this into an include) - $res = $object->fetch_optionals($object->id, $extralabels); - $parameters = array('colspan' => ' colspan="5"', "cols" => 5); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by - // hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - foreach ($extrafields->attribute_label as $key => $label) - { - if ($action == 'edit_extras') { - $value = (isset($_POST["options_" . $key]) ? $_POST["options_" . $key] : $object->array_options ["options_" . $key]); - } else { - $value = $object->array_options ["options_" . $key]; - } - if ($extrafields->attribute_type [$key] == 'separate') { - print $extrafields->showSeparator($key); - } else { - print 'attribute_required [$key])) - print ' class="fieldrequired"'; - print '>' . $label . '' . "\n"; - } - } - } + // Other attributes + $cols = 5; + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print '
'.$langs->trans("Total").'
'.$langs->trans("Total").''.price($total)."  
'.$langs->trans("User").''; -print $form->select_dolusers($userid,'userid',1); +$include=''; +if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $include='hierarchy'; +print $form->select_dolusers($userid,'userid',1,'',0,$include); print '
'.$langs->trans("Year").''; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 245f187d166..58001d5c918 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -406,21 +406,25 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->factu if ($result >= 0) { // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + if (empty($model)) { $tmp=getListOfModels($db, 'invoice'); $keys=array_keys($tmp); $model=$keys[0]; } $ret = $object->fetch($id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result < 0) dol_print_error($db,$result); } - } else { + } + else + { if (count($object->errors)) setEventMessage($object->errors, 'errors'); else setEventMessage($object->error, 'errors'); } @@ -483,20 +487,22 @@ else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_ $result=$object->set_draft($user, $idwarehouse); if ($result<0) setEventMessage($object->error,'errors'); + // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + if (empty($model)) { $tmp=getListOfModels($db, 'invoice'); $keys=array_keys($tmp); $model=$keys[0]; } $ret = $object->fetch($id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } } @@ -1158,7 +1164,11 @@ else if ($action == 'addline' && $user->rights->facture->creer) setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors'); $error ++; } - + if ($qty < 0) { + $langs->load("errors"); + setEventMessage($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), 'errors'); + $error ++; + } if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { $ret = $object->fetch($id); if ($ret < 0) { @@ -1304,23 +1314,26 @@ else if ($action == 'addline' && $user->rights->facture->creer) // Insert line $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, - 1, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_option); - if ($result > 0) { - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language + if ($result > 0) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { $outputlangs = $langs; - $newlang = GETPOST('lang_id', 'alpha'); - if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) - $newlang = $object->thirdparty->default_lang; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - + $model=$object->modelpdf; + if (empty($model)) { $tmp=getListOfModels($db, 'invoice'); $keys=array_keys($tmp); $model=$keys[0]; } $ret = $object->fetch($id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } - unset($_POST ['prod_entry_mode']); + unset($_POST['prod_entry_mode']); unset($_POST['qty']); unset($_POST['type']); @@ -1359,9 +1372,9 @@ else if ($action == 'addline' && $user->rights->facture->creer) } } -elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('cancel')) { - if (! $object->fetch($id) > 0) - dol_print_error($db); +elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('cancel')) +{ + if (! $object->fetch($id) > 0) dol_print_error($db); $object->fetch_thirdparty(); // Clean parameters @@ -1372,6 +1385,7 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST(' $description = dol_htmlcleanlastbr(GETPOST('product_desc')); $pu_ht = GETPOST('price_ht'); $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + $qty = GETPOST('qty'); // Define info_bits $info_bits = 0; @@ -1428,10 +1442,15 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST(' $error ++; } } + if ($qty < 0) { + $langs->load("errors"); + setEventMessage($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), 'errors'); + $error ++; + } // Update line if (! $error) { - $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_option); + $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, $qty, GETPOST('remise_percent'), $date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_option); if ($result >= 0) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -1463,6 +1482,8 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST(' unset($_POST['product_desc']); unset($_POST['fournprice']); unset($_POST['buying_price']); + unset($_POST['np_marginRate']); + unset($_POST['np_markRate']); } else { setEventMessage($object->error, 'errors'); } @@ -3324,52 +3345,9 @@ if ($action == 'create') print '
'; - // Convert date into timestamp format - if (in_array($extrafields->attribute_type [$key], array('date','datetime'))) { - $value = isset($_POST["options_" . $key]) ? dol_mktime($_POST["options_" . $key . "hour"], $_POST["options_" . $key . "min"], 0, $_POST["options_" . $key . "month"], $_POST["options_" . $key . "day"], $_POST["options_" . $key . "year"]) : $db->jdate($object->array_options ['options_' . $key]); - } - - if ($action == 'edit_extras' && $user->rights->facture->creer && GETPOST('attribute') == $key) { - print '
'; - print ''; - print ''; - print ''; - print ''; - - print $extrafields->showInputField($key, $value); - - print ''; - print '
'; - } else { - print $extrafields->showOutputField($key, $value); - if ($object->statut == 0 && $user->rights->facture->creer) - print '' . img_picto('', 'edit') . ' ' . $langs->trans('Modify') . ''; - } - print '

'; @@ -3622,21 +3600,24 @@ if ($action == 'create') // Linked object block $somethingshown = $object->showLinkedObjectBlock(); - if (empty($somethingshown) && ! empty($conf->commande->enabled)) + $linktoelem=''; + + if (! empty($conf->commande->enabled)) { - print '
' . $langs->trans('LinkedOrder') . ''; + $linktoelem.=($linktoelem?'   ':'').'' . $langs->trans('LinkedOrder') . ''; print ' '; - print '