diff --git a/ChangeLog b/ChangeLog index 9c9c2b8a039..d6e412ec06e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,13 @@ 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) @@ -138,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". @@ -156,6 +165,7 @@ Dolibarr better: - 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/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 ''; // 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/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/comm/propal.php b/htdocs/comm/propal.php index 6cd70b273be..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) { 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/card.php b/htdocs/commande/card.php index 60e5d81e37a..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 @@ -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'); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 6db8af5c2db..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; } @@ -904,7 +912,7 @@ class Commande extends CommonOrder $modCommande = new $obj; $this->ref = $modCommande->getNextValue($objsoc,$this); - + // Create clone $result=$this->create($user); if ($result < 0) $error++; 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 ''.$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 ''; // Year print ''.$langs->trans("Year").''; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index eb4ca29f022..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'); } @@ -3579,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 '