Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Florian HENRY 2014-10-30 13:25:36 +01:00
commit 9f2c596496
79 changed files with 1608 additions and 997 deletions

View File

@ -5,6 +5,13 @@ English Dolibarr ChangeLog
***** ChangeLog for 3.7 compared to 3.6.* ***** ***** ChangeLog for 3.7 compared to 3.6.* *****
For users: 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: Can set a color on user card (visible into agenda view).
- New: extrafields for projects and tasks are exported to ODT documents. - 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: 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 WARNING: Following changes may create regression for some external modules, but was necessary to make
Dolibarr better: 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. - Deprecated module "oscommerce" were removed.
- Changed the way parameters are provided to scripts sync_xxx_ldap2dolibarr.php - Changed the way parameters are provided to scripts sync_xxx_ldap2dolibarr.php
- Some field into database were renamed from "libelle" to "label". - 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: box of customer and propsects were not correctly disabled.
- Fix: right and error management #1961 - Fix: right and error management #1961
- Fix: Fix Error when trying to clone an Order #1943 - 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.* ***** ***** ChangeLog for 3.6.1 compared to 3.6.* *****
For users: For users:

View File

@ -3,7 +3,7 @@ Section: web
Priority: optional Priority: optional
Maintainer: Laurent Destailleur (eldy) <eldy@users.sourceforge.net> Maintainer: Laurent Destailleur (eldy) <eldy@users.sourceforge.net>
# Uploaders: Laurent Destailleur (eldy) <eldy@users.sourceforge.net> # Only if differs from Maintainer # Uploaders: Laurent Destailleur (eldy) <eldy@users.sourceforge.net> # Only if differs from Maintainer
Standards-Version: 3.9.4 Standards-Version: 3.9.6
Homepage: http://www.dolibarr.org Homepage: http://www.dolibarr.org
Build-Depends: debhelper (>= 9), po-debconf Build-Depends: debhelper (>= 9), po-debconf
# This package need at least debian 7 or ubuntu 13.04 or any distribution based on this version # 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, php5-mysql | php5-mysqli, php5-curl, php5-gd, php5-ldap, php5-geoip,
# Required PHP libraries # Required PHP libraries
php-pear, php-mail-mime, 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, # libphp-adodb,
# libnusoap-php, # libnusoap-php,
# libphp-pclzip, # libphp-pclzip,
@ -26,9 +27,10 @@ Depends: libapache2-mod-php5 | libapache2-mod-php5filter | php5-cgi | php5-fpm |
# fonts-dejavu-core | ttf-dejavu-core, # fonts-dejavu-core | ttf-dejavu-core,
xdg-utils, xdg-utils,
mysql-server, mysql-server,
mysql-client,
${misc:Depends}, ${misc:Depends},
${perl:Depends} ${perl:Depends}
Recommends: mysql-client, apache2 | lighttpd | httpd Recommends: apache2 | lighttpd | httpd
Suggests: www-browser Suggests: www-browser
Description: Web based software to manage a company or foundation Description: Web based software to manage a company or foundation
Dolibarr ERP & CRM is an easy to use open source/free software for small Dolibarr ERP & CRM is an easy to use open source/free software for small

View File

@ -1,7 +1,7 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Dolibarr Upstream-Name: Dolibarr
Upstream-Contact: Laurent Destailleur <eldy@users.sourceforge.net> Upstream-Contact: Laurent Destailleur <eldy@users.sourceforge.net>
Source: http://sourceforge.net/projects/dolibarr/files/ Source: http://www.dolibarr.org/files/stable/standard/
Files: * Files: *
Copyright: 2002-2009, Rodolphe Quiedeville <rodolphe@quiedeville.org> Copyright: 2002-2009, Rodolphe Quiedeville <rodolphe@quiedeville.org>

View File

@ -65,8 +65,9 @@ if ($action == 'add')
$sql.= " FROM ".MAIN_DB_PREFIX."user_param"; $sql.= " FROM ".MAIN_DB_PREFIX."user_param";
$sql.= " WHERE param = 'MAIN_BOXES_".$db->escape(GETPOST("pos","alpha"))."' AND value = '1'"; $sql.= " WHERE param = 'MAIN_BOXES_".$db->escape(GETPOST("pos","alpha"))."' AND value = '1'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
dol_syslog("boxes.php search fk_user to activate box for", LOG_DEBUG); dol_syslog("boxes.php search fk_user to activate box for", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($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 = "SELECT b.rowid, b.box_id, b.position, b.box_order,";
$sql.= " bd.rowid as boxid"; $sql.= " bd.rowid as boxid";
$sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as bd"; $sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as bd";
$sql.= " WHERE b.entity = ".$conf->entity; $sql.= " WHERE b.box_id = bd.rowid";
$sql.= " AND 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.= " AND b.fk_user=0";
$sql.= " ORDER by b.position, b.box_order"; $sql.= " ORDER by b.position, b.box_order";
@ -237,6 +238,8 @@ $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
// Check record to know if we must recalculate sort order
$i = 0; $i = 0;
$decalage=0; $decalage=0;
$var=false; $var=false;
@ -310,7 +313,6 @@ if ($resql)
$db->free($resql); $db->free($resql);
} }
// Available boxes to activate // Available boxes to activate
$boxtoadd=InfoBox::listBoxes($db,'available',-1,null,$actives); $boxtoadd=InfoBox::listBoxes($db,'available',-1,null,$actives);
@ -372,7 +374,7 @@ print '</table>';
// Activated boxes // Activated boxes
$boxactivated=InfoBox::listBoxes($db,'activated',-1,null); $boxactivated=InfoBox::listBoxes($db,'activated',-1,null);
//var_dump($boxactivated);
print "<br>\n\n"; print "<br>\n\n";
print_titre($langs->trans("BoxesActivated")); print_titre($langs->trans("BoxesActivated"));

View File

@ -32,6 +32,7 @@ $langs->load("other");
$langs->load("orders"); $langs->load("orders");
$langs->load("propal"); $langs->load("propal");
$langs->load("bills"); $langs->load("bills");
$langs->load("errors");
// Security check // Security check
if (!$user->admin) if (!$user->admin)
@ -39,19 +40,32 @@ if (!$user->admin)
$action = GETPOST("action"); $action = GETPOST("action");
/* /*
* Actions * Actions
*/ */
if ($action == 'setvalue' && $user->admin) if ($action == 'setvalue' && $user->admin)
{ {
$result=dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM",$_POST["email_from"],'chaine',0,'',$conf->entity); $result=dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM", $_POST["email_from"], 'chaine', 0, '', $conf->entity);
if ($result >= 0) if ($result < 0) $error++;
if (! $error)
{
foreach($_POST as $key => $val)
{
if (! preg_match('/^NOTIFICATION_FIXEDEMAIL_/',$key)) continue;
//print $key.' - '.$val.'<br>';
$result=dolibarr_set_const($db, $key, $val, 'chaine', 0, '', $conf->entity);
}
}
if (! $error)
{ {
setEventMessage($langs->trans("SetupSaved")); setEventMessage($langs->trans("SetupSaved"));
} }
else else
{ {
setEventMessage($langs->trans("Error"),'errors'); setEventMessage($langs->trans("Error"),'errors');
} }
} }
@ -67,7 +81,7 @@ llxHeader();
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("NotificationSetup"),$linkback,'setup'); print_fiche_titre($langs->trans("NotificationSetup"),$linkback,'setup');
print $langs->trans("NotificationsDesc").'<br><br>'; print $langs->trans("NotificationsDesc").'<br><br>';
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -83,19 +97,13 @@ print "</tr>\n";
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'; print '<tr '.$bc[$var].'><td>';
print $langs->trans("NotificationEMailFrom").'</td><td>'; print $langs->trans("NotificationEMailFrom").'</td><td>';
print '<input size="32" type="text" name="email_from" value="'.$conf->global->NOTIFICATION_EMAIL_FROM.'">'; print '<input size="32" type="email" name="email_from" value="'.$conf->global->NOTIFICATION_EMAIL_FROM.'">';
if (! empty($conf->global->NOTIFICATION_EMAIL_FROM) && ! isValidEmail($conf->global->NOTIFICATION_EMAIL_FROM)) print ' '.img_warning($langs->trans("BadEMail")); if (! empty($conf->global->NOTIFICATION_EMAIL_FROM) && ! isValidEmail($conf->global->NOTIFICATION_EMAIL_FROM)) print ' '.img_warning($langs->trans("ErrorBadEMail"));
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
print '<br>'; print '<br>';
print '<center><input type="submit" class="button" value="'.$langs->trans("Modify").'"></center>';
print '</form>';
print '<br>';
print_fiche_titre($langs->trans("ListOfAvailableNotifications"),'',''); print_fiche_titre($langs->trans("ListOfAvailableNotifications"),'','');
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
@ -103,6 +111,7 @@ print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Module").'</td>'; print '<td>'.$langs->trans("Module").'</td>';
print '<td>'.$langs->trans("Code").'</td>'; print '<td>'.$langs->trans("Code").'</td>';
print '<td>'.$langs->trans("Label").'</td>'; print '<td>'.$langs->trans("Label").'</td>';
print '<td>'.$langs->trans("FixedEmailTarget").'</td>';
print "</tr>\n"; print "</tr>\n";
// Load array of available notifications // Load array of available notifications
@ -123,10 +132,21 @@ foreach($listofnotifiedevents as $notifiedevent)
print '<td>'.$elementLabel.'</td>'; print '<td>'.$elementLabel.'</td>';
print '<td>'.$notifiedevent['code'].'</td>'; print '<td>'.$notifiedevent['code'].'</td>';
print '<td>'.$label.'</td>'; print '<td>'.$label.'</td>';
$param='NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'];
print '<td><input type="email" size="32" name="'.$param.'" value="'.dol_escape_htmltag(GETPOST($param)?GETPOST($param,'alpha'):$conf->global->$param).'">';
if (! empty($conf->global->$param) && ! isValidEmail($conf->global->$param)) print ' '.img_warning($langs->trans("ErrorBadEMail"));
print '</td>';
print '</tr>'; print '</tr>';
} }
print '</table>'; print '</table>';
$db->close(); print '<br>';
print '<center><input type="submit" class="button" value="'.$langs->trans("Save").'"></center>';
print '</form>';
llxFooter(); llxFooter();
$db->close();

View File

@ -43,15 +43,9 @@ else
$obj_facturation = new Facturation(); $obj_facturation = new Facturation();
} }
print '<div class="liste_articles">';
require ('tpl/liste_articles.tpl.php');
$obj_facturation->prixTotalHt($lst_total_ht);
$obj_facturation->prixTotalTtc($lst_total_ttc);
print '</div>';
// Left area with selected articles (shopping cart)
print '<div class="principal">'; print '<div class="principal">';
$page=GETPOST('menu','alpha'); $page=GETPOST('menu','alpha');
@ -75,4 +69,18 @@ else
print '</div>'; print '</div>';
// Right area with selected articles (shopping cart)
print '<div class="liste_articles">';
require ('tpl/liste_articles.tpl.php');
$obj_facturation->prixTotalHt($lst_total_ht);
$obj_facturation->prixTotalTtc($lst_total_ttc);
print '</div>';
$_SESSION['serObjFacturation'] = serialize($obj_facturation); $_SESSION['serObjFacturation'] = serialize($obj_facturation);

View File

@ -30,23 +30,24 @@ p {
.conteneur { .conteneur {
background: #fff; background: #fff;
text-align: left; text-align: left;
width: 770px; max-width: 770px;
margin: 10px auto; margin: 10px auto;
border: 2px solid #000;
} }
.conteneur_img_gauche { .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 { .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 ------------------- */ /* ------------------- Header ------------------- */
.entete { .entete {
height: 15px; height: 15px;
margin: 0; margin: 0;
background: url('../img/bg_entete.png') no-repeat left top; /* background: url('../img/bg_entete.png') no-repeat left top; */
} }
.entete span { .entete span {
@ -57,7 +58,6 @@ p {
.menu_principal { .menu_principal {
margin: 0 20px 20px 15px; margin: 0 20px 20px 15px;
font-size: 14px; font-size: 14px;
width: 735px;
height: 84px; height: 84px;
background: #CCCCCC; background: #CCCCCC;
background-image: linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(40,40,40,.3) 100%); background-image: linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(40,40,40,.3) 100%);
@ -80,20 +80,21 @@ p {
.menu li { .menu li {
float: left; float: left;
padding-right: 10px;
} }
.menu_choix1,.menu_choix2 { .menu_choix1,.menu_choix2 {
font-size: 1.4em; font-size: 1.4em;
text-align: left; text-align: left;
width: 180px;
} }
.menu_choix1 a,.menu_choix2 a { .menu_choix1 a,.menu_choix2 a {
display: block; display: block;
color: #fff; color: #fff;
text-decoration: none; text-decoration: none;
width: 100px; padding-top: 18px;
padding-left: 54px; padding-left: 54px;
font-size: 14px;
height: 48px; height: 48px;
background: url('../img/new.png') top left no-repeat; background: url('../img/new.png') top left no-repeat;
} }
@ -115,7 +116,6 @@ p {
text-align: right; text-align: right;
font-style: italic; font-style: italic;
font-weight: normal; font-weight: normal;
width: 340px;
display: block; display: block;
color: #333; color: #333;
text-decoration: none; text-decoration: none;
@ -126,11 +126,13 @@ p {
font-weight: normal; font-weight: normal;
text-decoration: none; text-decoration: none;
} }
li.menu_choix0 {
float: right;
}
/* ------------------- R<>capitulatif des articles ------------------- */ /* ------------------- R<>capitulatif des articles ------------------- */
.liste_articles { .liste_articles {
width: 215px; min-width: 215px;
float: right; float: right;
margin-top: 8px; margin-top: 8px;
margin-right: 20px; margin-right: 20px;
@ -219,7 +221,7 @@ p.titre {
float: left; float: left;
margin: 0 15px; margin: 0 15px;
padding: 0; padding: 0;
width: 495px; max-width: 500px;
} }
.titre1 { .titre1 {
@ -237,7 +239,6 @@ p.titre {
.cadre_facturation { .cadre_facturation {
border: 2px solid #ddd; border: 2px solid #ddd;
margin-bottom: 15px; margin-bottom: 15px;
padding: 10px 10px;
} }
.principal p { .principal p {
@ -374,7 +375,7 @@ p.titre {
.pied { .pied {
clear: both; clear: both;
height: 15px; height: 15px;
background: url('../img/bg_pied.png') no-repeat bottom left; /* background: url('../img/bg_pied.png') no-repeat bottom left; */
} }
/* ------------------- Param<61>tres communs (messages d'erreur, informations, etc...) ------------------- */ /* ------------------- Param<61>tres communs (messages d'erreur, informations, etc...) ------------------- */

View File

@ -158,9 +158,9 @@ $sql = "SELECT t.rowid, t.taux";
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t"; $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t";
$sql.= ", ".MAIN_DB_PREFIX."c_country as c"; $sql.= ", ".MAIN_DB_PREFIX."c_country as c";
$sql.= " WHERE t.fk_pays = c.rowid"; $sql.= " WHERE t.fk_pays = c.rowid";
$sql.= " AND c.active = 1"; $sql.= " AND t.active = 1";
$sql.= " AND c.code = '".$mysoc->country_code."'"; $sql.= " AND c.code = '".$mysoc->country_code."'";
//print $request; //print $sql;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)

View File

@ -111,8 +111,9 @@ $langs->load("cashdesk");
<td> <td>
<input class="texte1_off" type="text" name="txtStock" value="<?php echo $obj_facturation->stock() ?>" disabled="disabled" /> <input class="texte1_off" type="text" name="txtStock" value="<?php echo $obj_facturation->stock() ?>" disabled="disabled" />
</td> </td>
<!-- Affichage du prix unitaire --> <!-- Show unit price -->
<td><input class="texte1_off" type="text" name="txtPrixUnit" value="<?php echo price2num($obj_facturation->prix(), 'MU'); ?>" disabled="disabled" /></td> <?php // TODO Remove the disabled and use this value when adding product into cart ?>
<td><input class="texte1_off" type="text" name="txtPrixUnit" value="<?php echo price2num($obj_facturation->prix(), 'MU'); ?>" onchange="javascript: modif();" disabled="disabled" /></td>
<td><?php echo $conf->currency; ?></td> <td><?php echo $conf->currency; ?></td>
<!-- Choix de la remise --> <!-- Choix de la remise -->
<td><input class="texte1" type="text" id="txtRemise" name="txtRemise" value="0" onkeyup="javascript: modif();" onfocus="javascript: this.select();"/> <td><input class="texte1" type="text" id="txtRemise" name="txtRemise" value="0" onkeyup="javascript: modif();" onfocus="javascript: this.select();"/>
@ -122,9 +123,9 @@ $langs->load("cashdesk");
<td><input class="texte1_off" type="text" name="txtTotal" value="" disabled="disabled" /></td><td><?php echo $conf->currency; ?></td> <td><input class="texte1_off" type="text" name="txtTotal" value="" disabled="disabled" /></td><td><?php echo $conf->currency; ?></td>
<!-- Choix du taux de TVA --> <!-- Choix du taux de TVA -->
<td class="select_tva"> <td class="select_tva">
<?php //var_dump($tab_tva); ?>
<select name="selTva" onchange="javascript: modif();" > <select name="selTva" onchange="javascript: modif();" >
<?php <?php
$tva_tx = $obj_facturation->tva(); $tva_tx = $obj_facturation->tva();
$tab_tva_size=count($tab_tva); $tab_tva_size=count($tab_tva);
for($i=0;$i < $tab_tva_size;$i++) { for($i=0;$i < $tab_tva_size;$i++) {
@ -132,12 +133,10 @@ $langs->load("cashdesk");
if ( $tva_tx == $tab_tva[$i]['taux'] ) if ( $tva_tx == $tab_tva[$i]['taux'] )
$selected = 'selected="selected"'; $selected = 'selected="selected"';
else else
$selected = ''; $selected = '';
echo ('<option '.$selected.' value="'.$tab_tva[$i]['rowid'].'">'.$tab_tva[$i]['taux'].'</option>'."\n "); echo ('<option '.$selected.' value="'.$tab_tva[$i]['rowid'].'">'.$tab_tva[$i]['taux'].'</option>'."\n ");
} }
?> ?>
</select> </select>
</td> </td>

View File

@ -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 include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once
// Action clone object // Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes') { if ($action == 'confirm_clone' && $confirm == 'yes')
if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) { {
if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers'))
{
setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors');
} else { }
else
{
if ($object->id > 0) { if ($object->id > 0) {
$result = $object->createFromClone($socid); $result = $object->createFromClone($socid);
if ($result > 0) { if ($result > 0) {
@ -129,7 +133,8 @@ if ($action == 'confirm_clone' && $confirm == 'yes') {
} }
// Delete proposal // 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); $result = $object->delete($user);
if ($result > 0) { if ($result > 0) {
header('Location: ' . DOL_URL_ROOT . '/comm/propal/list.php'); 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 // 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); $result = $object->deleteline($lineid);
// reorder lines // reorder lines
if ($result) if ($result)
@ -164,19 +170,29 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->
} }
// Validation // 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); $result = $object->valid($user);
if ($result >= 0) { if ($result >= 0)
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { {
// Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
$outputlangs = $langs; {
if (! empty($conf->global->MAIN_MULTILANGS)) { // Define output language
$outputlangs = new Translate("", $conf); if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang); {
$outputlangs->setDefaultLang($newlang); $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 { } else {
$langs->load("errors"); $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) { else if ($action == 'setdate' && $user->rights->propal->creer)
$datep = dol_mktime(12, 0, 0, $_POST ['remonth'], $_POST ['reday'], $_POST ['reyear']); {
$datep = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
if (empty($datep)) { if (empty($datep)) {
$error ++; $error ++;
@ -198,23 +215,29 @@ else if ($action == 'setdate' && $user->rights->propal->creer) {
if ($result < 0) if ($result < 0)
dol_print_error($db, $object->error); 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) if ($result < 0)
dol_print_error($db, $object->error); 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) if ($result < 0)
dol_print_error($db, $object->error); dol_print_error($db, $object->error);
} }
// Positionne ref client // Positionne ref client
else if ($action == 'set_ref_client' && $user->rights->propal->creer) { else if ($action == 'set_ref_client' && $user->rights->propal->creer)
$object->set_ref_client($user, $_POST ['ref_client']); {
$object->set_ref_client($user, $_POST['ref_client']);
} }
// Create proposal // Create proposal
else if ($action == 'add' && $user->rights->propal->creer) { else if ($action == 'add' && $user->rights->propal->creer)
{
$object->socid = $socid; $object->socid = $socid;
$object->fetch_thirdparty(); $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 ++) for($i = 1; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i ++)
{ {
if ($_POST ['idprod' . $i]) { if ($_POST['idprod' . $i]) {
$xid = 'idprod' . $i; $xid = 'idprod' . $i;
$xqty = 'qty' . $i; $xqty = 'qty' . $i;
$xremise = 'remise' . $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(); $db->commit();
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) // Define output language
{ if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
// Define output language {
$outputlangs = $langs; $outputlangs = $langs;
if (! empty($conf->global->MAIN_MULTILANGS)) $newlang = '';
{ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
$outputlangs = new Translate("", $conf); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang); if (! empty($newlang)) {
$outputlangs->setDefaultLang($newlang); $outputlangs = new Translate("", $conf);
} $outputlangs->setDefaultLang($newlang);
$ret = $object->fetch($id); // Reload to get new records }
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); $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); header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
exit(); exit();
@ -544,7 +574,7 @@ if (GETPOST('removedfile')) {
$upload_dir_tmp = $vardir . '/temp'; $upload_dir_tmp = $vardir . '/temp';
// TODO Delete only files that was uploaded from email form // 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'; $action = 'presend';
} }
@ -555,35 +585,35 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
$langs->load('mails'); $langs->load('mails');
if ($object->id > 0) { if ($object->id > 0) {
if ($_POST ['sendto']) { if ($_POST['sendto']) {
// Le destinataire a ete fourni via le champ libre // Le destinataire a ete fourni via le champ libre
$sendto = $_POST ['sendto']; $sendto = $_POST['sendto'];
$sendtoid = 0; $sendtoid = 0;
} elseif ($_POST ['receiver'] != '-1') { } elseif ($_POST['receiver'] != '-1') {
// Recipient was provided from combo list // 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; $sendto = $object->thirdparty->email;
$sendtoid = 0; $sendtoid = 0;
} else // Id du contact } else // Id du contact
{ {
$sendto = $object->thirdparty->contact_get_property($_POST ['receiver'], 'email'); $sendto = $object->thirdparty->contact_get_property($_POST['receiver'], 'email');
$sendtoid = $_POST ['receiver']; $sendtoid = $_POST['receiver'];
} }
} }
if (dol_strlen($sendto)) { if (dol_strlen($sendto)) {
$langs->load("commercial"); $langs->load("commercial");
$from = $_POST ['fromname'] . ' <' . $_POST ['frommail'] . '>'; $from = $_POST['fromname'] . ' <' . $_POST['frommail'] . '>';
$replyto = $_POST ['replytoname'] . ' <' . $_POST ['replytomail'] . '>'; $replyto = $_POST['replytoname'] . ' <' . $_POST['replytomail'] . '>';
$message = $_POST ['message']; $message = $_POST['message'];
$sendtocc = $_POST ['sendtocc']; $sendtocc = $_POST['sendtocc'];
$sendtobcc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO); $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'])) if (dol_strlen($_POST['subject']))
$subject = $_POST ['subject']; $subject = $_POST['subject'];
else else
$subject = $langs->transnoentities('Propal') . ' ' . $object->ref; $subject = $langs->transnoentities('Propal') . ' ' . $object->ref;
$actiontypecode = 'AC_PROP'; $actiontypecode = 'AC_PROP';
@ -683,9 +713,9 @@ if ($action == 'modif' && $user->rights->propal->creer)
} }
else if ($action == "setabsolutediscount" && $user->rights->propal->creer) { else if ($action == "setabsolutediscount" && $user->rights->propal->creer) {
if ($_POST ["remise_id"]) { if ($_POST["remise_id"]) {
if ($object->id > 0) { if ($object->id > 0) {
$result = $object->insert_discount($_POST ["remise_id"]); $result = $object->insert_discount($_POST["remise_id"]);
if ($result < 0) { if ($result < 0) {
setEventMessage($object->error, 'errors'); setEventMessage($object->error, 'errors');
} }
@ -723,7 +753,7 @@ else if ($action == 'addline' && $user->rights->propal->creer) {
if (is_array($extralabelsline)) { if (is_array($extralabelsline)) {
// Get extra fields // Get extra fields
foreach ($extralabelsline as $key => $value) { 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); $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
} }
unset($_POST ['prod_entry_mode']); unset($_POST['prod_entry_mode']);
unset($_POST ['qty']); unset($_POST['qty']);
unset($_POST ['type']); unset($_POST['type']);
unset($_POST ['remise_percent']); unset($_POST['remise_percent']);
unset($_POST ['price_ht']); unset($_POST['price_ht']);
unset($_POST ['price_ttc']); unset($_POST['price_ttc']);
unset($_POST ['tva_tx']); unset($_POST['tva_tx']);
unset($_POST ['product_ref']); unset($_POST['product_ref']);
unset($_POST ['product_label']); unset($_POST['product_label']);
unset($_POST ['product_desc']); unset($_POST['product_desc']);
unset($_POST ['fournprice']); unset($_POST['fournprice']);
unset($_POST ['buying_price']); unset($_POST['buying_price']);
unset($_POST ['np_marginRate']); unset($_POST['np_marginRate']);
unset($_POST ['np_markRate']); unset($_POST['np_markRate']);
unset($_POST ['dp_desc']); unset($_POST['dp_desc']);
unset($_POST ['idprod']); unset($_POST['idprod']);
unset($_POST['date_starthour']); unset($_POST['date_starthour']);
unset($_POST['date_startmin']); unset($_POST['date_startmin']);
@ -966,7 +996,7 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa
if (is_array($extralabelsline)) { if (is_array($extralabelsline)) {
// Get extra fields // Get extra fields
foreach ($extralabelsline as $key => $value) { 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); $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
} }
unset($_POST ['qty']); unset($_POST['qty']);
unset($_POST ['type']); unset($_POST['type']);
unset($_POST ['productid']); unset($_POST['productid']);
unset($_POST ['remise_percent']); unset($_POST['remise_percent']);
unset($_POST ['price_ht']); unset($_POST['price_ht']);
unset($_POST ['price_ttc']); unset($_POST['price_ttc']);
unset($_POST ['tva_tx']); unset($_POST['tva_tx']);
unset($_POST ['product_ref']); unset($_POST['product_ref']);
unset($_POST ['product_label']); unset($_POST['product_label']);
unset($_POST ['product_desc']); unset($_POST['product_desc']);
unset($_POST ['fournprice']); unset($_POST['fournprice']);
unset($_POST ['buying_price']); unset($_POST['buying_price']);
} else { } else {
$db->rollback(); $db->rollback();
@ -1091,17 +1121,17 @@ else if ($action == 'remove_file' && $user->rights->propal->creer) {
// Set project // Set project
else if ($action == 'classin' && $user->rights->propal->creer) { else if ($action == 'classin' && $user->rights->propal->creer) {
$object->setProject($_POST ['projectid']); $object->setProject($_POST['projectid']);
} }
// Delai de livraison // Delai de livraison
else if ($action == 'setavailability' && $user->rights->propal->creer) { else if ($action == 'setavailability' && $user->rights->propal->creer) {
$result = $object->availability($_POST ['availability_id']); $result = $object->availability($_POST['availability_id']);
} }
// Origine de la propale // Origine de la propale
else if ($action == 'setdemandreason' && $user->rights->propal->creer) { 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 // Conditions de reglement
@ -1110,11 +1140,11 @@ else if ($action == 'setconditions' && $user->rights->propal->creer) {
} }
else if ($action == 'setremisepercent' && $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) { 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 // Mode de reglement
@ -1206,7 +1236,7 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal->
{ {
if ($object->id > 0) { if ($object->id > 0) {
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $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) { if ($result >= 0) {

View File

@ -1326,67 +1326,77 @@ class Propal extends CommonObject
{ {
$num = $this->ref; $num = $this->ref;
} }
$this->newref = $num;
$sql = "UPDATE ".MAIN_DB_PREFIX."propal"; $sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql.= " SET ref = '".$num."',"; $sql.= " SET ref = '".$num."',";
$sql.= " fk_statut = 1, date_valid='".$this->db->idate($now)."', fk_user_valid=".$user->id; $sql.= " fk_statut = 1, date_valid='".$this->db->idate($now)."', fk_user_valid=".$user->id;
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
dol_syslog(get_class($this).'::valid', LOG_DEBUG); dol_syslog(get_class($this)."::valid", LOG_DEBUG);
if ($this->db->query($sql)) $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) $this->oldref = $this->ref;
{
// Call trigger
$result=$this->call_trigger('PROPAL_VALIDATE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error) // Rename directory if dir was a temporary ref
{ if (preg_match('/^[\(]?PROV/i', $this->ref))
// 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
// Rename of propal directory ($this->ref = old ref, $num = new ref) $oldref = dol_sanitizeFileName($this->ref);
// to not lose the linked files $newref = dol_sanitizeFileName($num);
$oldref = dol_sanitizeFileName($this->ref); $dirsource = $conf->propal->dir_output.'/'.$oldref;
$newref = dol_sanitizeFileName($num); $dirdest = $conf->propal->dir_output.'/'.$newref;
$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);
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"); $this->ref=$num;
// Deleting old PDF in new rep $this->brouillon=0;
dol_delete_file($conf->propal->dir_output.'/'.$newref.'/'.$oldref.'*.*'); $this->statut = 1;
} $this->user_valid_id=$user->id;
} $this->datev=$now;
}
$this->ref=$num; $this->db->commit();
$this->brouillon=0; return 1;
$this->statut = 1;
$this->user_valid_id=$user->id;
$this->datev=$now;
$this->db->commit();
return 1;
}
else
{
$this->db->rollback();
return -2;
}
} }
else else
{ {
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
@ -908,20 +908,23 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->co
if (! $error) { if (! $error) {
$result = $object->valid($user, $idwarehouse); $result = $object->valid($user, $idwarehouse);
if ($result >= 0) { if ($result >= 0)
{
// Define output language // Define output language
$outputlangs = $langs; if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
$newlang = ''; {
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $outputlangs = $langs;
$newlang = $_REQUEST['lang_id']; $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
$newlang = $object->thirdparty->default_lang; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) { if (! empty($newlang)) {
$outputlangs = new Translate("", $conf); $outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $model=$object->modelpdf;
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); 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) { if (! $error) {
$result = $object->set_draft($user, $idwarehouse); $result = $object->set_draft($user, $idwarehouse);
if ($result >= 0) { if ($result >= 0)
{
// Define output language // Define output language
$outputlangs = $langs; if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
$newlang = ''; {
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $outputlangs = $langs;
$newlang = $_REQUEST['lang_id']; $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
$newlang = $object->thirdparty->default_lang; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) { if (! empty($newlang)) {
$outputlangs = new Translate("", $conf); $outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $model=$object->modelpdf;
$ret = $object->fetch($object->id); // Reload to get new records if (empty($model)) { $tmp=getListOfModels($db, 'order'); $keys=array_keys($tmp); $model=$keys[0]; }
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); $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 * Add file in email form
*/ */
if (GETPOST('addfile')) { if (GETPOST('addfile')) {
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
@ -1162,7 +1167,7 @@ if (GETPOST('addfile')) {
/* /*
* Remove file in email form * Remove file in email form
*/ */
if (GETPOST('removedfile')) { if (GETPOST('removedfile')) {
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
@ -1177,7 +1182,7 @@ if (GETPOST('removedfile')) {
/* /*
* Send mail * Send mail
*/ */
if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! GETPOST('cancel')) { if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! GETPOST('cancel')) {
$langs->load('mails'); $langs->load('mails');

View File

@ -183,9 +183,10 @@ class Commande extends CommonOrder
* *
* @param User $user User making status change * @param User $user User making status change
* @param int $idwarehouse Id of warehouse to use for stock decrease * @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 * @return int <=0 if OK, >0 if KO
*/ */
function valid($user, $idwarehouse=0) function valid($user, $idwarehouse=0, $notrigger=0)
{ {
global $conf,$langs; global $conf,$langs;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -223,9 +224,10 @@ class Commande extends CommonOrder
$num = $this->getNextNumRef($soc); $num = $this->getNextNumRef($soc);
} }
else else
{ {
$num = $this->ref; $num = $this->ref;
} }
$this->newref = $num;
// Validate // Validate
$sql = "UPDATE ".MAIN_DB_PREFIX."commande"; $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) if (! $error)
{ {
$this->oldref=''; $this->oldref = $this->ref;
// Rename directory if dir was a temporary ref // Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->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 // in order not to lose the attachments
$comref = dol_sanitizeFileName($this->ref); $oldref = dol_sanitizeFileName($this->ref);
$snum = dol_sanitizeFileName($num); $newref = dol_sanitizeFileName($num);
$dirsource = $conf->commande->dir_output.'/'.$comref; $dirsource = $conf->commande->dir_output.'/'.$oldref;
$dirdest = $conf->commande->dir_output.'/'.$snum; $dirdest = $conf->commande->dir_output.'/'.$newref;
if (file_exists($dirsource)) if (file_exists($dirsource))
{ {
dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest); dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest);
if (@rename($dirsource, $dirdest)) if (@rename($dirsource, $dirdest))
{ {
$this->oldref = $comref;
dol_syslog("Rename ok"); dol_syslog("Rename ok");
// Suppression ancien fichier PDF dans nouveau rep // Rename docs starting with $oldref with $newref
dol_delete_file($conf->commande->dir_output.'/'.$snum.'/'.$comref.'*.*'); $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 // Set new ref and current status
if (! $error) if (! $error)
{ {
@ -323,7 +331,7 @@ class Commande extends CommonOrder
return 1; return 1;
} }
else else
{ {
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
@ -904,7 +912,7 @@ class Commande extends CommonOrder
$modCommande = new $obj; $modCommande = new $obj;
$this->ref = $modCommande->getNextValue($objsoc,$this); $this->ref = $modCommande->getNextValue($objsoc,$this);
// Create clone // Create clone
$result=$this->create($user); $result=$this->create($user);
if ($result < 0) $error++; if ($result < 0) $error++;

View File

@ -45,7 +45,7 @@ class DeplacementStats extends Stats
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
* @param int $socid Id third party * @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 * @return void
*/ */
function __construct($db, $socid=0, $userid=0) function __construct($db, $socid=0, $userid=0)
@ -66,7 +66,8 @@ class DeplacementStats extends Stats
{ {
$this->where.=" AND fk_soc = ".$this->socid; $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;
} }

View File

@ -54,6 +54,9 @@ $limit = $conf->liste_limit;
$tripandexpense_static=new Deplacement($db); $tripandexpense_static=new Deplacement($db);
$childids = $user->getAllChildIds();
$childids[]=$user->id;
//$help_url='EN:Module_Donations|FR:Module_Dons|ES:M&oacute;dulo_Donaciones'; //$help_url='EN:Module_Donations|FR:Module_Dons|ES:M&oacute;dulo_Donaciones';
$help_url=''; $help_url='';
llxHeader('',$langs->trans("ListOfFees"),$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 = "SELECT count(d.rowid) as nb, sum(d.km) as km, d.type";
$sql.= " FROM ".MAIN_DB_PREFIX."deplacement as d"; $sql.= " FROM ".MAIN_DB_PREFIX."deplacement as d";
$sql.= " WHERE d.entity = ".$conf->entity; $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.= " GROUP BY d.type";
$sql.= " ORDER 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"; 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.= " WHERE u.rowid = d.fk_user";
$sql.= " AND d.entity = ".$conf->entity; $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 (!$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; if ($socid) $sql.= " AND d.fk_soc = ".$socid;
$sql.= $db->order("d.tms","DESC"); $sql.= $db->order("d.tms","DESC");

View File

@ -58,6 +58,9 @@ $search_ref=GETPOST('search_ref','alpha');
$tripandexpense_static=new Deplacement($db); $tripandexpense_static=new Deplacement($db);
$userstatic = new User($db); $userstatic = new User($db);
$childids = $user->getAllChildIds();
$childids[]=$user->id;
llxHeader(); llxHeader();
$sql = "SELECT s.nom, s.rowid as socid,"; // Ou $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"; 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.= " WHERE d.fk_user = u.rowid";
$sql.= " AND d.entity = ".$conf->entity; $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 (!$user->rights->societe->client->voir && !$socid) $sql.= " AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND s.rowid = ".$socid; if ($socid) $sql.= " AND s.rowid = ".$socid;
if (trim($search_ref) != '') if (trim($search_ref) != '')
@ -167,6 +171,7 @@ else
{ {
dol_print_error($db); dol_print_error($db);
} }
$db->close();
llxFooter(); llxFooter();
$db->close();

View File

@ -45,6 +45,18 @@ if ($user->societe_id > 0)
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'deplacement', $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()); $nowyear=strftime("%Y", dol_now());
$year = GETPOST('year')>0?GETPOST('year'):$nowyear; $year = GETPOST('year')>0?GETPOST('year'):$nowyear;
//$startyear=$year-2; //$startyear=$year-2;
@ -60,6 +72,7 @@ $mode=GETPOST("mode")?GETPOST("mode"):'customer';
$form=new Form($db); $form=new Form($db);
llxHeader(); llxHeader();
$title=$langs->trans("TripsAndExpensesStatistics"); $title=$langs->trans("TripsAndExpensesStatistics");
@ -69,7 +82,14 @@ print_fiche_titre($title, $mesg);
dol_mkdir($dir); 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 // Build graphic number of object
@ -220,7 +240,9 @@ print $form->select_company($socid,'socid',$filter,1,1);
print '</td></tr>'; print '</td></tr>';
// User // User
print '<tr><td>'.$langs->trans("User").'</td><td>'; print '<tr><td>'.$langs->trans("User").'</td><td>';
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 '</td></tr>'; print '</td></tr>';
// Year // Year
print '<tr><td>'.$langs->trans("Year").'</td><td>'; print '<tr><td>'.$langs->trans("Year").'</td><td>';

View File

@ -406,21 +406,25 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->factu
if ($result >= 0) if ($result >= 0)
{ {
// Define output language // Define output language
$outputlangs = $langs; if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
$newlang = ''; {
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $outputlangs = $langs;
$newlang = $_REQUEST['lang_id']; $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
$newlang = $object->thirdparty->default_lang; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) { if (! empty($newlang)) {
$outputlangs = new Translate("", $conf); $outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $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 $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'); if (count($object->errors)) setEventMessage($object->errors, 'errors');
else setEventMessage($object->error, '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); $result=$object->set_draft($user, $idwarehouse);
if ($result<0) setEventMessage($object->error,'errors'); if ($result<0) setEventMessage($object->error,'errors');
// Define output language // Define output language
$outputlangs = $langs; if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
$newlang = ''; {
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $outputlangs = $langs;
$newlang = $_REQUEST['lang_id']; $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
$newlang = $object->thirdparty->default_lang; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) { if (! empty($newlang)) {
$outputlangs = new Translate("", $conf); $outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $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 $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'); setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors');
$error ++; $error ++;
} }
if ($qty < 0) {
$langs->load("errors");
setEventMessage($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), 'errors');
$error ++;
}
if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) {
$ret = $object->fetch($id); $ret = $object->fetch($id);
if ($ret < 0) { if ($ret < 0) {
@ -1304,23 +1314,26 @@ else if ($action == 'addline' && $user->rights->facture->creer)
// Insert line // 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); $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 ($result > 0)
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { {
// Define output language // Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs; $outputlangs = $langs;
$newlang = GETPOST('lang_id', 'alpha'); $newlang = '';
if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
$newlang = $object->thirdparty->default_lang; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) { if (! empty($newlang)) {
$outputlangs = new Translate("", $conf); $outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang); $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 $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['qty']);
unset($_POST['type']); unset($_POST['type']);
@ -1359,9 +1372,9 @@ else if ($action == 'addline' && $user->rights->facture->creer)
} }
} }
elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('cancel')) { elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('cancel'))
if (! $object->fetch($id) > 0) {
dol_print_error($db); if (! $object->fetch($id) > 0) dol_print_error($db);
$object->fetch_thirdparty(); $object->fetch_thirdparty();
// Clean parameters // Clean parameters
@ -1372,6 +1385,7 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('
$description = dol_htmlcleanlastbr(GETPOST('product_desc')); $description = dol_htmlcleanlastbr(GETPOST('product_desc'));
$pu_ht = GETPOST('price_ht'); $pu_ht = GETPOST('price_ht');
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
$qty = GETPOST('qty');
// Define info_bits // Define info_bits
$info_bits = 0; $info_bits = 0;
@ -1428,10 +1442,15 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('
$error ++; $error ++;
} }
} }
if ($qty < 0) {
$langs->load("errors");
setEventMessage($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), 'errors');
$error ++;
}
// Update line // Update line
if (! $error) { 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 ($result >= 0) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { 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['product_desc']);
unset($_POST['fournprice']); unset($_POST['fournprice']);
unset($_POST['buying_price']); unset($_POST['buying_price']);
unset($_POST['np_marginRate']);
unset($_POST['np_markRate']);
} else { } else {
setEventMessage($object->error, 'errors'); setEventMessage($object->error, 'errors');
} }
@ -3579,21 +3600,24 @@ if ($action == 'create')
// Linked object block // Linked object block
$somethingshown = $object->showLinkedObjectBlock(); $somethingshown = $object->showLinkedObjectBlock();
if (empty($somethingshown) && ! empty($conf->commande->enabled)) $linktoelem='';
if (! empty($conf->commande->enabled))
{ {
print '<br><a href="#" id="linktoorder">' . $langs->trans('LinkedOrder') . '</a>'; $linktoelem.=($linktoelem?' &nbsp; ':'').'<a href="#" id="linktoorder">' . $langs->trans('LinkedOrder') . '</a>';
print ' print '
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
jQuery(document).ready(function() { jQuery(document).ready(function() {
jQuery("#linktoorder").click(function() { jQuery("#linktoorder").click(function() {
jQuery("#commande").toggle(); jQuery("#orderlist").toggle();
jQuery("#linktoorder").toggle();
}); });
}); });
</script> </script>
'; ';
print '<div id="commande" style="display:none">'; print '<div id="orderlist" style="display:none">';
$sql = "SELECT s.rowid as socid, s.nom as name, s.client, c.rowid, c.ref, c.ref_client, c.total_ht"; $sql = "SELECT s.rowid as socid, s.nom as name, s.client, c.rowid, c.ref, c.ref_client, c.total_ht";
$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
@ -3601,11 +3625,12 @@ if ($action == 'create')
$sql .= ' WHERE c.fk_soc = s.rowid AND c.fk_soc = ' . $soc->id . ''; $sql .= ' WHERE c.fk_soc = s.rowid AND c.fk_soc = ' . $soc->id . '';
$resqlorderlist = $db->query($sql); $resqlorderlist = $db->query($sql);
if ($resqlorderlist) { if ($resqlorderlist)
{
$num = $db->num_rows($resqlorderlist); $num = $db->num_rows($resqlorderlist);
$i = 0; $i = 0;
print '<form action="" method="POST" name="LinkedOrder">'; print '<br><form action="" method="POST" name="LinkedOrder">';
print '<table class="noborder">'; print '<table class="noborder">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="nowrap"></td>'; print '<td class="nowrap"></td>';
@ -3614,7 +3639,8 @@ if ($action == 'create')
print '<td align="left">' . $langs->trans("AmountHTShort") . '</td>'; print '<td align="left">' . $langs->trans("AmountHTShort") . '</td>';
print '<td align="left">' . $langs->trans("Company") . '</td>'; print '<td align="left">' . $langs->trans("Company") . '</td>';
print '</tr>'; print '</tr>';
while ($i < $num) { while ($i < $num)
{
$objp = $db->fetch_object($resqlorderlist); $objp = $db->fetch_object($resqlorderlist);
if ($objp->socid == $soc->id) { if ($objp->socid == $soc->id) {
$var = ! $var; $var = ! $var;
@ -3632,7 +3658,7 @@ if ($action == 'create')
$i ++; $i ++;
} }
print '</table>'; print '</table>';
print '<br><center><input type="submit" class="button" value="' . $langs->trans('ToLink') . '"></center>'; print '<br><center><input type="submit" class="button" value="' . $langs->trans('ToLink') . '"> &nbsp; <input type="submit" class="button" name="cancel" value="' . $langs->trans('Cancel') . '"></center>';
print '</form>'; print '</form>';
$db->free($resqlorderlist); $db->free($resqlorderlist);
} else { } else {
@ -3642,6 +3668,9 @@ if ($action == 'create')
print '</div>'; print '</div>';
} }
// Show link to elements
if ($linktoelem) print '<br>'.$linktoelem;
// Link for paypal payment // Link for paypal payment
if (! empty($conf->paypal->enabled) && $object->statut != 0) { if (! empty($conf->paypal->enabled) && $object->statut != 0) {
include_once DOL_DOCUMENT_ROOT . '/paypal/lib/paypal.lib.php'; include_once DOL_DOCUMENT_ROOT . '/paypal/lib/paypal.lib.php';

View File

@ -1589,9 +1589,10 @@ class Facture extends CommonInvoice
* @param User $user Object user that validate * @param User $user Object user that validate
* @param string $force_number Reference to force on invoice * @param string $force_number Reference to force on invoice
* @param int $idwarehouse Id of warehouse to use for stock decrease * @param int $idwarehouse Id of warehouse to use for stock decrease
* @return int <0 if KO, >0 if OK * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK
*/ */
function validate($user, $force_number='', $idwarehouse=0) function validate($user, $force_number='', $idwarehouse=0, $notrigger=0)
{ {
global $conf,$langs; global $conf,$langs;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -1679,6 +1680,7 @@ class Facture extends CommonInvoice
{ {
$num = $this->ref; $num = $this->ref;
} }
$this->newref = $num;
if ($num) if ($num)
{ {
@ -1738,45 +1740,50 @@ class Facture extends CommonInvoice
} }
} }
// Trigger calls
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('BILL_VALIDATE',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error) if (! $error)
{ {
$this->oldref = ''; $this->oldref = $this->ref;
// Rename directory if dir was a temporary ref // Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref)) if (preg_match('/^[\(]?PROV/i', $this->ref))
{ {
// Rename of object directory ($this->ref = old ref, $num = new ref) // Rename of object directory ($this->ref = old ref, $num = new ref)
// to not lose the linked files // to not lose the linked files
$facref = dol_sanitizeFileName($this->ref); $oldref = dol_sanitizeFileName($this->ref);
$snumfa = dol_sanitizeFileName($num); $newref = dol_sanitizeFileName($num);
$dirsource = $conf->facture->dir_output.'/'.$facref; $dirsource = $conf->facture->dir_output.'/'.$oldref;
$dirdest = $conf->facture->dir_output.'/'.$snumfa; $dirdest = $conf->facture->dir_output.'/'.$newref;
if (file_exists($dirsource)) if (file_exists($dirsource))
{ {
dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest);
if (@rename($dirsource, $dirdest)) if (@rename($dirsource, $dirdest))
{ {
$this->oldref = $facref;
dol_syslog("Rename ok"); dol_syslog("Rename ok");
// Suppression ancien fichier PDF dans nouveau rep // Rename docs starting with $oldref with $newref
dol_delete_file($conf->facture->dir_output.'/'.$snumfa.'/'.$facref.'*.*'); $listoffiles=dol_dir_list($conf->facture->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);
}
} }
} }
} }
} }
// Trigger calls
if (! $error)
{
// Call trigger
$result=$this->call_trigger('BILL_VALIDATE',$user);
if ($result < 0) $error++;
//TODO: Restoring ref, facnumber, statut, brouillon to previous value if trigger fail
// End call triggers
}
// Set new ref and define current statut // Set new ref and define current statut
if (! $error) if (! $error)
{ {

View File

@ -60,6 +60,8 @@ if ($user->societe_id > 0) accessforbidden();
$holiday = new Holiday($db); $holiday = new Holiday($db);
$holidaystatic=new Holiday($db); $holidaystatic=new Holiday($db);
$childids = $user->getAllChildIds();
$childids[]=$user->id;
llxHeader(array(),$langs->trans('HRMArea')); llxHeader(array(),$langs->trans('HRMArea'));
@ -118,6 +120,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"; 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.= " WHERE u.rowid = d.fk_user";
$sql.= " AND d.entity = ".$conf->entity; $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 (!$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 (!empty($socid)) $sql.= " AND d.fk_soc = ".$socid; if (!empty($socid)) $sql.= " AND d.fk_soc = ".$socid;
$sql.= $db->order("d.tms","DESC"); $sql.= $db->order("d.tms","DESC");

View File

@ -112,8 +112,8 @@ if ($resql)
print '</tr>'; print '</tr>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="GET">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="GET">';
print '<td class="liste_titre"><input type="text" class="flat" name="search_facture" size="12" value="'.GETPOST('search_facture','alpha').'"></td>'; print '<td class="liste_titre"><input type="text" class="flat" name="search_facture" size="12" value="'.dol_escape_htmltag(GETPOST('search_facture','alpha')).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat" name="search_societe" size="18" value="'.GETPOST('search_societe','alpha').'"></td>'; print '<td class="liste_titre"><input type="text" class="flat" name="search_societe" size="18" value="'.dol_escape_htmltag(GETPOST('search_societe','alpha')).'"></td>';
print '<td colspan="2" class="liste_titre" align="right"><input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'"></td>'; print '<td colspan="2" class="liste_titre" align="right"><input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'"></td>';
print '</tr>'; print '</tr>';
print '</form>'; print '</form>';

View File

@ -122,11 +122,11 @@ if ($result)
print '<form action="list.php" method="GET">'; print '<form action="list.php" method="GET">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="liste_titre"><input type="text" class="flat" name="search_ligne" value="'. $search_line.'" size="6"></td>'; print '<td class="liste_titre"><input type="text" class="flat" name="search_ligne" value="'. dol_escape_htmltag($search_line).'" size="6"></td>';
print '<td class="liste_titre"><input type="text" class="flat" name="search_bon" value="'. $search_bon.'" size="8"></td>'; print '<td class="liste_titre"><input type="text" class="flat" name="search_bon" value="'. dol_escape_htmltag($search_bon).'" size="8"></td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '<td class="liste_titre"><input type="text" class="flat" name="search_societe" value="'. $search_societe.'" size="12"></td>'; print '<td class="liste_titre"><input type="text" class="flat" name="search_societe" value="'. dol_escape_htmltag($search_societe).'" size="12"></td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat" name="search_code" value="'. $search_code.'" size="8"></td>'; print '<td class="liste_titre" align="center"><input type="text" class="flat" name="search_code" value="'. dol_escape_htmltag($search_code).'" size="8"></td>';
print '<td class="liste_titre">&nbsp;</td>'; print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>'; print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="right"><input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'"></td>'; print '<td class="liste_titre" align="right"><input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'"></td>';

View File

@ -525,23 +525,22 @@ else if ($action == 'addline' && $user->rights->contrat->creer)
if ($result > 0) if ($result > 0)
{ {
/* // Define output language
// Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
$outputlangs = $langs; {
$newlang=''; $outputlangs = $langs;
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if (! empty($newlang)) if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
{ if (! empty($newlang)) {
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) $model=$object->modelpdf;
{ if (empty($model)) { $tmp=getListOfModels($db, 'contract'); $keys=array_keys($tmp); $model=$keys[0]; }
$ret=$object->fetch($id); // Reload to get new records $ret = $object->fetch($id); // Reload to get new records
contrat_pdf_create($db, $object->id, $object->modelpdf, $outputlangs); $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
} }
*/
unset($_POST ['prod_entry_mode']); unset($_POST ['prod_entry_mode']);

View File

@ -278,9 +278,10 @@ class Contrat extends CommonObject
* *
* @param User $user Objet User * @param User $user Objet User
* @param string $force_number Reference to force on contract (not implemented yet) * @param string $force_number Reference to force on contract (not implemented yet)
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function validate($user, $force_number='') function validate($user, $force_number='', $notrigger=0)
{ {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
global $langs, $conf; global $langs, $conf;
@ -307,6 +308,7 @@ class Contrat extends CommonObject
{ {
$num = $this->ref; $num = $this->ref;
} }
$this->newref = $num;
if ($num) if ($num)
{ {
@ -323,30 +325,45 @@ class Contrat extends CommonObject
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
} }
// Trigger calls
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('CONTRACT_VALIDATE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error) if (! $error)
{ {
$this->oldref = ''; $this->oldref = $this->ref;
// Rename directory if dir was a temporary ref // Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref)) if (preg_match('/^[\(]?PROV/i', $this->ref))
{ {
// Rename of object directory ($this->ref = old ref, $num = new ref) // Rename of object directory ($this->ref = old ref, $num = new ref)
// to not lose the linked files // to not lose the linked files
$facref = dol_sanitizeFileName($this->ref); $oldref = dol_sanitizeFileName($this->ref);
$snumfa = dol_sanitizeFileName($num); $newref = dol_sanitizeFileName($num);
$dirsource = $conf->contract->dir_output.'/'.$facref; $dirsource = $conf->contract->dir_output.'/'.$oldref;
$dirdest = $conf->contract->dir_output.'/'.$snumfa; $dirdest = $conf->contract->dir_output.'/'.$newref;
if (file_exists($dirsource)) if (file_exists($dirsource))
{ {
dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest);
if (@rename($dirsource, $dirdest)) if (@rename($dirsource, $dirdest))
{ {
$this->oldref = $facref;
dol_syslog("Rename ok"); dol_syslog("Rename ok");
// Deleting old PDF in new rep // Rename docs starting with $oldref with $newref
dol_delete_file($conf->contract->dir_output.'/'.$snumfa.'/'.$facref.'*.*'); $listoffiles=dol_dir_list($conf->contract->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);
}
} }
} }
} }
@ -360,15 +377,6 @@ class Contrat extends CommonObject
$this->brouillon=0; $this->brouillon=0;
$this->date_validation=$now; $this->date_validation=$now;
} }
// Trigger calls
if (! $error)
{
// Call trigger
$result=$this->call_trigger('CONTRACT_VALIDATE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
} }
else else
{ {

View File

@ -58,22 +58,25 @@ class box_commandes extends ModeleBoxes
include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$commandestatic=new Commande($db); $commandestatic=new Commande($db);
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastCustomerOrders",$max)); $userstatic = new User($db);
$this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."CustomerOrders",$max));
if ($user->rights->commande->lire) if ($user->rights->commande->lire)
{ {
$sql = "SELECT s.nom as name, s.rowid as socid,"; $sql = "SELECT s.nom as name, s.rowid as socid,";
$sql.= " c.ref, c.tms, c.rowid,"; $sql.= " c.ref, c.tms, c.rowid, c.date_commande,";
$sql.= " c.fk_statut, c.facture"; $sql.= " c.fk_statut, c.fk_user_valid, c.facture, c.total_ht";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."commande as c"; $sql.= ", ".MAIN_DB_PREFIX."commande as c";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.rowid"; $sql.= " WHERE c.fk_soc = s.rowid";
$sql.= " AND c.entity = ".$conf->entity; $sql.= " AND c.entity = ".$conf->entity;
if (! empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) $sql.=" AND c.fk_statut = 1";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
$sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC ";
else $sql.= " ORDER BY c.tms DESC, c.ref DESC ";
$sql.= $db->plimit($max, 0); $sql.= $db->plimit($max, 0);
$result = $db->query($sql); $result = $db->query($sql);
@ -86,29 +89,43 @@ class box_commandes extends ModeleBoxes
while ($i < $num) while ($i < $num)
{ {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$date=$db->jdate($objp->date_commande);
$datem=$db->jdate($objp->tms); $datem=$db->jdate($objp->tms);
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', $this->info_box_contents[$i][] = array('td' => 'align="left" width="16"',
'logo' => $this->boximg, 'logo' => $this->boximg,
'url' => DOL_URL_ROOT."/commande/card.php?id=".$objp->rowid); 'url' => DOL_URL_ROOT."/commande/card.php?id=".$objp->rowid);
$this->info_box_contents[$i][1] = array('td' => 'align="left"', $this->info_box_contents[$i][] = array('td' => 'align="left"',
'text' => $objp->ref, 'text' => $objp->ref,
'url' => DOL_URL_ROOT."/commande/card.php?id=".$objp->rowid); 'url' => DOL_URL_ROOT."/commande/card.php?id=".$objp->rowid);
$this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', $this->info_box_contents[$i][] = array('td' => 'align="left" width="16"',
'logo' => 'company', 'logo' => 'company',
'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid);
$this->info_box_contents[$i][3] = array('td' => 'align="left"', $this->info_box_contents[$i][] = array('td' => 'align="left"',
'text' => $objp->name, 'text' => $objp->name,
'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid);
$this->info_box_contents[$i][4] = array('td' => 'align="right"', $this->info_box_contents[$i][] = array('td' => 'align="right"',
'text' => dol_print_date($datem,'day'), 'text' => price($objp->total_ht),
);
if (! empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER))
{
if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid);
$this->info_box_contents[$i][] = array('td' => 'align="right"',
'text' => (($objp->fk_user_valid > 0)?$userstatic->getNomUrl(1):''),
'url' => (($objp->fk_user_valid > 0)?DOL_URL_ROOT.'/user/card.php?id='.$objp->fk_user_valid:'')
);
}
$this->info_box_contents[$i][] = array('td' => 'align="right"',
'text' => dol_print_date($date,'day'),
); );
$this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"', $this->info_box_contents[$i][] = array('td' => 'align="right" width="18"',
'text' => $commandestatic->LibStatut($objp->fk_statut,$objp->facture,3)); 'text' => $commandestatic->LibStatut($objp->fk_statut,$objp->facture,3));
$i++; $i++;

View File

@ -56,7 +56,7 @@ class box_factures extends ModeleBoxes
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$facturestatic=new Facture($db); $facturestatic=new Facture($db);
$text = $langs->trans("BoxTitleLastCustomerBills",$max); $text = $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."CustomerBills",$max);
$this->info_box_head = array( $this->info_box_head = array(
'text' => $text, 'text' => $text,
'limit'=> dol_strlen($text) 'limit'=> dol_strlen($text)
@ -64,7 +64,7 @@ class box_factures extends ModeleBoxes
if ($user->rights->facture->lire) if ($user->rights->facture->lire)
{ {
$sql = "SELECT f.rowid as facid, f.facnumber, f.type, f.amount, f.datef as df"; $sql = "SELECT f.rowid as facid, f.facnumber, f.type, f.total as total_ht, f.datef as df";
$sql.= ", f.paye, f.fk_statut, f.datec, f.tms"; $sql.= ", f.paye, f.fk_statut, f.datec, f.tms";
$sql.= ", s.nom as name, s.rowid as socid"; $sql.= ", s.nom as name, s.rowid as socid";
$sql.= ", f.date_lim_reglement as datelimite"; $sql.= ", f.date_lim_reglement as datelimite";
@ -75,7 +75,8 @@ class box_factures extends ModeleBoxes
$sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
$sql.= " ORDER BY f.tms DESC"; if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.facnumber DESC ";
else $sql.= " ORDER BY f.tms DESC, f.facnumber DESC ";
$sql.= $db->plimit($max, 0); $sql.= $db->plimit($max, 0);
$result = $db->query($sql); $result = $db->query($sql);
@ -91,7 +92,8 @@ class box_factures extends ModeleBoxes
{ {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$datelimite=$db->jdate($objp->datelimite); $datelimite=$db->jdate($objp->datelimite);
$datec=$db->jdate($objp->datec); $date=$db->jdate($objp->df);
$datem=$db->jdate($objp->tms);
$picto='bill'; $picto='bill';
if ($objp->type == 1) $picto.='r'; if ($objp->type == 1) $picto.='r';
@ -118,10 +120,14 @@ class box_factures extends ModeleBoxes
'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid);
$this->info_box_contents[$i][4] = array('td' => 'align="right"', $this->info_box_contents[$i][4] = array('td' => 'align="right"',
'text' => dol_print_date($datec,'day'), 'text' => price($objp->total_ht),
); );
$this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"', $this->info_box_contents[$i][5] = array('td' => 'align="right"',
'text' => dol_print_date($date,'day'),
);
$this->info_box_contents[$i][6] = array('td' => 'align="right" width="18"',
'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3)); 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3));
$i++; $i++;

View File

@ -58,13 +58,13 @@ class box_factures_fourn extends ModeleBoxes
$facturestatic=new FactureFournisseur($db); $facturestatic=new FactureFournisseur($db);
$this->info_box_head = array( $this->info_box_head = array(
'text' => $langs->trans("BoxTitleLastSupplierBills",$max) 'text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."SupplierBills",$max)
); );
if ($user->rights->fournisseur->facture->lire) if ($user->rights->fournisseur->facture->lire)
{ {
$sql = "SELECT s.nom as name, s.rowid as socid,"; $sql = "SELECT s.nom as name, s.rowid as socid,";
$sql.= " f.rowid as facid, f.ref, f.ref_supplier, f.amount,"; $sql.= " f.rowid as facid, f.ref, f.ref_supplier, f.total_ht,";
$sql.= " f.paye, f.fk_statut,"; $sql.= " f.paye, f.fk_statut,";
$sql.= ' f.datef as df,'; $sql.= ' f.datef as df,';
$sql.= ' f.datec as datec,'; $sql.= ' f.datec as datec,';
@ -76,7 +76,8 @@ class box_factures_fourn extends ModeleBoxes
$sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
$sql.= " ORDER BY f.tms DESC"; if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.ref DESC ";
else $sql.= " ORDER BY f.tms DESC, f.ref DESC ";
$sql.= $db->plimit($max, 0); $sql.= $db->plimit($max, 0);
$result = $db->query($sql); $result = $db->query($sql);
@ -92,7 +93,8 @@ class box_factures_fourn extends ModeleBoxes
{ {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$datelimite=$db->jdate($objp->datelimite); $datelimite=$db->jdate($objp->datelimite);
$datec=$db->jdate($objp->datec); $date=$db->jdate($objp->df);
$datem=$db->jdate($objp->tms);
$late = ''; $late = '';
if ($objp->paye == 0 && $datelimite && $datelimite < ($now - $conf->facture->fournisseur->warning_delay)) $late=img_warning(sprintf($l_due_date, dol_print_date($datelimite,'day'))); if ($objp->paye == 0 && $datelimite && $datelimite < ($now - $conf->facture->fournisseur->warning_delay)) $late=img_warning(sprintf($l_due_date, dol_print_date($datelimite,'day')));
@ -119,7 +121,7 @@ class box_factures_fourn extends ModeleBoxes
'url' => DOL_URL_ROOT."/fourn/card.php?socid=".$objp->socid); 'url' => DOL_URL_ROOT."/fourn/card.php?socid=".$objp->socid);
$this->info_box_contents[$i][5] = array('td' => 'align="right"', $this->info_box_contents[$i][5] = array('td' => 'align="right"',
'text' => dol_print_date($datec,'day')); 'text' => dol_print_date($date,'day'));
$fac = new FactureFournisseur($db); $fac = new FactureFournisseur($db);
$fac->fetch($objp->facid); $fac->fetch($objp->facid);

View File

@ -67,15 +67,12 @@ class box_ficheinter extends ModeleBoxes
$sql.= " f.tms as datem,"; $sql.= " f.tms as datem,";
$sql.= " s.nom as name, s.rowid as socid, s.client"; $sql.= " s.nom as name, s.rowid as socid, s.client";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
if (! $user->rights->societe->client->voir) if (! $user->rights->societe->client->voir) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ", ".MAIN_DB_PREFIX."fichinter as f"; $sql.= ", ".MAIN_DB_PREFIX."fichinter as f";
$sql.= " WHERE f.fk_soc = s.rowid "; $sql.= " WHERE f.fk_soc = s.rowid ";
$sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.entity = ".$conf->entity;
if (! $user->rights->societe->client->voir && !$user->societe_id) if (! $user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
$sql.= " ORDER BY f.tms DESC"; $sql.= " ORDER BY f.tms DESC";
$sql.= $db->plimit($max, 0); $sql.= $db->plimit($max, 0);

View File

@ -56,84 +56,93 @@ class box_propales extends ModeleBoxes
$this->max=$max; $this->max=$max;
include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$propalstatic=new Propal($db); $propalstatic=new Propal($db);
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastPropals",$max)); $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."Propals",$max));
if ($user->rights->propale->lire) if ($user->rights->propale->lire)
{ {
$sql = "SELECT s.nom as name, s.rowid as socid,"; $sql = "SELECT s.nom as name, s.rowid as socid,";
$sql.= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture"; $sql.= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tms";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."propal as p"; $sql.= ", ".MAIN_DB_PREFIX."propal as p";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE p.fk_soc = s.rowid"; $sql.= " WHERE p.fk_soc = s.rowid";
$sql.= " AND p.entity = ".$conf->entity; $sql.= " AND p.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
$sql.= " ORDER BY p.datep DESC, p.ref DESC "; if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY p.datep DESC, p.ref DESC ";
$sql.= $db->plimit($max, 0); else $sql.= " ORDER BY p.tms DESC, p.ref DESC ";
$sql.= $db->plimit($max, 0);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
$num = $db->num_rows($result); $num = $db->num_rows($result);
$now=dol_now(); $now=dol_now();
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$datec=$db->jdate($objp->datec); $date=$db->jdate($objp->dp);
$dateterm=$db->jdate($objp->fin_validite); $datec=$db->jdate($objp->datec);
$dateclose=$db->jdate($objp->date_cloture); $datem=$db->jdate($objp->tms);
$dateterm=$db->jdate($objp->fin_validite);
$dateclose=$db->jdate($objp->date_cloture);
$late = ''; $late = '';
if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); } if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) {
$late = img_warning($langs->trans("Late"));
}
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
'logo' => $this->boximg, 'logo' => $this->boximg,
'url' => DOL_URL_ROOT."/comm/propal.php?id=".$objp->rowid); 'url' => DOL_URL_ROOT."/comm/propal.php?id=".$objp->rowid);
$this->info_box_contents[$i][1] = array('td' => 'align="left"', $this->info_box_contents[$i][1] = array('td' => 'align="left"',
'text' => $objp->ref, 'text' => $objp->ref,
'text2'=> $late, 'text2'=> $late,
'url' => DOL_URL_ROOT."/comm/propal.php?id=".$objp->rowid); 'url' => DOL_URL_ROOT."/comm/propal.php?id=".$objp->rowid);
$this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"',
'logo' => 'company', 'logo' => 'company',
'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid);
$this->info_box_contents[$i][3] = array('td' => 'align="left"', $this->info_box_contents[$i][3] = array('td' => 'align="left"',
'text' => dol_trunc($objp->name,40), 'text' => dol_trunc($objp->name,40),
'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid);
$this->info_box_contents[$i][4] = array('td' => 'align="right"', $this->info_box_contents[$i][4] = array('td' => 'align="right"',
'text' => dol_print_date($datec,'day')); 'text' => price($objp->total_ht),
);
$this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"', $this->info_box_contents[$i][5] = array('td' => 'align="right"',
'text' => $propalstatic->LibStatut($objp->fk_statut,3)); 'text' => dol_print_date($date,'day'));
$i++; $this->info_box_contents[$i][6] = array('td' => 'align="right" width="18"',
} 'text' => $propalstatic->LibStatut($objp->fk_statut,3));
if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedProposals")); $i++;
}
$db->free($result); if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedProposals"));
}
else $db->free($result);
{ }
$this->info_box_contents[0][0] = array( 'td' => 'align="left"', else
'maxlength'=>500, {
'text' => ($db->error().' sql='.$sql)); $this->info_box_contents[0][0] = array( 'td' => 'align="left"',
} 'maxlength'=>500,
} 'text' => ($db->error().' sql='.$sql));
else }
{ }
$this->info_box_contents[0][0] = array('td' => 'align="left"', else
'text' => $langs->trans("ReadPermissionNotAllowed")); {
} $this->info_box_contents[0][0] = array('td' => 'align="left"',
'text' => $langs->trans("ReadPermissionNotAllowed"));
}
} }
/** /**

View File

@ -58,12 +58,12 @@ class box_supplier_orders extends ModeleBoxes
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
$supplierorderstatic=new CommandeFournisseur($db); $supplierorderstatic=new CommandeFournisseur($db);
$this->info_box_head = array('text' => $langs->trans("BoxTitleLatestSupplierOrders", $max)); $this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."SupplierOrders", $max));
if ($user->rights->fournisseur->commande->lire) if ($user->rights->fournisseur->commande->lire)
{ {
$sql = "SELECT s.nom as name, s.rowid as socid,"; $sql = "SELECT s.nom as name, s.rowid as socid,";
$sql.= " c.ref, c.tms, c.rowid,"; $sql.= " c.ref, c.tms, c.rowid, c.date_commande,";
$sql.= " c.fk_statut"; $sql.= " c.fk_statut";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c";
@ -72,7 +72,8 @@ class box_supplier_orders extends ModeleBoxes
$sql.= " AND c.entity = ".$conf->entity; $sql.= " AND c.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
$sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC ";
else $sql.= " ORDER BY c.tms DESC, c.ref DESC ";
$sql.= $db->plimit($max, 0); $sql.= $db->plimit($max, 0);
$result = $db->query($sql); $result = $db->query($sql);
@ -84,7 +85,8 @@ class box_supplier_orders extends ModeleBoxes
while ($i < $num) while ($i < $num)
{ {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$datem=$db->jdate($objp->tms); $date=$db->jdate($objp->date_commande);
$datem=$db->jdate($objp->tms);
$urlo = DOL_URL_ROOT."/fourn/commande/card.php?id=".$objp->rowid; $urlo = DOL_URL_ROOT."/fourn/commande/card.php?id=".$objp->rowid;
$urls = DOL_URL_ROOT."/fourn/card.php?socid=".$objp->socid; $urls = DOL_URL_ROOT."/fourn/card.php?socid=".$objp->socid;
@ -106,7 +108,7 @@ class box_supplier_orders extends ModeleBoxes
'url' => $urls); 'url' => $urls);
$this->info_box_contents[$i][4] = array('td' => 'align="right"', $this->info_box_contents[$i][4] = array('td' => 'align="right"',
'text' => dol_print_date($datem,'day'), 'text' => dol_print_date($date,'day'),
); );
$this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"', $this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"',

View File

@ -1145,6 +1145,9 @@ class Form
// If no preselected user defined, we take current user // If no preselected user defined, we take current user
if ((is_numeric($selected) && ($selected < -1 || empty($selected))) && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) $selected=$user->id; if ((is_numeric($selected) && ($selected < -1 || empty($selected))) && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) $selected=$user->id;
$excludeUsers=null;
$includeUsers=null;
// Permettre l'exclusion d'utilisateurs // Permettre l'exclusion d'utilisateurs
if (is_array($exclude)) $excludeUsers = implode("','",$exclude); if (is_array($exclude)) $excludeUsers = implode("','",$exclude);
// Permettre l'inclusion d'utilisateurs // Permettre l'inclusion d'utilisateurs

View File

@ -167,15 +167,15 @@ class FormProjets
} }
/** /**
* Build Select List of element associable to a project * Build a HTML select list of element of same thirdparty to suggest to link them to project
* *
* @param string $table_element Table of the element to update * @param string $table_element Table of the element to update
* @param int $socid socid to filter * @param int $socid socid to filter
* @return string The HTML select list of element * @return string The HTML select list of element
*/ */
function select_element($table_element,$socid=0) function select_element($table_element,$socid=0)
{ {
global $conf; global $conf, $langs;
$projectkey="fk_projet"; $projectkey="fk_projet";
switch ($table_element) switch ($table_element)
@ -184,7 +184,10 @@ class FormProjets
$sql = "SELECT rowid, facnumber as ref"; $sql = "SELECT rowid, facnumber as ref";
break; break;
case "facture_fourn": case "facture_fourn":
$sql = "SELECT rowid, ref"; $sql = "SELECT rowid, ref, ref_supplier";
break;
case "commande_fourn":
$sql = "SELECT rowid, ref, ref_supplier";
break; break;
case "facture_rec": case "facture_rec":
$sql = "SELECT rowid, titre as ref"; $sql = "SELECT rowid, titre as ref";
@ -219,14 +222,22 @@ class FormProjets
while ($i < $num) while ($i < $num)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$sellist .='<option value="'.$obj->rowid.'">'.$obj->ref.'</option>'; $ref=$obj->ref?$obj->ref:$obj->rowid;
if (! empty($obj->ref_supplier)) $ref.=' ('.$obj->ref_supplier.')';
$sellist .='<option value="'.$obj->rowid.'">'.$ref.'</option>';
$i++; $i++;
} }
$sellist .='</select>'; $sellist .='</select>';
} }
return $sellist ; /*else
{
$sellist = '<select class="flat" name="elementselect">';
$sellist.= '<option value="0" disabled="disabled">'.$langs->trans("None").'</option>';
$sellist.= '</select>';
}*/
$this->db->free($resql); $this->db->free($resql);
return $sellist ;
}else { }else {
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
dol_syslog(get_class($this) . "::select_element " . $this->error, LOG_ERR); dol_syslog(get_class($this) . "::select_element " . $this->error, LOG_ERR);

View File

@ -54,7 +54,7 @@ class InfoBox
$boxes=array(); $boxes=array();
$confuserzone='MAIN_BOXES_'.$zone; $confuserzone='MAIN_BOXES_'.$zone;
if ($mode == 'activated') if ($mode == 'activated') // activated
{ {
$sql = "SELECT b.rowid, b.position, b.box_order, b.fk_user,"; $sql = "SELECT b.rowid, b.position, b.box_order, b.fk_user,";
$sql.= " d.rowid as box_id, d.file, d.note, d.tms"; $sql.= " d.rowid as box_id, d.file, d.note, d.tms";
@ -66,18 +66,11 @@ class InfoBox
else $sql.= " AND b.fk_user = 0"; else $sql.= " AND b.fk_user = 0";
$sql.= " ORDER BY b.box_order"; $sql.= " ORDER BY b.box_order";
} }
else else // available
{ {
$sql = "SELECT d.rowid as box_id, d.file, d.note, d.tms"; $sql = "SELECT d.rowid as box_id, d.file, d.note, d.tms";
$sql.= " FROM ".MAIN_DB_PREFIX."boxes_def as d"; $sql.= " FROM ".MAIN_DB_PREFIX."boxes_def as d";
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) $sql.= " WHERE d.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")";
{
$sql.= " WHERE entity IN (1,".$conf->entity.")"; // TODO add method for define another master entity
}
else
{
$sql.= " WHERE entity = ".$conf->entity;
}
} }
dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user)?$user->id:'')."", LOG_DEBUG); dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user)?$user->id:'')."", LOG_DEBUG);
@ -92,6 +85,7 @@ class InfoBox
if (! in_array($obj->box_id, $excludelist)) if (! in_array($obj->box_id, $excludelist))
{ {
if (preg_match('/^([^@]+)@([^@]+)$/i',$obj->file,$regs)) if (preg_match('/^([^@]+)@([^@]+)$/i',$obj->file,$regs))
{ {
$boxname = preg_replace('/\.php$/i','',$regs[1]); $boxname = preg_replace('/\.php$/i','',$regs[1]);
@ -104,9 +98,11 @@ class InfoBox
$relsourcefile = "/core/boxes/".$boxname.".php"; $relsourcefile = "/core/boxes/".$boxname.".php";
} }
//print $obj->box_id.'-'.$boxname.'-'.$relsourcefile.'<br>';
// TODO PERF Do not make "dol_include_once" here, nor "new" later. This means, we must store a 'depends' field to store modules list, then // TODO PERF Do not make "dol_include_once" here, nor "new" later. This means, we must store a 'depends' field to store modules list, then
// the "enabled" condition for modules forbidden for external users and the depends condition can be done. // the "enabled" condition for modules forbidden for external users and the depends condition can be done.
// Goal is to avoid making a new instance for each boxes returned by select. // Goal is to avoid making a "new" done for each boxes returned by select.
dol_include_once($relsourcefile); dol_include_once($relsourcefile);
if (class_exists($boxname)) if (class_exists($boxname))
{ {
@ -161,15 +157,19 @@ class InfoBox
//print 'xx module='.$module.' enabled='.$enabled; //print 'xx module='.$module.' enabled='.$enabled;
if ($enabled) $boxes[]=$box; if ($enabled) $boxes[]=$box;
else unset($box); else unset($box);
} }
else
{
dol_syslog("Failed to load box '".$boxname."' into file '".$relsourcefile."'", LOG_WARNING);
}
} }
$j++; $j++;
} }
} }
else else
{ {
//dol_print_error($db); dol_syslog($db->lasterror(),LOG_ERR);
$error=$db->lasterror(); return array('error'=>$db->lasterror());
} }
return $boxes; return $boxes;

View File

@ -32,6 +32,7 @@ class Notify
var $id; var $id;
var $db; var $db;
var $error; var $error;
var $errors=array();
var $author; var $author;
var $ref; var $ref;
@ -84,34 +85,50 @@ class Notify
{ {
global $conf; global $conf;
$num=-1; $error=0;
$num=0;
$sql = "SELECT n.rowid"; if (! $error)
$sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n,";
$sql.= " ".MAIN_DB_PREFIX."socpeople as c,";
$sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a,";
$sql.= " ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE n.fk_contact = c.rowid";
$sql.= " AND a.rowid = n.fk_action";
$sql.= " AND n.fk_soc = s.rowid";
if (is_numeric($action)) $sql.= " AND n.fk_action = ".$action; // Old usage
else $sql.= " AND a.code = '".$action."'"; // New usage
$sql.= " AND s.entity IN (".getEntity('societe', 1).")";
$sql.= " AND s.rowid = ".$socid;
dol_syslog("Notify.class::countDefinedNotifications ".$action.", ".$socid."", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{ {
$num = $this->db->num_rows($resql); $sql = "SELECT n.rowid";
} $sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n,";
else $sql.= " ".MAIN_DB_PREFIX."socpeople as c,";
$sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a,";
$sql.= " ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE n.fk_contact = c.rowid";
$sql.= " AND a.rowid = n.fk_action";
$sql.= " AND n.fk_soc = s.rowid";
if (is_numeric($action)) $sql.= " AND n.fk_action = ".$action; // Old usage
else $sql.= " AND a.code = '".$action."'"; // New usage
$sql.= " AND s.entity IN (".getEntity('societe', 1).")";
$sql.= " AND s.rowid = ".$socid;
dol_syslog(get_class($this)."::countDefinedNotifications ".$action.", ".$socid."", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
}
else
{
$error++;
$this->error=$this->db->error.' sql='.$sql;
}
}
if (! $error)
{ {
$this->error=$this->db->error.' sql='.$sql; // List of notifications enabled for fixed email
return -1; foreach($conf->global as $key => $val)
{
if (! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$action.'/', $key, $reg)) continue;
$num++;
}
} }
// TODO return array with list of email instead of number, + type of notification (contacts or fixed email)
if ($error) return -1;
return $num; return $num;
} }
@ -120,22 +137,42 @@ class Notify
* If yes, send mail and save trace into llx_notify. * If yes, send mail and save trace into llx_notify.
* *
* @param string $action Code of action in llx_c_action_trigger (new usage) or Id of action in llx_c_action_trigger (old usage) * @param string $action Code of action in llx_c_action_trigger (new usage) or Id of action in llx_c_action_trigger (old usage)
* @param int $socid Id of third party * @param Object $object Object the notification deals on
* @param string $texte Message to send
* @param string $objet_type Type of object the notification deals on (facture, order, propal, order_supplier...). Just for log in llx_notify.
* @param int $objet_id Id of object the notification deals on
* @param string $file Attach a file
* @return int <0 if KO, or number of changes if OK * @return int <0 if KO, or number of changes if OK
*/ */
function send($action, $socid, $texte, $objet_type, $objet_id, $file="") function send($action, $object)
{ {
global $conf,$langs,$mysoc,$dolibarr_main_url_root; global $conf,$langs,$mysoc,$dolibarr_main_url_root;
$langs->load("other"); include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_syslog(get_class($this)."::send action=".$action.", socid=".$socid.", texte=".$texte.", objet_type=".$objet_type.", objet_id=".$objet_id.", file=".$file); dol_syslog(get_class($this)."::send action=".$action.", object=".$object->id);
$sql = "SELECT s.nom, c.email, c.rowid as cid, c.lastname, c.firstname,"; $langs->load("other");
// Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
// Define some vars
$application = $mysoc->name;
//if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $application = $conf->global->MAIN_APPLICATION_TITLE;
$replyto = $conf->notification->email_from;
$filename = basename($file);
$mimefile = dol_mimetype($file);
$object_type = '';
$link = '';
$num = 0;
if (! in_array($action, array('BILL_VALIDATE', 'ORDER_VALIDATE', 'PROPAL_VALIDATE', 'FICHINTER_VALIDATE', 'ORDER_SUPPLIER_APPROVE', 'ORDER_SUPPLIER_REFUSE', 'SHIPPING_VALIDATE')))
{
return 0;
}
// Check notification per third party
$sql = "SELECT s.nom, c.email, c.rowid as cid, c.lastname, c.firstname, c.default_lang,";
$sql.= " a.rowid as adid, a.label, a.code, n.rowid"; $sql.= " a.rowid as adid, a.label, a.code, n.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c,"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c,";
$sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a,"; $sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a,";
@ -145,7 +182,7 @@ class Notify
$sql.= " AND n.fk_soc = s.rowid"; $sql.= " AND n.fk_soc = s.rowid";
if (is_numeric($action)) $sql.= " AND n.fk_action = ".$action; // Old usage if (is_numeric($action)) $sql.= " AND n.fk_action = ".$action; // Old usage
else $sql.= " AND a.code = '".$action."'"; // New usage else $sql.= " AND a.code = '".$action."'"; // New usage
$sql .= " AND s.rowid = ".$socid; $sql .= " AND s.rowid = ".$object->socid;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
@ -155,7 +192,7 @@ class Notify
if ($num > 0) if ($num > 0)
{ {
$i = 0; $i = 0;
while ($i < $num) // For each notification couple defined (third party/actioncode) while ($i < $num && ! $error) // For each notification couple defined (third party/actioncode)
{ {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
@ -164,48 +201,80 @@ class Notify
if (dol_strlen($obj->email)) if (dol_strlen($obj->email))
{ {
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Set output language
$application=($conf->global->MAIN_APPLICATION_TITLE?$conf->global->MAIN_APPLICATION_TITLE:'Dolibarr ERP/CRM'); $outputlangs = $langs;
if ($obj->default_lang && $obj->default_lang != $langs->defaultlang)
{
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang($obj->default_lang);
}
$subject = '['.$application.'] '.$langs->transnoentitiesnoconv("DolibarrNotification"); switch ($action) {
case 'BILL_VALIDATE':
$link='/compta/facture.php?facid='.$object->id;
$dir_output = $conf->facture->dir_output;
$object_type = 'facture';
$mesg = $langs->transnoentitiesnoconv("EMailTextInvoiceValidated",$object->ref);
break;
case 'ORDER_VALIDATE':
$link='/commande/card.php?id='.$object->id;
$dir_output = $conf->commande->dir_output;
$object_type = 'order';
$mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated",$object->ref);
break;
case 'PROPAL_VALIDATE':
$link='/comm/propal.php?id='.$object->id;
$dir_output = $conf->propal->dir_output;
$object_type = 'propal';
$mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated",$object->ref);
break;
case 'FICHINTER_VALIDATE':
$link='/fichinter/card.php?id='.$object->id;
$dir_output = $conf->facture->dir_output;
$object_type = 'ficheinter';
$mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated",$object->ref);
break;
case 'ORDER_SUPPLIER_APPROVE':
$link='/fourn/commande/card.php?id='.$object->id;
$dir_output = $conf->fournisseur->dir_output.'/commande/';
$object_type = 'order_supplier';
$mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
$mesg.= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy",$object->ref,$user->getFullName($langs));
$mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
break;
case 'ORDER_SUPPLIER_REFUSE':
$link='/fourn/commande/card.php?id='.$object->id;
$dir_output = $conf->fournisseur->dir_output.'/commande/';
$object_type = 'order_supplier';
$mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
$mesg.= $langs->transnoentitiesnoconv("EMailTextOrderRefusedBy",$object->ref,$user->getFullName($langs));
$mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
break;
case 'SHIPPING_VALIDATE':
$dir_output = $conf->expedition->dir_output.'/sending/';
$object_type = 'order_supplier';
$mesg = $langs->transnoentitiesnoconv("EMailTextExpeditionValidated",$object->ref);
break;
}
$ref = dol_sanitizeFileName($object->ref);
$pdf_path = $dir_output."/".$ref."/".$ref.".pdf";
if (! dol_is_file($pdf_path))
{
// We can't add PDF as it is not generated yet.
$filepdf = '';
}
else
{
$filepdf = $pdf_path;
}
$message = $langs->transnoentities("YouReceiveMailBecauseOfNotification",$application,$mysoc->name)."\n"; $subject = '['.$application.'] '.$outputlangs->transnoentitiesnoconv("DolibarrNotification");
$message.= $langs->transnoentities("YouReceiveMailBecauseOfNotification2",$application,$mysoc->name)."\n";
$message = $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification",$application,$mysoc->name)."\n";
$message.= $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification2",$application,$mysoc->name)."\n";
$message.= "\n"; $message.= "\n";
$message.= $texte; $message.= $mesg;
// Add link if ($link) $message=dol_concatdesc($message,$urlwithroot.$link);
$link='';
switch($objet_type)
{
case 'ficheinter':
$link='/fichinter/card.php?id='.$objet_id;
break;
case 'propal':
$link='/comm/propal.php?id='.$objet_id;
break;
case 'facture':
$link='/compta/facture.php?facid='.$objet_id;
break;
case 'order':
$link='/commande/card.php?id='.$objet_id;
break;
case 'order_supplier':
$link='/fourn/commande/card.php?id='.$objet_id;
break;
}
// Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
if ($link) $message.="\n".$urlwithroot.$link;
$filename = basename($file);
$mimefile=dol_mimetype($file);
$msgishtml=0;
$replyto = $conf->notification->email_from;
$mailfile = new CMailFile( $mailfile = new CMailFile(
$subject, $subject,
@ -218,26 +287,22 @@ class Notify
'', '',
'', '',
0, 0,
$msgishtml -1
); );
if ($mailfile->sendfile()) if ($mailfile->sendfile())
{ {
$now=dol_now(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, objet_type, objet_id, email)";
$sendto = htmlentities($sendto); $sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$actiondefid.", ".$object->socid.", ".$obj->cid.", '".$object_type."', ".$object->id.", '".$this->db->escape($obj->email)."')";
if (! $this->db->query($sql))
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_contact, objet_type, objet_id, email)";
$sql.= " VALUES ('".$this->db->idate($now)."', ".$actiondefid.", ".$obj->cid.", '".$objet_type."', ".$objet_id.", '".$this->db->escape($obj->email)."')";
dol_syslog("Notify::send", LOG_DEBUG);
if (! $this->db->query($sql) )
{ {
dol_print_error($this->db); dol_print_error($this->db);
} }
} }
else else
{ {
$this->error=$mailfile->error; $error++;
//dol_syslog("Notify::send ".$this->error, LOG_ERR); $this->errors[]=$mailfile->error;
} }
} }
else else
@ -246,20 +311,133 @@ class Notify
} }
$i++; $i++;
} }
return $i;
} }
else else
{ {
dol_syslog("No notification sent, nothing into notification setup for the thirdparty socid = ".$socid); dol_syslog("No notification to thirdparty sent, nothing into notification setup for the thirdparty socid = ".$object->socid);
return 0;
} }
} }
else else
{ {
$this->error=$this->db->lasterror(); $error++;
$this->errors[]=$this->db->lasterror();
return -1; return -1;
} }
// Check notification using fixed email
if (! $error)
{
$param='NOTIFICATION_FIXEDEMAIL_'.$action;
if (! empty($conf->global->$param))
{
$sendto = $conf->global->$param;
$actiondefid = dol_getIdFromCode($this->db, $action, 'c_action_trigger', 'code', 'rowid');
if ($actiondefid <= 0) dol_print_error($this->db, 'Failed to get id from code');
$object_type = '';
$link = '';
$num++;
switch ($action) {
case 'BILL_VALIDATE':
$link='/compta/facture.php?facid='.$object->id;
$dir_output = $conf->facture->dir_output;
$object_type = 'facture';
$mesg = $langs->transnoentitiesnoconv("EMailTextInvoiceValidated",$object->ref);
break;
case 'ORDER_VALIDATE':
$link='/commande/card.php?id='.$object->id;
$dir_output = $conf->commande->dir_output;
$object_type = 'order';
$mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated",$object->ref);
break;
case 'PROPAL_VALIDATE':
$link='/comm/propal.php?id='.$object->id;
$dir_output = $conf->propal->dir_output;
$object_type = 'propal';
$mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated",$object->ref);
break;
case 'FICHINTER_VALIDATE':
$link='/fichinter/card.php?id='.$object->id;
$dir_output = $conf->facture->dir_output;
$object_type = 'ficheinter';
$mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated",$object->ref);
break;
case 'ORDER_SUPPLIER_APPROVE':
$link='/fourn/commande/card.php?id='.$object->id;
$dir_output = $conf->fournisseur->dir_output.'/commande/';
$object_type = 'order_supplier';
$mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
$mesg.= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy",$object->ref,$user->getFullName($langs));
$mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
break;
case 'ORDER_SUPPLIER_REFUSE':
$link='/fourn/commande/card.php?id='.$object->id;
$dir_output = $conf->fournisseur->dir_output.'/commande/';
$object_type = 'order_supplier';
$mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
$mesg.= $langs->transnoentitiesnoconv("EMailTextOrderRefusedBy",$object->ref,$user->getFullName($langs));
$mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
break;
case 'SHIPPING_VALIDATE':
$dir_output = $conf->expedition->dir_output.'/sending/';
$object_type = 'order_supplier';
$mesg = $langs->transnoentitiesnoconv("EMailTextExpeditionValidated",$object->ref);
break;
}
$ref = dol_sanitizeFileName($object->ref);
$pdf_path = $dir_output."/".$ref."/".$ref.".pdf";
if (! dol_is_file($pdf_path))
{
// We can't add PDF as it is not generated yet.
$filepdf = '';
}
else
{
$filepdf = $pdf_path;
}
$subject = '['.$application.'] '.$langs->transnoentitiesnoconv("DolibarrNotification");
$message = $langs->transnoentities("YouReceiveMailBecauseOfNotification",$application,$mysoc->name)."\n";
$message.= $langs->transnoentities("YouReceiveMailBecauseOfNotification2",$application,$mysoc->name)."\n";
$message.= "\n";
$message.= $mesg;
if ($link) $message=dol_concatdesc($message,$urlwithroot.$link);
$mailfile = new CMailFile(
$subject,
$sendto,
$replyto,
$message,
array($file),
array($mimefile),
array($filename[count($filename)-1]),
'',
'',
0,
-1
);
if ($mailfile->sendfile())
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, objet_type, objet_id, email)";
$sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$actiondefid.", ".$object->socid.", null, '".$object_type."', ".$object->id.", '".$this->db->escape($conf->global->$param)."')";
if (! $this->db->query($sql))
{
dol_print_error($this->db);
}
}
else
{
$error++;
$this->errors[]=$mailfile->error;
}
}
}
if (! $error) return $num;
else return -1 * $error;
} }
} }

View File

@ -46,6 +46,10 @@ abstract class DoliDB implements Database
public $database_name; public $database_name;
//! Database username //! Database username
public $database_user; public $database_user;
//! Database host
public $database_host;
//! Database port
public $database_port;
//! >=1 if a transaction is opened, 0 otherwise //! >=1 if a transaction is opened, 0 otherwise
public $transaction_opened; public $transaction_opened;
//! Last successful query //! Last successful query

View File

@ -60,6 +60,8 @@ class DoliDBMssql extends DoliDB
global $conf,$langs; global $conf,$langs;
$this->database_user=$user; $this->database_user=$user;
$this->database_host=$host;
$this->database_port=$port;
$this->transaction_opened=0; $this->transaction_opened=0;
if (! function_exists("mssql_connect")) if (! function_exists("mssql_connect"))

View File

@ -61,6 +61,8 @@ class DoliDBMysql extends DoliDB
if (! empty($conf->db->dolibarr_main_db_collation)) $this->forcecollate=$conf->db->dolibarr_main_db_collation; if (! empty($conf->db->dolibarr_main_db_collation)) $this->forcecollate=$conf->db->dolibarr_main_db_collation;
$this->database_user=$user; $this->database_user=$user;
$this->database_host=$host;
$this->database_port=$port;
$this->transaction_opened=0; $this->transaction_opened=0;

View File

@ -61,6 +61,8 @@ class DoliDBMysqli extends DoliDB
if (! empty($conf->db->dolibarr_main_db_collation)) $this->forcecollate=$conf->db->dolibarr_main_db_collation; if (! empty($conf->db->dolibarr_main_db_collation)) $this->forcecollate=$conf->db->dolibarr_main_db_collation;
$this->database_user=$user; $this->database_user=$user;
$this->database_host=$host;
$this->database_port=$port;
$this->transaction_opened=0; $this->transaction_opened=0;

View File

@ -71,6 +71,8 @@ class DoliDBPgsql extends DoliDB
if (! empty($conf->db->dolibarr_main_db_collation)) $this->forcecollate=$conf->db->dolibarr_main_db_collation; if (! empty($conf->db->dolibarr_main_db_collation)) $this->forcecollate=$conf->db->dolibarr_main_db_collation;
$this->database_user=$user; $this->database_user=$user;
$this->database_host=$host;
$this->database_port=$port;
$this->transaction_opened=0; $this->transaction_opened=0;

View File

@ -61,6 +61,8 @@ class DoliDBSqlite extends DoliDB
if (! empty($conf->db->dolibarr_main_db_collation)) $this->forcecollate=$conf->db->dolibarr_main_db_collation; if (! empty($conf->db->dolibarr_main_db_collation)) $this->forcecollate=$conf->db->dolibarr_main_db_collation;
$this->database_user=$user; $this->database_user=$user;
$this->database_host=$host;
$this->database_port=$port;
$this->transaction_opened=0; $this->transaction_opened=0;

View File

@ -443,10 +443,11 @@ function dol_get_next_week($day, $week, $month, $year)
* @param mixed $gm False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date. * @param mixed $gm False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date.
* Exemple: dol_get_first_day(1970,1,false) will return -3600 with TZ+1, after a dol_print_date will return 1970-01-01 00:00:00 * Exemple: dol_get_first_day(1970,1,false) will return -3600 with TZ+1, after a dol_print_date will return 1970-01-01 00:00:00
* Exemple: dol_get_first_day(1970,1,true) will return 0 whatever is TZ, after a dol_print_date will return 1970-01-01 00:00:00 * Exemple: dol_get_first_day(1970,1,true) will return 0 whatever is TZ, after a dol_print_date will return 1970-01-01 00:00:00
* @return int Date for first day * @return int Date for first day, '' if error
*/ */
function dol_get_first_day($year,$month=1,$gm=false) function dol_get_first_day($year,$month=1,$gm=false)
{ {
if ($year > 9999) return '';
return dol_mktime(0,0,0,$month,1,$year,$gm); return dol_mktime(0,0,0,$month,1,$year,$gm);
} }
@ -456,10 +457,11 @@ function dol_get_first_day($year,$month=1,$gm=false)
* @param int $year Year * @param int $year Year
* @param int $month Month * @param int $month Month
* @param boolean $gm False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date. * @param boolean $gm False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date.
* @return int Date for first day * @return int Date for first day, '' if error
*/ */
function dol_get_last_day($year,$month=12,$gm=false) function dol_get_last_day($year,$month=12,$gm=false)
{ {
if ($year > 9999) return '';
if ($month == 12) if ($month == 12)
{ {
$month = 1; $month = 1;

View File

@ -139,6 +139,7 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
$level1name=(isset($reg[1])?$reg[1]:''); $level1name=(isset($reg[1])?$reg[1]:'');
$file_list[] = array( $file_list[] = array(
"name" => $file, "name" => $file,
"path" => $path,
"level1name" => $level1name, "level1name" => $level1name,
"fullname" => $path.'/'.$file, "fullname" => $path.'/'.$file,
"date" => $filedate, "date" => $filedate,
@ -166,6 +167,7 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
$level1name=(isset($reg[1])?$reg[1]:''); $level1name=(isset($reg[1])?$reg[1]:'');
$file_list[] = array( $file_list[] = array(
"name" => $file, "name" => $file,
"path" => $path,
"level1name" => $level1name, "level1name" => $level1name,
"fullname" => $path.'/'.$file, "fullname" => $path.'/'.$file,
"date" => $filedate, "date" => $filedate,

View File

@ -175,7 +175,7 @@ function dol_shutdown()
* @param int $method Type of method (0 = get then post, 1 = only get, 2 = only post, 3 = post then get, 4 = post then get then cookie) * @param int $method Type of method (0 = get then post, 1 = only get, 2 = only post, 3 = post then get, 4 = post then get then cookie)
* @param int $filter Filter to apply when $check is set to custom. (See http://php.net/manual/en/filter.filters.php for détails) * @param int $filter Filter to apply when $check is set to custom. (See http://php.net/manual/en/filter.filters.php for détails)
* @param mixed $options Options to pass to filter_var when $check is set to custom * @param mixed $options Options to pass to filter_var when $check is set to custom
* @return string||string[] Value found, or '' if check fails * @return string||string[] Value found (string or array), or '' if check fails
*/ */
function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL) function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL)
{ {
@ -4559,6 +4559,8 @@ function picto_from_langcode($codelang)
{ {
global $langs; global $langs;
if (empty($codelang)) return '';
if ($codelang == 'auto') if ($codelang == 'auto')
{ {
return img_picto_common($langs->trans('AutoDetectLang'), 'flags/int.png'); return img_picto_common($langs->trans('AutoDetectLang'), 'flags/int.png');

View File

@ -1341,6 +1341,7 @@ function getListOfModels($db,$type,$maxfilenamelength=0)
$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; $sql.= " FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE type = '".$type."'"; $sql.= " WHERE type = '".$type."'";
$sql.= " AND entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; $sql.= " AND entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")";
$sql.= " ORDER BY description DESC";
dol_syslog('/core/lib/function2.lib.php::getListOfModels', LOG_DEBUG); dol_syslog('/core/lib/function2.lib.php::getListOfModels', LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);

View File

@ -79,7 +79,7 @@ function facture_prepare_head($object)
if(!empty($object->note_public)) $nbNote++; if(!empty($object->note_public)) $nbNote++;
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id;
$head[$h][1] = $langs->trans('Notes'); $head[$h][1] = $langs->trans('Notes');
if ($nbNote > 0) $head[$h][1].= ' ('.$nbNote.')'; if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
$head[$h][2] = 'note'; $head[$h][2] = 'note';
$h++; $h++;
} }
@ -89,7 +89,7 @@ function facture_prepare_head($object)
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$')); $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$'));
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/document.php?facid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/compta/facture/document.php?facid='.$object->id;
$head[$h][1] = $langs->trans('Documents'); $head[$h][1] = $langs->trans('Documents');
if($nbFiles > 0) $head[$h][1].= ' ('.$nbFiles.')'; if($nbFiles > 0) $head[$h][1].= ' <span class="badge">'.$nbFiles.'</span>';
$head[$h][2] = 'documents'; $head[$h][2] = 'documents';
$h++; $h++;

View File

@ -98,8 +98,10 @@ class modCommande extends DolibarrModules
$this->const[$r][4] = 0; $this->const[$r][4] = 0;
// Boxes // Boxes
$this->boxes = array(); $this->boxes = array(
$this->boxes = array(0=>array('file'=>'box_commandes.php','enabledbydefaulton'=>'Home'),2=>array('file'=>'box_graph_orders_permonth.php','enabledbydefaulton'=>'Home')); 0=>array('file'=>'box_commandes.php','enabledbydefaulton'=>'Home'),
2=>array('file'=>'box_graph_orders_permonth.php','enabledbydefaulton'=>'Home')
);
// Permissions // Permissions
$this->rights = array(); $this->rights = array();

View File

@ -78,25 +78,31 @@ class modDeplacement extends DolibarrModules
$this->rights_class = 'deplacement'; $this->rights_class = 'deplacement';
$this->rights[1][0] = 171; $this->rights[1][0] = 171;
$this->rights[1][1] = 'Lire les deplacements'; $this->rights[1][1] = 'Lire ses notes de frais et deplacements et celles de sa hierarchy';
$this->rights[1][2] = 'r'; $this->rights[1][2] = 'r';
$this->rights[1][3] = 1; $this->rights[1][3] = 1;
$this->rights[1][4] = 'lire'; $this->rights[1][4] = 'lire';
$this->rights[2][0] = 172; $this->rights[2][0] = 172;
$this->rights[2][1] = 'Creer/modifier les deplacements'; $this->rights[2][1] = 'Creer/modifier une note de frais et deplacements';
$this->rights[2][2] = 'w'; $this->rights[2][2] = 'w';
$this->rights[2][3] = 0; $this->rights[2][3] = 0;
$this->rights[2][4] = 'creer'; $this->rights[2][4] = 'creer';
$this->rights[3][0] = 173; $this->rights[3][0] = 173;
$this->rights[3][1] = 'Supprimer les deplacements'; $this->rights[3][1] = 'Supprimer les notes de frais et deplacements';
$this->rights[3][2] = 'd'; $this->rights[3][2] = 'd';
$this->rights[3][3] = 0; $this->rights[3][3] = 0;
$this->rights[3][4] = 'supprimer'; $this->rights[3][4] = 'supprimer';
$this->rights[3][0] = 174;
$this->rights[3][1] = 'Lire toutes les notes de frais';
$this->rights[3][2] = 'd';
$this->rights[3][3] = 0;
$this->rights[3][4] = 'readall';
$this->rights[6][0] = 178; $this->rights[6][0] = 178;
$this->rights[6][1] = 'Exporter les deplacements'; $this->rights[6][1] = 'Exporter les notes de frais et deplacements';
$this->rights[6][2] = 'd'; $this->rights[6][2] = 'd';
$this->rights[6][3] = 0; $this->rights[6][3] = 0;
$this->rights[6][4] = 'export'; $this->rights[6][4] = 'export';

View File

@ -106,8 +106,8 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->load("contracts"); $langs->load("contracts");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractValidatedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
$object->actionmsg=$langs->transnoentities("ContractValidatedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
@ -117,8 +117,8 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->load("propal"); $langs->load("propal");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
$object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
@ -165,8 +165,8 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->load("orders"); $langs->load("orders");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
$object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
@ -192,8 +192,8 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->load("bills"); $langs->load("bills");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
$object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
@ -271,8 +271,8 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->load("interventions"); $langs->load("interventions");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionValidatedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
$object->actionmsg=$langs->transnoentities("InterventionValidatedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
@ -337,10 +337,10 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->load("sendings"); $langs->load("sendings");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingValidated",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref));
if (empty($object->actionmsg)) if (empty($object->actionmsg))
{ {
$object->actionmsg=$langs->transnoentities("ShippingValidated",$object->ref); $object->actionmsg=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref));
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
} }
@ -368,8 +368,8 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->load("orders"); $langs->load("orders");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
$object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
@ -419,8 +419,8 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->load("bills"); $langs->load("bills");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
$object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
@ -474,8 +474,8 @@ class InterfaceActionsAuto extends DolibarrTriggers
$langs->load("members"); $langs->load("members");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberValidatedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
$object->actionmsg=$langs->transnoentities("MemberValidatedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("MemberValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
$object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
$object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;

View File

@ -60,70 +60,12 @@ class InterfaceNotification extends DolibarrTriggers
{ {
if (empty($conf->notification->enabled)) return 0; // Module not active, we do nothing if (empty($conf->notification->enabled)) return 0; // Module not active, we do nothing
require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php';
$langs->load("other");
switch ($action) {
case 'BILL_VALIDATE':
$dir_output = $conf->facture->dir_output;
$object_type = 'facture';
$mesg = $langs->transnoentitiesnoconv("EMailTextInvoiceValidated",$object->ref);
break;
case 'ORDER_VALIDATE':
$dir_output = $conf->commande->dir_output;
$object_type = 'order';
$mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated",$object->ref);
break;
case 'PROPAL_VALIDATE':
$dir_output = $conf->propal->dir_output;
$object_type = 'propal';
$mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated",$object->ref);
break;
case 'FICHINTER_VALIDATE':
$dir_output = $conf->facture->dir_output;
$object_type = 'ficheinter';
$mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated",$object->ref);
break;
case 'ORDER_SUPPLIER_APPROVE':
$dir_output = $conf->fournisseur->dir_output.'/commande/';
$object_type = 'order_supplier';
$mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
$mesg.= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy",$object->ref,$user->getFullName($langs));
$mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
break;
case 'ORDER_SUPPLIER_REFUSE':
$dir_output = $conf->fournisseur->dir_output.'/commande/';
$object_type = 'order_supplier';
$mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
$mesg.= $langs->transnoentitiesnoconv("EMailTextOrderRefusedBy",$object->ref,$user->getFullName($langs));
$mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
break;
case 'SHIPPING_VALIDATE':
$dir_output = $conf->expedition->dir_output.'/sending/';
$object_type = 'order_supplier';
$mesg = $langs->transnoentitiesnoconv("EMailTextExpeditionValidated",$object->ref);
break;
default:
return 0;
}
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$ref = dol_sanitizeFileName($object->ref); require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php';
$pdf_path = "$dir_output/$ref/$ref.pdf";
if (!file_exists($pdf_path)) {
// We can't add PDF as it is not generated yet.
$filepdf = '';
} else {
$filepdf = $pdf_path;
}
$notify = new Notify($this->db); $notify = new Notify($this->db);
$notify->send($action, $object->socid, $mesg, $object_type, $object->id, $filepdf); $notify->send($action, $object);
return 1; return 1;
} }

View File

@ -250,26 +250,25 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->exped
} }
else else
{ {
// Define output language // Define output language
$outputlangs = $langs; if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
$newlang=''; {
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id','alpha'); $outputlangs = $langs;
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; $newlang = '';
if (! empty($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;
$outputlangs = new Translate("",$conf); if (! empty($newlang)) {
$outputlangs->setDefaultLang($newlang); $outputlangs = new Translate("", $conf);
} $outputlangs->setDefaultLang($newlang);
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) }
{ $model=$object->modelpdf;
$ret=$object->fetch($id); // Reload to get new records if (empty($model)) {
$result = $object->generateDocument($object->modelpdf, $outputlangs); $tmp=getListOfModels($db, 'shipping'); $keys=array_keys($tmp); $model=$keys[0];
} }
if ($result < 0) $ret = $object->fetch($id); // Reload to get new records
{ $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
dol_print_error($db,$result); if ($result < 0) dol_print_error($db,$result);
exit; }
}
} }
} }

View File

@ -503,9 +503,10 @@ class Expedition extends CommonObject
* Validate object and update stock if option enabled * Validate object and update stock if option enabled
* *
* @param User $user Object user that validate * @param User $user Object user that validate
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if OK, >0 if KO * @return int <0 if OK, >0 if KO
*/ */
function valid($user) function valid($user, $notrigger=0)
{ {
global $conf, $langs; global $conf, $langs;
@ -547,6 +548,7 @@ class Expedition extends CommonObject
{ {
$numref = "EXP".$this->id; $numref = "EXP".$this->id;
} }
$this->newref = $numref;
$now=dol_now(); $now=dol_now();
@ -617,9 +619,17 @@ class Expedition extends CommonObject
} }
} }
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('SHIPPING_VALIDATE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error) if (! $error)
{ {
$this->oldref=''; $this->oldref = $this->ref;
// Rename directory if dir was a temporary ref // Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref)) if (preg_match('/^[\(]?PROV/i', $this->ref))
@ -636,11 +646,17 @@ class Expedition extends CommonObject
if (@rename($dirsource, $dirdest)) if (@rename($dirsource, $dirdest))
{ {
$this->oldref = $oldref; dol_syslog("Rename ok");
// Rename docs starting with $oldref with $newref
dol_syslog("Rename ok"); $listoffiles=dol_dir_list($conf->expedition->dir_output.'/sending/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/'));
// Suppression ancien fichier PDF dans nouveau rep foreach($listoffiles as $fileentry)
dol_delete_file($dirdest.'/'.$oldref.'*.*'); {
$dirsource=$fileentry['name'];
$dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource);
$dirsource=$fileentry['path'].'/'.$dirsource;
$dirdest=$fileentry['path'].'/'.$dirdest;
@rename($dirsource, $dirdest);
}
} }
} }
} }
@ -653,14 +669,6 @@ class Expedition extends CommonObject
$this->statut = 1; $this->statut = 1;
} }
if (! $error)
{
// Call trigger
$result=$this->call_trigger('SHIPPING_VALIDATE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error) if (! $error)
{ {
$this->db->commit(); $this->db->commit();

View File

@ -374,9 +374,10 @@ class Fichinter extends CommonObject
* Validate a intervention * Validate a intervention
* *
* @param User $user User that validate * @param User $user User that validate
* @return int <0 if KO, >0 if OK * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK
*/ */
function setValid($user) function setValid($user, $notrigger=0)
{ {
global $conf; global $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -398,6 +399,7 @@ class Fichinter extends CommonObject
{ {
$num = $this->ref; $num = $this->ref;
} }
$this->newref = $num;
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter"; $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter";
$sql.= " SET fk_statut = 1"; $sql.= " SET fk_statut = 1";
@ -416,9 +418,17 @@ class Fichinter extends CommonObject
$error++; $error++;
} }
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('FICHINTER_VALIDATE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error) if (! $error)
{ {
$this->oldref = ''; $this->oldref = $this->ref;
// Rename directory if dir was a temporary ref // Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref)) if (preg_match('/^[\(]?PROV/i', $this->ref))
@ -426,20 +436,26 @@ class Fichinter extends CommonObject
// Rename of object directory ($this->ref = old ref, $num = new ref) // Rename of object directory ($this->ref = old ref, $num = new ref)
// to not lose the linked files // to not lose the linked files
$oldref = dol_sanitizeFileName($this->ref); $oldref = dol_sanitizeFileName($this->ref);
$snum = dol_sanitizeFileName($num); $newref = dol_sanitizeFileName($num);
$dirsource = $conf->ficheinter->dir_output.'/'.$oldref; $dirsource = $conf->ficheinter->dir_output.'/'.$oldref;
$dirdest = $conf->ficheinter->dir_output.'/'.$snum; $dirdest = $conf->ficheinter->dir_output.'/'.$newref;
if (file_exists($dirsource)) if (file_exists($dirsource))
{ {
dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); dol_syslog(get_class($this)."::setValid rename dir ".$dirsource." into ".$dirdest);
if (@rename($dirsource, $dirdest)) if (@rename($dirsource, $dirdest))
{ {
$this->oldref = $oldref; dol_syslog("Rename ok");
// Rename docs starting with $oldref with $newref
dol_syslog("Rename ok"); $listoffiles=dol_dir_list($conf->ficheinter->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/'));
// Suppression ancien fichier PDF dans nouveau rep foreach($listoffiles as $fileentry)
dol_delete_file($conf->ficheinter->dir_output.'/'.$snum.'/'.$oldref.'*.*'); {
$dirsource=$fileentry['name'];
$dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource);
$dirsource=$fileentry['path'].'/'.$dirsource;
$dirdest=$fileentry['path'].'/'.$dirdest;
@rename($dirsource, $dirdest);
}
} }
} }
} }
@ -454,14 +470,6 @@ class Fichinter extends CommonObject
$this->date_validation=$now; $this->date_validation=$now;
} }
if (! $error)
{
// Call trigger
$result=$this->call_trigger('FICHINTER_VALIDATE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error) if (! $error)
{ {
$this->db->commit(); $this->db->commit();

View File

@ -317,9 +317,10 @@ class CommandeFournisseur extends CommonOrder
* *
* @param User $user Validator User * @param User $user Validator User
* @param int $idwarehouse Id of warehouse to use for stock decrease * @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 KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function valid($user,$idwarehouse=0) function valid($user,$idwarehouse=0,$notrigger=0)
{ {
global $langs,$conf; global $langs,$conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -342,12 +343,13 @@ class CommandeFournisseur extends CommonOrder
$num = $this->getNextNumRef($soc); $num = $this->getNextNumRef($soc);
} }
else else
{ {
$num = $this->ref; $num = $this->ref;
} }
$this->newref = $num;
$sql = 'UPDATE '.MAIN_DB_PREFIX."commande_fournisseur"; $sql = 'UPDATE '.MAIN_DB_PREFIX."commande_fournisseur";
$sql.= " SET ref='".$num."',"; $sql.= " SET ref='".$this->db->escape($num)."',";
$sql.= " fk_statut = 1,"; $sql.= " fk_statut = 1,";
$sql.= " date_valid='".$this->db->idate(dol_now())."',"; $sql.= " date_valid='".$this->db->idate(dol_now())."',";
$sql.= " fk_user_valid = ".$user->id; $sql.= " fk_user_valid = ".$user->id;
@ -361,9 +363,17 @@ class CommandeFournisseur extends CommonOrder
$error++; $error++;
} }
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('ORDER_SUPPLIER_VALIDATE',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error) if (! $error)
{ {
$this->oldref=''; $this->oldref = $this->ref;
// Rename directory if dir was a temporary ref // Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref)) if (preg_match('/^[\(]?PROV/i', $this->ref))
@ -380,11 +390,17 @@ class CommandeFournisseur extends CommonOrder
if (@rename($dirsource, $dirdest)) if (@rename($dirsource, $dirdest))
{ {
$this->oldref = $oldref;
dol_syslog("Rename ok"); dol_syslog("Rename ok");
// Suppression ancien fichier PDF dans nouveau rep // Rename docs starting with $oldref with $newref
dol_delete_file($dirdest.'/'.$oldref.'*.*'); $listoffiles=dol_dir_list($conf->fournisseur->dir_output.'/commande/'.$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);
}
} }
} }
} }
@ -397,18 +413,6 @@ class CommandeFournisseur extends CommonOrder
$this->ref = $num; $this->ref = $num;
} }
if (! $error)
{
// Call trigger
$result=$this->call_trigger('ORDER_SUPPLIER_VALIDATE',$user);
if ($result < 0)
{
$this->db->rollback();
return -1;
}
// End call triggers
}
if (! $error) if (! $error)
{ {
$this->db->commit(); $this->db->commit();
@ -619,9 +623,10 @@ class CommandeFournisseur extends CommonOrder
$num = $this->getNextNumRef($soc); $num = $this->getNextNumRef($soc);
} }
else else
{ {
$num = $this->ref; $num = $this->ref;
} }
$this->newref = $num;
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur"; $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur";
$sql.= " SET ref='".$this->db->escape($num)."',"; $sql.= " SET ref='".$this->db->escape($num)."',";

View File

@ -257,7 +257,7 @@ class FactureFournisseur extends CommonInvoice
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('BILL_SUPPLIER_CREATE',$user); $result=$this->call_trigger('BILL_SUPPLIER_CREATE',$user);
if ($result < 0) $error++; if ($result < 0) $error++;
// End call triggers // End call triggers
if (! $error) if (! $error)
@ -413,7 +413,7 @@ class FactureFournisseur extends CommonInvoice
$this->socid = $obj->socid; $this->socid = $obj->socid;
$this->socnom = $obj->socnom; $this->socnom = $obj->socnom;
// Retreive all extrafield // Retreive all extrafield
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
@ -611,7 +611,7 @@ class FactureFournisseur extends CommonInvoice
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('BILL_SUPPLIER_UPDATE',$user); $result=$this->call_trigger('BILL_SUPPLIER_UPDATE',$user);
if ($result < 0) $error++; if ($result < 0) $error++;
// End call triggers // End call triggers
} }
} }
@ -682,9 +682,9 @@ class FactureFournisseur extends CommonInvoice
// Call trigger // Call trigger
$result=$this->call_trigger('BILL_SUPPLIER_DELETE',$user); $result=$this->call_trigger('BILL_SUPPLIER_DELETE',$user);
if ($result < 0) if ($result < 0)
{ {
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
// Fin appel triggers // Fin appel triggers
} }
@ -776,7 +776,7 @@ class FactureFournisseur extends CommonInvoice
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('BILL_SUPPLIER_PAYED',$user); $result=$this->call_trigger('BILL_SUPPLIER_PAYED',$user);
if ($result < 0) $error++; if ($result < 0) $error++;
// End call triggers // End call triggers
} }
else else
@ -824,7 +824,7 @@ class FactureFournisseur extends CommonInvoice
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('BILL_SUPPLIER_UNPAYED',$user); $result=$this->call_trigger('BILL_SUPPLIER_UNPAYED',$user);
if ($result < 0) $error++; if ($result < 0) $error++;
// End call triggers // End call triggers
} }
else else
@ -852,9 +852,10 @@ class FactureFournisseur extends CommonInvoice
* @param User $user Object user that validate * @param User $user Object user that validate
* @param string $force_number Reference to force on invoice * @param string $force_number Reference to force on invoice
* @param int $idwarehouse Id of warehouse for stock change * @param int $idwarehouse Id of warehouse for stock change
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, =0 if nothing to do, >0 if OK * @return int <0 if KO, =0 if nothing to do, >0 if OK
*/ */
function validate($user, $force_number='', $idwarehouse=0) function validate($user, $force_number='', $idwarehouse=0, $notrigger=0)
{ {
global $conf,$langs; global $conf,$langs;
@ -886,9 +887,10 @@ class FactureFournisseur extends CommonInvoice
$num = $this->getNextNumRef($this->client); $num = $this->getNextNumRef($this->client);
} }
else else
{ {
$num = $this->ref; $num = $this->ref;
} }
$this->newref = $num;
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn"; $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn";
$sql.= " SET ref='".$num."', fk_statut = 1, fk_user_valid = ".$user->id; $sql.= " SET ref='".$num."', fk_statut = 1, fk_user_valid = ".$user->id;
@ -920,31 +922,46 @@ class FactureFournisseur extends CommonInvoice
} }
} }
// Triggers call
if (! $error && $notrigger)
{
// Call trigger
$result=$this->call_trigger('BILL_SUPPLIER_VALIDATE',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error) if (! $error)
{ {
$this->oldref = ''; $this->oldref = $this->ref;
// Rename directory if dir was a temporary ref // Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref)) if (preg_match('/^[\(]?PROV/i', $this->ref))
{ {
// On renomme repertoire facture ($this->ref = ancienne ref, $num = nouvelle ref) // On renomme repertoire facture ($this->ref = ancienne ref, $num = nouvelle ref)
// in order not to lose the attached files // in order not to lose the attached files
$facref = dol_sanitizeFileName($this->ref); $oldref = dol_sanitizeFileName($this->ref);
$snumfa = dol_sanitizeFileName($num); $newref = dol_sanitizeFileName($num);
$dirsource = $conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id,2).$facref; $dirsource = $conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id,2).$oldref;
$dirdest = $conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id,2).$snumfa; $dirdest = $conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id,2).$newref;
if (file_exists($dirsource)) if (file_exists($dirsource))
{ {
dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest);
if (@rename($dirsource, $dirdest)) if (@rename($dirsource, $dirdest))
{ {
$this->oldref = $facref;
dol_syslog("Rename ok"); dol_syslog("Rename ok");
// Suppression ancien fichier PDF dans nouveau rep // Rename docs starting with $oldref with $newref
dol_delete_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id,2).$snumfa.'/'.$facref.'*.*'); $listoffiles=dol_dir_list($conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id,2).$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);
}
} }
} }
} }
@ -958,15 +975,6 @@ class FactureFournisseur extends CommonInvoice
//$this->date_validation=$now; this is stored into log table //$this->date_validation=$now; this is stored into log table
} }
// Triggers call
if (! $error)
{
// Call trigger
$result=$this->call_trigger('BILL_SUPPLIER_VALIDATE',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error) if (! $error)
{ {
$this->db->commit(); $this->db->commit();
@ -1128,8 +1136,8 @@ class FactureFournisseur extends CommonInvoice
global $conf, $langs, $user; global $conf, $langs, $user;
// Call trigger // Call trigger
$result=$this->call_trigger('LINEBILL_SUPPLIER_CREATE',$user); $result=$this->call_trigger('LINEBILL_SUPPLIER_CREATE',$user);
if ($result < 0) if ($result < 0)
{ {
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
@ -1224,7 +1232,7 @@ class FactureFournisseur extends CommonInvoice
} }
$this->db->begin(); $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET";
$sql.= " description ='".$this->db->escape($desc)."'"; $sql.= " description ='".$this->db->escape($desc)."'";
$sql.= ", pu_ht = ".price2num($pu_ht); $sql.= ", pu_ht = ".price2num($pu_ht);
@ -1258,8 +1266,8 @@ class FactureFournisseur extends CommonInvoice
global $conf, $langs, $user; global $conf, $langs, $user;
// Call trigger // Call trigger
$result=$this->call_trigger('LINEBILL_SUPPLIER_UPDATE',$user); $result=$this->call_trigger('LINEBILL_SUPPLIER_UPDATE',$user);
if ($result < 0) if ($result < 0)
{ {
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
@ -1270,7 +1278,7 @@ class FactureFournisseur extends CommonInvoice
$result=$this->update_price('','auto'); $result=$this->update_price('','auto');
$this->db->commit(); $this->db->commit();
return $result; return $result;
} }
else else
@ -1303,7 +1311,7 @@ class FactureFournisseur extends CommonInvoice
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('LINEBILL_SUPPLIER_DELETE',$user); $result=$this->call_trigger('LINEBILL_SUPPLIER_DELETE',$user);
if ($result < 0) $error++; if ($result < 0) $error++;
// End call triggers // End call triggers
} }

View File

@ -341,19 +341,24 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
{ {
$ret=$object->fetch($object->id); // Reload to get new records $ret=$object->fetch($object->id); // Reload to get new records
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{ {
// Define output language
$outputlangs = $langs; $outputlangs = $langs;
$newlang=GETPOST('lang_id','alpha'); $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if (! empty($newlang)) if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
{ if (! empty($newlang)) {
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
$model=$object->modelpdf;
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if (empty($model)) {
$tmp=getListOfModels($db, 'order_supplier'); $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);
} }
unset($_POST ['prod_entry_mode']); unset($_POST ['prod_entry_mode']);
@ -438,19 +443,28 @@ else if ($action == 'update_line' && $user->rights->fournisseur->commande->creer
unset($_POST['date_end']); unset($_POST['date_end']);
unset($localtax1_tx); unset($localtax1_tx);
unset($localtax2_tx); unset($localtax2_tx);
if ($result >= 0) if ($result >= 0)
{ {
$outputlangs = $langs; // Define output language
if (GETPOST('lang_id')) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{ {
$outputlangs = new Translate("",$conf); $outputlangs = $langs;
$outputlangs->setDefaultLang(GETPOST('lang_id')); $newlang = '';
} if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
{ if (! empty($newlang)) {
$ret=$object->fetch($object->id); // Reload to get new records $outputlangs = new Translate("", $conf);
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); $outputlangs->setDefaultLang($newlang);
} }
$model=$object->modelpdf;
if (empty($model)) {
$tmp=getListOfModels($db, 'order_supplier'); $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);
}
} }
else else
{ {
@ -496,17 +510,25 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fourn
$result = $object->valid($user); $result = $object->valid($user);
if ($result >= 0) if ($result >= 0)
{ {
$outputlangs = $langs; // Define output language
if (GETPOST('lang_id')) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{ {
$outputlangs = new Translate("",$conf); $outputlangs = $langs;
$outputlangs->setDefaultLang(GETPOST('lang_id')); $newlang = '';
} if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
{ if (! empty($newlang)) {
$ret=$object->fetch($object->id); // Reload to get new records $outputlangs = new Translate("", $conf);
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); $outputlangs->setDefaultLang($newlang);
} }
$model=$object->modelpdf;
if (empty($model)) {
$tmp=getListOfModels($db, 'order_supplier'); $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);
}
} }
else else
{ {
@ -1760,7 +1782,7 @@ elseif (! empty($object->id))
if ($user->societe_id == 0 && $action != 'edit_line' && $action != 'delete') if ($user->societe_id == 0 && $action != 'edit_line' && $action != 'delete')
{ {
print '<div class="tabsAction">'; print '<div class="tabsAction">';
// Validate // Validate
if ($object->statut == 0 && $num > 0) if ($object->statut == 0 && $num > 0)
{ {
@ -1770,7 +1792,7 @@ elseif (! empty($object->id))
print '>'.$langs->trans('Validate').'</a>'; print '>'.$langs->trans('Validate').'</a>';
} }
} }
// Modify // Modify
if ($object->statut == 1) if ($object->statut == 1)
{ {
@ -1779,7 +1801,7 @@ elseif (! empty($object->id))
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("Modify").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("Modify").'</a>';
} }
} }
// Approve // Approve
if ($object->statut == 1) if ($object->statut == 1)
{ {
@ -1794,7 +1816,7 @@ elseif (! empty($object->id))
print '<a class="butActionRefused" href="#">'.$langs->trans("RefuseOrder").'</a>'; print '<a class="butActionRefused" href="#">'.$langs->trans("RefuseOrder").'</a>';
} }
} }
// Send // Send
if (in_array($object->statut, array(2, 3, 4, 5))) if (in_array($object->statut, array(2, 3, 4, 5)))
{ {
@ -1803,7 +1825,7 @@ elseif (! empty($object->id))
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=presend&amp;mode=init">'.$langs->trans('SendByMail').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=presend&amp;mode=init">'.$langs->trans('SendByMail').'</a>';
} }
} }
// Reopen // Reopen
if (in_array($object->statut, array(2, 5, 6, 7, 9))) if (in_array($object->statut, array(2, 5, 6, 7, 9)))
{ {
@ -1812,7 +1834,7 @@ elseif (! empty($object->id))
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("ReOpen").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("ReOpen").'</a>';
} }
} }
// Create bill // Create bill
if (! empty($conf->fournisseur->enabled) && $object->statut >= 2) // 2 means accepted if (! empty($conf->fournisseur->enabled) && $object->statut >= 2) // 2 means accepted
{ {
@ -1820,13 +1842,13 @@ elseif (! empty($object->id))
{ {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a>';
} }
//if ($user->rights->fournisseur->commande->creer && $object->statut > 2) //if ($user->rights->fournisseur->commande->creer && $object->statut > 2)
//{ //{
// print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("ClassifyBilled").'</a>'; // print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("ClassifyBilled").'</a>';
//} //}
} }
// Cancel // Cancel
if ($object->statut == 2) if ($object->statut == 2)
{ {
@ -1835,19 +1857,19 @@ elseif (! empty($object->id))
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=cancel">'.$langs->trans("CancelOrder").'</a>'; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=cancel">'.$langs->trans("CancelOrder").'</a>';
} }
} }
// Clone // Clone
if ($user->rights->fournisseur->commande->creer) if ($user->rights->fournisseur->commande->creer)
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object=order">'.$langs->trans("ToClone").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object=order">'.$langs->trans("ToClone").'</a>';
} }
// Delete // Delete
if ($user->rights->fournisseur->commande->supprimer) if ($user->rights->fournisseur->commande->supprimer)
{ {
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>'; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
} }
print "</div>"; print "</div>";
} }
} }

View File

@ -693,24 +693,25 @@ elseif ($action == 'addline' && $user->rights->fournisseur->facture->creer)
{ {
$db->commit(); $db->commit();
// Define output language // Define output language
$outputlangs = $langs; if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
$newlang=GETPOST('lang_id','alpha');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang))
{ {
$outputlangs = new Translate("",$conf); $outputlangs = $langs;
$outputlangs->setDefaultLang($newlang); $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_supplier'); $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);
} }
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result <= 0)
{
dol_print_error($db,$result);
exit;
}
}
unset($_POST ['prod_entry_mode']); unset($_POST ['prod_entry_mode']);
@ -774,20 +775,25 @@ elseif ($action == 'edit' && $user->rights->fournisseur->facture->creer)
{ {
$object->set_draft($user); $object->set_draft($user);
$outputlangs = $langs; // Define output language
if (! empty($_REQUEST['lang_id'])) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{ {
$outputlangs = new Translate("",$conf); $outputlangs = $langs;
$outputlangs->setDefaultLang($_REQUEST['lang_id']); $newlang = '';
} if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if (! empty($newlang)) {
if ($result <= 0) $outputlangs = new Translate("", $conf);
{ $outputlangs->setDefaultLang($newlang);
dol_print_error($db,$result); }
exit; $model=$object->modelpdf;
} if (empty($model)) {
} $tmp=getListOfModels($db, 'invoice_supplier'); $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);
}
$action=''; $action='';
} }
@ -2288,21 +2294,24 @@ else
*/ */
$somethingshown=$object->showLinkedObjectBlock(); $somethingshown=$object->showLinkedObjectBlock();
$linktoelem='';
if (empty($somethingshown) && ! empty($conf->fournisseur->enabled)) if (empty($somethingshown) && ! empty($conf->fournisseur->enabled))
{ {
print '<br><a href="#" id="linktoorder">' . $langs->trans('LinkedOrder') . '</a>'; $linktoelem.=($linktoelem?' &nbsp; ':'').'<a href="#" id="linktoorder">' . $langs->trans('LinkedOrder') . '</a>';
print ' print '
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
jQuery(document).ready(function() { jQuery(document).ready(function() {
jQuery("#linktoorder").click(function() { jQuery("#linktoorder").click(function() {
jQuery("#commande").toggle(); jQuery("#orderlist").toggle();
}); jQuery("#linktoorder").toggle();
});
}); });
</script> </script>
'; ';
print '<div id="commande" style="display:none">'; print '<div id="orderlist" style="display:none">';
$sql = "SELECT s.rowid as socid, s.nom as name, s.client, c.rowid, c.ref, c.ref_supplier, c.total_ht"; $sql = "SELECT s.rowid as socid, s.nom as name, s.client, c.rowid, c.ref, c.ref_supplier, c.total_ht";
$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
@ -2314,7 +2323,7 @@ else
$num = $db->num_rows($resqlorderlist); $num = $db->num_rows($resqlorderlist);
$i = 0; $i = 0;
print '<form action="" method="POST" name="LinkedOrder">'; print '<br><form action="" method="POST" name="LinkedOrder">';
print '<table class="noborder">'; print '<table class="noborder">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="nowrap"></td>'; print '<td class="nowrap"></td>';
@ -2341,7 +2350,7 @@ else
$i ++; $i ++;
} }
print '</table>'; print '</table>';
print '<br><center><input type="submit" class="button" value="' . $langs->trans('ToLink') . '"></center>'; print '<br><center><input type="submit" class="button" value="' . $langs->trans('ToLink') . '"> &nbsp; <input type="submit" class="button" name="cancel" value="' . $langs->trans('Cancel') . '"></center>';
print '</form>'; print '</form>';
$db->free($resqlorderlist); $db->free($resqlorderlist);
} else { } else {
@ -2351,6 +2360,9 @@ else
print '</div>'; print '</div>';
} }
// Show link to elements
if ($linktoelem) print '<br>'.$linktoelem;
print '</div><div class="fichehalfright"><div class="ficheaddleft">'; print '</div><div class="fichehalfright"><div class="ficheaddleft">';
//print '</td><td valign="top" width="50%">'; //print '</td><td valign="top" width="50%">';
//print '<br>'; //print '<br>';

View File

@ -32,6 +32,7 @@ echo '<br>';
if ($num > 1) print_titre($langs->trans("RelatedBills")); if ($num > 1) print_titre($langs->trans("RelatedBills"));
else print_titre($langs->trans("RelatedBill")); else print_titre($langs->trans("RelatedBill"));
?> ?>
<table class="noborder allwidth"> <table class="noborder allwidth">
<tr class="liste_titre"> <tr class="liste_titre">
<td><?php echo $langs->trans("Ref"); ?></td> <td><?php echo $langs->trans("Ref"); ?></td>

View File

@ -257,7 +257,7 @@ print_liste_field_titre($langs->trans("Employe"),$_SERVER["PHP_SELF"],"cp.fk_use
print_liste_field_titre($langs->trans("ValidatorCP"),$_SERVER["PHP_SELF"],"cp.fk_validator","",'','',$sortfield,$sortorder); print_liste_field_titre($langs->trans("ValidatorCP"),$_SERVER["PHP_SELF"],"cp.fk_validator","",'','',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateDebCP"),$_SERVER["PHP_SELF"],"cp.date_debut","",'','align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateDebCP"),$_SERVER["PHP_SELF"],"cp.date_debut","",'','align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateFinCP"),$_SERVER["PHP_SELF"],"cp.date_fin","",'','align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateFinCP"),$_SERVER["PHP_SELF"],"cp.date_fin","",'','align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Duration")); print_liste_field_titre($langs->trans("Duration"),$_SERVER["PHP_SELF"],'','','','align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"cp.statut","",'','align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"cp.statut","",'','align="center"',$sortfield,$sortorder);
print '<td></td>'; print '<td></td>';
print "</tr>\n"; print "</tr>\n";

View File

@ -24,6 +24,7 @@
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_CLASSIFYBILLED','Intervention set billed','Executed when a intervention is set to billed (when option FICHINTER_DISABLE_DETAILS is set)','ficheinter',19); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_CLASSIFYBILLED','Intervention set billed','Executed when a intervention is set to billed (when option FICHINTER_DISABLE_DETAILS is set)','ficheinter',19);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_SENTBYMAIL','Intervention sent by mail','Executed when a intervention is sent by mail','ficheinter',19); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_SENTBYMAIL','Intervention sent by mail','Executed when a intervention is sent by mail','ficheinter',19);
ALTER TABLE llx_notify ADD COLUMN fk_soc integer NULL after fk_action;
ALTER TABLE llx_bank_account ADD COLUMN fk_user_author integer; ALTER TABLE llx_bank_account ADD COLUMN fk_user_author integer;

View File

@ -23,6 +23,7 @@ create table llx_notify
tms timestamp, tms timestamp,
daten datetime, -- date de la notification daten datetime, -- date de la notification
fk_action integer NOT NULL, fk_action integer NOT NULL,
fk_soc integer NULL,
fk_contact integer NULL, fk_contact integer NULL,
fk_user integer NULL, fk_user integer NULL,
objet_type varchar(24) NOT NULL, objet_type varchar(24) NOT NULL,

View File

@ -484,7 +484,7 @@ Module500Desc=Management of special expenses like taxes, social contribution, di
Module510Name=Salaries Module510Name=Salaries
Module510Desc=Management of employees salaries and payments Module510Desc=Management of employees salaries and payments
Module600Name=Notifications Module600Name=Notifications
Module600Desc=Send notifications by email on some Dolibarr business events to third party contacts Module600Desc=Send EMail notifications on some Dolibarr business events to third-party contacts (setup defined on each thirdparty)
Module700Name=Donations Module700Name=Donations
Module700Desc=Donation management Module700Desc=Donation management
Module1200Name=Mantis Module1200Name=Mantis
@ -611,10 +611,11 @@ Permission162=Create/modify contracts
Permission163=Activate a service of a contract Permission163=Activate a service of a contract
Permission164=Disable a service of a contract Permission164=Disable a service of a contract
Permission165=Delete contracts Permission165=Delete contracts
Permission171=Read trips Permission171=Read trips and expenses (own and his subordinates)
Permission172=Create/modify trips Permission172=Create/modify trips and expenses
Permission173=Delete trips Permission173=Delete trips and expenses
Permission178=Export trips Permission174=Read all trips and expenses
Permission178=Export trips and expenses
Permission180=Read suppliers Permission180=Read suppliers
Permission181=Read supplier orders Permission181=Read supplier orders
Permission182=Create/modify supplier orders Permission182=Create/modify supplier orders
@ -1074,7 +1075,7 @@ ModuleCompanyCodeAquarium=Return an accountancy code built by:<br>%s followed by
ModuleCompanyCodePanicum=Return an empty accountancy code. ModuleCompanyCodePanicum=Return an empty accountancy code.
ModuleCompanyCodeDigitaria=Accountancy code depends on third party code. The code is composed of the character "C" in the first position followed by the first 5 characters of the third party code. ModuleCompanyCodeDigitaria=Accountancy code depends on third party code. The code is composed of the character "C" in the first position followed by the first 5 characters of the third party code.
UseNotifications=Use notifications UseNotifications=Use notifications
NotificationsDesc=EMails notifications feature allows you to silently send automatic mail, for some Dolibarr events, to third parties (customers or suppliers) that are configured to. Choice of active notification and targets contacts is made one third party at time. NotificationsDesc=EMails notifications feature allows you to silently send automatic mail, for some Dolibarr events. Targets of notifications can be defined:<br>* per third parties contacts (customers or suppliers), one third party at time.<br>* or by setting a global target email address on module setup page.
ModelModules=Documents templates ModelModules=Documents templates
DocumentModelOdt=Generate documents from OpenDocuments templates (.ODT or .ODS files for OpenOffice, KOffice, TextEdit,...) DocumentModelOdt=Generate documents from OpenDocuments templates (.ODT or .ODS files for OpenOffice, KOffice, TextEdit,...)
WatermarkOnDraft=Watermark on draft document WatermarkOnDraft=Watermark on draft document
@ -1382,9 +1383,10 @@ MailingSetup=EMailing module setup
MailingEMailFrom=Sender EMail (From) for emails sent by emailing module MailingEMailFrom=Sender EMail (From) for emails sent by emailing module
MailingEMailError=Return EMail (Errors-to) for emails with errors MailingEMailError=Return EMail (Errors-to) for emails with errors
##### Notification ##### ##### Notification #####
NotificationSetup=Notification bu email module setup NotificationSetup=EMail notification module setup
NotificationEMailFrom=Sender EMail (From) for emails sent for notifications NotificationEMailFrom=Sender EMail (From) for emails sent for notifications
ListOfAvailableNotifications=List of available notifications (This list depends on activated modules) ListOfAvailableNotifications=List of events you can set notification on, for each thirdparty (go into thirdparty card to setup) or by setting a fixed email (List depends on activated modules)
FixedEmailTarget=Fixed email target
##### Sendings ##### ##### Sendings #####
SendingsSetup=Sending module setup SendingsSetup=Sending module setup
SendingsReceiptModel=Sending receipt model SendingsReceiptModel=Sending receipt model

View File

@ -28,8 +28,8 @@ InvoiceAvoir=Credit note
InvoiceAvoirAsk=Credit note to correct invoice InvoiceAvoirAsk=Credit note to correct invoice
InvoiceAvoirDesc=The <b>credit note</b> is a negative invoice used to solve fact that an invoice has an amount that differs than amount really paid (because customer paid too much by error, or will not paid completely since he returned some products for example). InvoiceAvoirDesc=The <b>credit note</b> is a negative invoice used to solve fact that an invoice has an amount that differs than amount really paid (because customer paid too much by error, or will not paid completely since he returned some products for example).
invoiceAvoirWithLines=Create Credit Note with lines from the origin invoice invoiceAvoirWithLines=Create Credit Note with lines from the origin invoice
invoiceAvoirWithPaymentRestAmount=Create Credit Note with the amount of origin invoice payment's lake invoiceAvoirWithPaymentRestAmount=Create Credit Note with remaining unpaid of origin invoice
invoiceAvoirLineWithPaymentRestAmount=Credit Note amount of invoice payment's lake invoiceAvoirLineWithPaymentRestAmount=Credit Note for remaining unpaid amount
ReplaceInvoice=Replace invoice %s ReplaceInvoice=Replace invoice %s
ReplacementInvoice=Replacement invoice ReplacementInvoice=Replacement invoice
ReplacedByInvoice=Replaced by invoice %s ReplacedByInvoice=Replaced by invoice %s
@ -99,7 +99,7 @@ DoPaymentBack=Do payment back
ConvertToReduc=Convert into future discount ConvertToReduc=Convert into future discount
EnterPaymentReceivedFromCustomer=Enter payment received from customer EnterPaymentReceivedFromCustomer=Enter payment received from customer
EnterPaymentDueToCustomer=Make payment due to customer EnterPaymentDueToCustomer=Make payment due to customer
DisabledBecauseRemainderToPayIsZero=Disabled because remainder to pay is zero DisabledBecauseRemainderToPayIsZero=Disabled because remaining unpaid is zero
Amount=Amount Amount=Amount
PriceBase=Price base PriceBase=Price base
BillStatus=Invoice status BillStatus=Invoice status
@ -156,9 +156,9 @@ ConfirmCancelBill=Are you sure you want to cancel invoice <b>%s</b> ?
ConfirmCancelBillQuestion=Why do you want to classify this invoice 'abandoned' ? ConfirmCancelBillQuestion=Why do you want to classify this invoice 'abandoned' ?
ConfirmClassifyPaidPartially=Are you sure you want to change invoice <b>%s</b> to status paid ? ConfirmClassifyPaidPartially=Are you sure you want to change invoice <b>%s</b> to status paid ?
ConfirmClassifyPaidPartiallyQuestion=This invoice has not been paid completely. What are reasons for you to close this invoice ? ConfirmClassifyPaidPartiallyQuestion=This invoice has not been paid completely. What are reasons for you to close this invoice ?
ConfirmClassifyPaidPartiallyReasonAvoir=Remainder to pay <b>(%s %s)</b> is a discount granted because payment was made before term. I regularise the VAT with a credit note. ConfirmClassifyPaidPartiallyReasonAvoir=Remaining unpaid <b>(%s %s)</b> is a discount granted because payment was made before term. I regularise the VAT with a credit note.
ConfirmClassifyPaidPartiallyReasonDiscountNoVat=Remainder to pay <b>(%s %s)</b> is a discount granted because payment was made before term. I accept to lose the VAT on this discount. ConfirmClassifyPaidPartiallyReasonDiscountNoVat=Remaining unpaid <b>(%s %s)</b> is a discount granted because payment was made before term. I accept to lose the VAT on this discount.
ConfirmClassifyPaidPartiallyReasonDiscountVat=Remainder to pay <b>(%s %s)</b> is a discount granted because payment was made before term. I recover the VAT on this discount without a credit note. ConfirmClassifyPaidPartiallyReasonDiscountVat=Remaining unpaid <b>(%s %s)</b> is a discount granted because payment was made before term. I recover the VAT on this discount without a credit note.
ConfirmClassifyPaidPartiallyReasonBadCustomer=Bad customer ConfirmClassifyPaidPartiallyReasonBadCustomer=Bad customer
ConfirmClassifyPaidPartiallyReasonProductReturned=Products partially returned ConfirmClassifyPaidPartiallyReasonProductReturned=Products partially returned
ConfirmClassifyPaidPartiallyReasonOther=Amount abandoned for other reason ConfirmClassifyPaidPartiallyReasonOther=Amount abandoned for other reason
@ -191,9 +191,9 @@ AlreadyPaid=Already paid
AlreadyPaidBack=Already paid back AlreadyPaidBack=Already paid back
AlreadyPaidNoCreditNotesNoDeposits=Already paid (without credit notes and deposits) AlreadyPaidNoCreditNotesNoDeposits=Already paid (without credit notes and deposits)
Abandoned=Abandoned Abandoned=Abandoned
RemainderToPay=Remainder to pay RemainderToPay=Remaining unpaid
RemainderToTake=Remainder to take RemainderToTake=Remaining amount to take
RemainderToPayBack=Remainder to pay back RemainderToPayBack=Remaining amount to pay back
Rest=Pending Rest=Pending
AmountExpected=Amount claimed AmountExpected=Amount claimed
ExcessReceived=Excess received ExcessReceived=Excess received

View File

@ -12,6 +12,7 @@ BoxLastProspects=Last modified prospects
BoxLastCustomers=Last modified customers BoxLastCustomers=Last modified customers
BoxLastSuppliers=Last modified suppliers BoxLastSuppliers=Last modified suppliers
BoxLastCustomerOrders=Last customer orders BoxLastCustomerOrders=Last customer orders
BoxLastValidatedCustomerOrders=Last validated customer orders
BoxLastBooks=Last books BoxLastBooks=Last books
BoxLastActions=Last actions BoxLastActions=Last actions
BoxLastContracts=Last contracts BoxLastContracts=Last contracts
@ -27,26 +28,29 @@ BoxTitleNbOfCustomers=Number of clients
BoxTitleLastRssInfos=Last %s news from %s BoxTitleLastRssInfos=Last %s news from %s
BoxTitleLastProducts=Last %s modified products/services BoxTitleLastProducts=Last %s modified products/services
BoxTitleProductsAlertStock=Products in stock alert BoxTitleProductsAlertStock=Products in stock alert
BoxTitleLastCustomerOrders=Last %s modified customer orders BoxTitleLastCustomerOrders=Last %s customer orders
BoxTitleLastModifiedCustomerOrders=Last %s modified customer orders
BoxTitleLastSuppliers=Last %s recorded suppliers BoxTitleLastSuppliers=Last %s recorded suppliers
BoxTitleLastCustomers=Last %s recorded customers BoxTitleLastCustomers=Last %s recorded customers
BoxTitleLastModifiedSuppliers=Last %s modified suppliers BoxTitleLastModifiedSuppliers=Last %s modified suppliers
BoxTitleLastModifiedCustomers=Last %s modified customers BoxTitleLastModifiedCustomers=Last %s modified customers
BoxTitleLastCustomersOrProspects=Last %s modified customers or prospects BoxTitleLastCustomersOrProspects=Last %s customers or prospects
BoxTitleLastPropals=Last %s recorded proposals BoxTitleLastPropals=Last %s proposals
BoxTitleLastModifiedPropals=Last %s modified proposals
BoxTitleLastCustomerBills=Last %s customer's invoices BoxTitleLastCustomerBills=Last %s customer's invoices
BoxTitleLastModifiedCustomerBills=Last %s modified customer invoices
BoxTitleLastSupplierBills=Last %s supplier's invoices BoxTitleLastSupplierBills=Last %s supplier's invoices
BoxTitleLastProspects=Last %s recorded prospects BoxTitleLastModifiedSupplierBills=Last %s modified supplier invoices
BoxTitleLastModifiedProspects=Last %s modified prospects BoxTitleLastModifiedProspects=Last %s modified prospects
BoxTitleLastProductsInContract=Last %s products/services in a contract BoxTitleLastProductsInContract=Last %s products/services in a contract
BoxTitleLastModifiedMembers=Last %s modified members BoxTitleLastModifiedMembers=Last %s members
BoxTitleLastFicheInter=Last %s modified intervention BoxTitleLastFicheInter=Last %s modified intervention
BoxTitleOldestUnpaidCustomerBills=Oldest %s unpaid customer's invoices BoxTitleOldestUnpaidCustomerBills=Oldest %s unpaid customer invoices
BoxTitleOldestUnpaidSupplierBills=Oldest %s unpaid supplier's invoices BoxTitleOldestUnpaidSupplierBills=Oldest %s unpaid supplier invoices
BoxTitleCurrentAccounts=Opened account's balances BoxTitleCurrentAccounts=Opened account's balances
BoxTitleSalesTurnover=Sales turnover BoxTitleSalesTurnover=Sales turnover
BoxTitleTotalUnpaidCustomerBills=Unpaid customer's invoices BoxTitleTotalUnpaidCustomerBills=Unpaid customer invoices
BoxTitleTotalUnpaidSuppliersBills=Unpaid supplier's invoices BoxTitleTotalUnpaidSuppliersBills=Unpaid supplier invoices
BoxTitleLastModifiedContacts=Last %s modified contacts/addresses BoxTitleLastModifiedContacts=Last %s modified contacts/addresses
BoxMyLastBookmarks=My last %s bookmarks BoxMyLastBookmarks=My last %s bookmarks
BoxOldestExpiredServices=Oldest active expired services BoxOldestExpiredServices=Oldest active expired services
@ -76,7 +80,8 @@ NoContractedProducts=No products/services contracted
NoRecordedContracts=No recorded contracts NoRecordedContracts=No recorded contracts
NoRecordedInterventions=No recorded interventions NoRecordedInterventions=No recorded interventions
BoxLatestSupplierOrders=Latest supplier orders BoxLatestSupplierOrders=Latest supplier orders
BoxTitleLatestSupplierOrders=%s latest supplier orders BoxTitleLatestSupplierOrders=Last %s supplier orders
BoxTitleLatestModifiedSupplierOrders=Last %s modified supplier orders
NoSupplierOrder=No recorded supplier order NoSupplierOrder=No recorded supplier order
BoxCustomersInvoicesPerMonth=Customer invoices per month BoxCustomersInvoicesPerMonth=Customer invoices per month
BoxSuppliersInvoicesPerMonth=Supplier invoices per month BoxSuppliersInvoicesPerMonth=Supplier invoices per month

View File

@ -114,6 +114,7 @@ ErrorLoginDoesNotExists=User with login <b>%s</b> could not be found.
ErrorLoginHasNoEmail=This user has no email address. Process aborted. ErrorLoginHasNoEmail=This user has no email address. Process aborted.
ErrorBadValueForCode=Bad value for security code. Try again with new value... ErrorBadValueForCode=Bad value for security code. Try again with new value...
ErrorBothFieldCantBeNegative=Fields %s and %s can't be both negative ErrorBothFieldCantBeNegative=Fields %s and %s can't be both negative
ErrorQtyForCustomerInvoiceCantBeNegative=Quantity for line into customer invoices can't be negative
ErrorWebServerUserHasNotPermission=User account <b>%s</b> used to execute web server has no permission for that ErrorWebServerUserHasNotPermission=User account <b>%s</b> used to execute web server has no permission for that
ErrorNoActivatedBarcode=No barcode type activated ErrorNoActivatedBarcode=No barcode type activated
ErrUnzipFails=Failed to unzip %s with ZipArchive ErrUnzipFails=Failed to unzip %s with ZipArchive

View File

@ -133,6 +133,6 @@ Notifications=Notifications
NoNotificationsWillBeSent=No email notifications are planned for this event and company NoNotificationsWillBeSent=No email notifications are planned for this event and company
ANotificationsWillBeSent=1 notification will be sent by email ANotificationsWillBeSent=1 notification will be sent by email
SomeNotificationsWillBeSent=%s notifications will be sent by email SomeNotificationsWillBeSent=%s notifications will be sent by email
AddNewNotification=Activate a new email notification request AddNewNotification=Activate a new email notification target
ListOfActiveNotifications=List all active email notification requests ListOfActiveNotifications=List all active email notification targets
ListOfNotificationsDone=List all email notifications sent ListOfNotificationsDone=List all email notifications sent

View File

@ -38,4 +38,6 @@ BuyingCost=Cost price
UnitCharges=Unit charges UnitCharges=Unit charges
Charges=Charges Charges=Charges
AgentContactType=Commercial agent contact type AgentContactType=Commercial agent contact type
AgentContactTypeDetails=Défine what contact type (linked on invoices) will be used for margin report by commercial agents AgentContactTypeDetails=Define what contact type (linked on invoices) will be used for margin report per sale representative
rateMustBeNumeric=Rate must be a numeric value
markRateShouldBeLesserThan100=Mark rate should be lower than 100

View File

@ -47,6 +47,7 @@ Notify_PROJECT_CREATE=Project creation
Notify_TASK_CREATE=Task created Notify_TASK_CREATE=Task created
Notify_TASK_MODIFY=Task modified Notify_TASK_MODIFY=Task modified
Notify_TASK_DELETE=Task deleted Notify_TASK_DELETE=Task deleted
SeeModuleSetup=See module setup
NbOfAttachedFiles=Number of attached files/documents NbOfAttachedFiles=Number of attached files/documents
TotalSizeOfAttachedFiles=Total size of attached files/documents TotalSizeOfAttachedFiles=Total size of attached files/documents
MaxSize=Maximum size MaxSize=Maximum size

View File

@ -14,8 +14,8 @@ WithdrawalReceiptShort=Receipt
LastWithdrawalReceipts=Last %s withdrawal receipts LastWithdrawalReceipts=Last %s withdrawal receipts
WithdrawedBills=Withdrawn invoices WithdrawedBills=Withdrawn invoices
WithdrawalsLines=Withdrawal lines WithdrawalsLines=Withdrawal lines
RequestStandingOrderToTreat=Request for standing orders to treat RequestStandingOrderToTreat=Request for standing orders to process
RequestStandingOrderTreated=Request for standing orders treated RequestStandingOrderTreated=Request for standing orders processed
CustomersStandingOrders=Customer standing orders CustomersStandingOrders=Customer standing orders
CustomerStandingOrder=Customer standing order CustomerStandingOrder=Customer standing order
NbOfInvoiceToWithdraw=Nb. of invoice with withdraw request NbOfInvoiceToWithdraw=Nb. of invoice with withdraw request

View File

@ -12,6 +12,7 @@ BoxLastProspects=Derniers prospects modifiés
BoxLastCustomers=Derniers clients modifiés BoxLastCustomers=Derniers clients modifiés
BoxLastSuppliers=Derniers fournisseurs modifiés BoxLastSuppliers=Derniers fournisseurs modifiés
BoxLastCustomerOrders=Dernières commandes BoxLastCustomerOrders=Dernières commandes
BoxLastValidatedCustomerOrders=Dernières commandes clients validées
BoxLastBooks=Derniers livres BoxLastBooks=Derniers livres
BoxLastActions=Derniers événements BoxLastActions=Derniers événements
BoxLastContracts=Derniers contrats BoxLastContracts=Derniers contrats
@ -27,26 +28,29 @@ BoxTitleNbOfCustomers=Nombre de clients
BoxTitleLastRssInfos=Les %s dernières informations de %s BoxTitleLastRssInfos=Les %s dernières informations de %s
BoxTitleLastProducts=Les %s derniers produits/services enregistrés BoxTitleLastProducts=Les %s derniers produits/services enregistrés
BoxTitleProductsAlertStock=Produits en alerte stock BoxTitleProductsAlertStock=Produits en alerte stock
BoxTitleLastCustomerOrders=Les %s dernières commandes clients modifiées BoxTitleLastCustomerOrders=Les %s dernières commandes clients
BoxTitleLastModifiedCustomerOrders=Les %s dernières commandes clients modifiées
BoxTitleLastSuppliers=Les %s derniers fournisseurs enregistrés BoxTitleLastSuppliers=Les %s derniers fournisseurs enregistrés
BoxTitleLastCustomers=Les %s derniers clients enregistrés BoxTitleLastCustomers=Les %s derniers clients enregistrés
BoxTitleLastModifiedSuppliers=Les %s derniers fournisseurs modifiés BoxTitleLastModifiedSuppliers=Les %s derniers fournisseurs modifiés
BoxTitleLastModifiedCustomers=Les %s derniers clients modifiés BoxTitleLastModifiedCustomers=Les %s derniers clients modifiés
BoxTitleLastCustomersOrProspects=Les %s derniers clients ou prospects modifiés BoxTitleLastCustomersOrProspects=Les %s derniers prospects
BoxTitleLastPropals=Les %s dernières propositions enregistrées BoxTitleLastPropals=Les %s dernières propales
BoxTitleLastCustomerBills=Les %s dernières factures clients modifiées BoxTitleLastModifiedPropals=Les %s dernières propositions commerciales modifiées
BoxTitleLastSupplierBills=Les %s dernières factures fournisseurs modifiées BoxTitleLastCustomerBills=Les %s dernières factures clients
BoxTitleLastProspects=Les %s derniers prospects enregistrés BoxTitleLastModifiedCustomerBills=Les %s dernières factures clients modifiées
BoxTitleLastSupplierBills=Les %s dernières factures fournisseurs
BoxTitleLastModifiedSupplierBills=Les %s dernières factures fournisseurs modifiées
BoxTitleLastModifiedProspects=Les %s derniers prospects modifiés BoxTitleLastModifiedProspects=Les %s derniers prospects modifiés
BoxTitleLastProductsInContract=Les %s derniers produits/services contractés BoxTitleLastProductsInContract=Les %s derniers produits/services contractés
BoxTitleLastModifiedMembers=Les %s derniers adhérents modifiés BoxTitleLastModifiedMembers=Les %s derniers adhérents
BoxTitleLastFicheInter=Les %s dernières fiches d'intervention modifiées BoxTitleLastFicheInter=Les %s dernières fiche d'intervention modifiée
BoxTitleOldestUnpaidCustomerBills=Les %s plus anciennes factures clients impayées BoxTitleOldestUnpaidCustomerBills=Les %s plus anciennes factures clients impayées
BoxTitleOldestUnpaidSupplierBills=Les %s plus anciennes factures fournisseurs impayées BoxTitleOldestUnpaidSupplierBills=Les %s plus anciennes factures fournisseurs impayées
BoxTitleCurrentAccounts=Soldes des comptes ouverts BoxTitleCurrentAccounts=Soldes des comptes ouverts
BoxTitleSalesTurnover=Le chiffre d'affaires réalisé BoxTitleSalesTurnover=Le chiffre d'affaires réalisé
BoxTitleTotalUnpaidCustomerBills=Impayés clients BoxTitleTotalUnpaidCustomerBills=Factures clients impayées
BoxTitleTotalUnpaidSuppliersBills=Impayés fournisseurs BoxTitleTotalUnpaidSuppliersBills=Factures fournisseurs impayées
BoxTitleLastModifiedContacts=Les %s derniers contacts/adresses modifiés BoxTitleLastModifiedContacts=Les %s derniers contacts/adresses modifiés
BoxMyLastBookmarks=Mes %s derniers marque-pages BoxMyLastBookmarks=Mes %s derniers marque-pages
BoxOldestExpiredServices=Plus anciens services expirés BoxOldestExpiredServices=Plus anciens services expirés
@ -76,7 +80,8 @@ NoContractedProducts=Pas de produit/service contracté
NoRecordedContracts=Pas de contrat enregistré NoRecordedContracts=Pas de contrat enregistré
NoRecordedInterventions=Pas fiche d'intervention enregistrée NoRecordedInterventions=Pas fiche d'intervention enregistrée
BoxLatestSupplierOrders=Dernières commandes fournisseur BoxLatestSupplierOrders=Dernières commandes fournisseur
BoxTitleLatestSupplierOrders=Les %s dernières commandes fournisseur enregistrées BoxTitleLatestSupplierOrders=Les %s dernières commandes fournisseurs
BoxTitleLatestModifiedSupplierOrders=Les %s dernières commandes fournisseurs
NoSupplierOrder=Pas de commande fournisseur enregistrée NoSupplierOrder=Pas de commande fournisseur enregistrée
BoxCustomersInvoicesPerMonth=Factures clients par mois BoxCustomersInvoicesPerMonth=Factures clients par mois
BoxSuppliersInvoicesPerMonth=Factures fournisseurs par mois BoxSuppliersInvoicesPerMonth=Factures fournisseurs par mois

View File

@ -124,24 +124,23 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->exped
$result = $object->valid($user); $result = $object->valid($user);
// Define output language // 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->client->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))
{ {
$ret=$object->fetch($id); // Reload to get new records $outputlangs = $langs;
$result= $object->generateDocument($_REQUEST['model'],$outputlangs); $newlang = '';
} if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if ($result < 0) if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
{ if (! empty($newlang)) {
dol_print_error($db,$result); $outputlangs = new Translate("", $conf);
exit; $outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
if (empty($model)) {
$tmp=getListOfModels($db, 'delivery'); $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);
} }
} }

View File

@ -359,18 +359,21 @@ class Livraison extends CommonObject
$soc = new Societe($this->db); $soc = new Societe($this->db);
$soc->fetch($this->socid); $soc->fetch($this->socid);
// on verifie si le bon de livraison est en numerotation provisoire if (preg_match('/^[\(]?PROV/i', $this->ref))
$livref = substr($this->ref, 1, 4); {
if ($livref == 'PROV') $numref = $objMod->livraison_get_num($soc,$this);
}
else
{ {
$numref = $objMod->livraison_get_num($soc,$this); $numref = $this->ref;
} }
$this->newref = $numref;
// Tester si non deja au statut valide. Si oui, on arrete afin d'eviter // Tester si non deja au statut valide. Si oui, on arrete afin d'eviter
// de decrementer 2 fois le stock. // de decrementer 2 fois le stock.
$sql = "SELECT ref"; $sql = "SELECT ref";
$sql.= " FROM ".MAIN_DB_PREFIX."livraison"; $sql.= " FROM ".MAIN_DB_PREFIX."livraison";
$sql.= " WHERE ref = '".$numref."'"; $sql.= " WHERE ref = '".$this->db->escape($numref)."'";
$sql.= " AND fk_statut <> 0"; $sql.= " AND fk_statut <> 0";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
@ -393,10 +396,24 @@ class Livraison extends CommonObject
$sql.= " AND fk_statut = 0"; $sql.= " AND fk_statut = 0";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if (! $resql)
{ {
dol_print_error($this->db);
$this->error=$this->db->lasterror();
$error++;
}
$this->oldref=''; if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('DELIVERY_VALIDATE',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->oldref = $this->ref;
// Rename directory if dir was a temporary ref // Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref)) if (preg_match('/^[\(]?PROV/i', $this->ref))
@ -413,11 +430,17 @@ class Livraison extends CommonObject
if (@rename($dirsource, $dirdest)) if (@rename($dirsource, $dirdest))
{ {
$this->oldref = $oldref; dol_syslog("Rename ok");
// Rename docs starting with $oldref with $newref
dol_syslog("Rename ok"); $listoffiles=dol_dir_list($conf->expedition->dir_output.'/receipt/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/'));
// Suppression ancien fichier PDF dans nouveau rep foreach($listoffiles as $fileentry)
dol_delete_file($dirdest.'/'.$oldref.'*.*'); {
$dirsource=$fileentry['name'];
$dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource);
$dirsource=$fileentry['path'].'/'.$dirsource;
$dirdest=$fileentry['path'].'/'.$dirdest;
@rename($dirsource, $dirdest);
}
} }
} }
} }
@ -431,12 +454,17 @@ class Livraison extends CommonObject
dol_syslog(get_class($this)."::valid ok"); dol_syslog(get_class($this)."::valid ok");
} }
else
if (! $error)
{
$this->db->commit();
return 1;
}
else
{ {
$this->db->rollback(); $this->db->rollback();
$this->error=$this->db->error()." - sql=$sql"; return -1;
return -1; }
}
} }
} }
} }
@ -446,21 +474,6 @@ class Livraison extends CommonObject
dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
return -1; return -1;
} }
// Call trigger
$result=$this->call_trigger('DELIVERY_VALIDATE',$user);
// End call triggers
if ($result < 0)
{
$this->db->rollback();
dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
return -1;
}
else
{
$this->db->commit();
return 1;
}
} }
/** /**

View File

@ -31,9 +31,9 @@ $langs->load("stocks");
// Security check // Security check
$result=restrictedArea($user,'stock'); $result=restrictedArea($user,'stock');
$sref=GETPOST("sref");; $sref=GETPOST("sref","alpha");
$snom=GETPOST("snom"); $snom=GETPOST("snom","alpha");
$sall=GETPOST("sall"); $sall=GETPOST("sall","alpha");
$sortfield = GETPOST("sortfield"); $sortfield = GETPOST("sortfield");
$sortorder = GETPOST("sortorder"); $sortorder = GETPOST("sortorder");

View File

@ -388,19 +388,38 @@ class Project extends CommonObject
/** /**
* Return list of elements for type linked to project * Return list of elements for type linked to project
* *
* @param string $type 'propal','order','invoice','order_supplier','invoice_supplier' * @param string $type 'propal','order','invoice','order_supplier','invoice_supplier'
* @param string $tablename name of table associated of the type * @param string $tablename name of table associated of the type
* @return array List of orders linked to project, <0 if error * @param string $datefieldname name of table associated of the type
* @param string $dates Start date (at 00:00:00)
* @param string $datee End date (at 23:00:00)
* @return mixed List of orders linked to project, < 0 or string if error
*/ */
function get_element_list($type, $tablename) function get_element_list($type, $tablename, $datefieldname='', $dates='', $datee='')
{ {
$elements = array(); $elements = array();
if ($type == 'agenda') if ($type == 'agenda')
{
$sql = "SELECT id as rowid FROM " . MAIN_DB_PREFIX . "actioncomm WHERE fk_project=" . $this->id; $sql = "SELECT id as rowid FROM " . MAIN_DB_PREFIX . "actioncomm WHERE fk_project=" . $this->id;
}
else else
{
$sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE fk_projet=" . $this->id; $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE fk_projet=" . $this->id;
if (! $sql) return -1; }
if ($dates > 0)
{
if (empty($datefieldname) && ! empty($this->table_element_date)) $datefieldname=$this->table_element_date;
if (empty($datefieldname)) return 'Error this object has no date field defined';
$sql.=" AND ".$datefieldname." >= '".$this->db->jdate($dates)."'";
}
if ($datee > 0)
{
if (empty($datefieldname) && ! empty($this->table_element_date)) $datefieldname=$this->table_element_date;
if (empty($datefieldname)) return 'Error this object has no date field defined';
$sql.=" AND ".$datefieldname." <= '".$this->db->jdate($datee)."'";
}
if (! $sql) return -1;
//print $sql; //print $sql;
dol_syslog(get_class($this)."::get_element_list", LOG_DEBUG); dol_syslog(get_class($this)."::get_element_list", LOG_DEBUG);

View File

@ -143,7 +143,7 @@ class Task extends CommonObject
} }
// Update extrafield // Update extrafield
if (! $error) if (! $error)
{ {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{ {
@ -480,15 +480,16 @@ class Task extends CommonObject
* *
* @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul * @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
* @param int $option Sur quoi pointe le lien * @param int $option Sur quoi pointe le lien
* @param int $mode Mode 'task', 'time', 'contact', 'note', document' define page to link to.
* @return string Chaine avec URL * @return string Chaine avec URL
*/ */
function getNomUrl($withpicto=0,$option='') function getNomUrl($withpicto=0,$option='',$mode='task')
{ {
global $langs; global $langs;
$result=''; $result='';
$lien = '<a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$this->id.($option=='withproject'?'&withproject=1':'').'">'; $lien = '<a href="'.DOL_URL_ROOT.'/projet/tasks/'.$mode.'.php?id='.$this->id.($option=='withproject'?'&withproject=1':'').'">';
$lienfin='</a>'; $lienfin='</a>';
$picto='projecttask'; $picto='projecttask';
@ -746,7 +747,7 @@ class Task extends CommonObject
// Clean parameters // Clean parameters
if (isset($this->timespent_note)) $this->timespent_note = trim($this->timespent_note); if (isset($this->timespent_note)) $this->timespent_note = trim($this->timespent_note);
if (empty($this->timespent_datehour)) $this->timespent_datehour = $this->timespent_date; if (empty($this->timespent_datehour)) $this->timespent_datehour = $this->timespent_date;
$this->db->begin(); $this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_time ("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_time (";
@ -832,9 +833,9 @@ class Task extends CommonObject
global $langs; global $langs;
if (empty($id)) $id=$this->id; if (empty($id)) $id=$this->id;
$result=array(); $result=array();
$sql = "SELECT"; $sql = "SELECT";
$sql.= " MIN(t.task_datehour) as min_date,"; $sql.= " MIN(t.task_datehour) as min_date,";
$sql.= " MAX(t.task_datehour) as max_date,"; $sql.= " MAX(t.task_datehour) as max_date,";
@ -925,7 +926,7 @@ class Task extends CommonObject
// Clean parameters // Clean parameters
if (empty($this->timespent_datehour)) $this->timespent_datehour = $this->timespent_date; if (empty($this->timespent_datehour)) $this->timespent_datehour = $this->timespent_date;
if (isset($this->timespent_note)) $this->timespent_note = trim($this->timespent_note); if (isset($this->timespent_note)) $this->timespent_note = trim($this->timespent_note);
$this->db->begin(); $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_time SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_time SET";

View File

@ -28,6 +28,7 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
@ -50,7 +51,20 @@ if (! empty($conf->ficheinter->enabled)) $langs->load("interventions");
$projectid=GETPOST('id','int'); $projectid=GETPOST('id','int');
$ref=GETPOST('ref','alpha'); $ref=GETPOST('ref','alpha');
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
$datesrfc=GETPOST('datesrfc');
$dateerfc=GETPOST('dateerfc');
$dates=dol_mktime(0, 0, 0, GETPOST('datesmonth'), GETPOST('datesday'), GETPOST('datesyear'));
$datee=dol_mktime(23, 59, 59, GETPOST('dateemonth'), GETPOST('dateeday'), GETPOST('dateeyear'));
if (empty($dates) && ! empty($datesrfc)) $dates=dol_stringtotime($datesrfc);
if (empty($datee) && ! empty($dateerfc)) $datee=dol_stringtotime($dateerfc);
if (! isset($_POST['datesrfc']) && ! isset($_POST['datesday']))
{
$new=dol_now();
$tmp=dol_getdate($new);
//$datee=$now
//$dates=dol_time_plus_duree($datee, -1, 'y');
$dates=dol_get_first_day($tmp['year'],1);
}
if ($projectid == '' && $ref == '') if ($projectid == '' && $ref == '')
{ {
dol_print_error('','Bad parameter'); dol_print_error('','Bad parameter');
@ -153,49 +167,58 @@ $listofreferent=array(
'title'=>"ListProposalsAssociatedProject", 'title'=>"ListProposalsAssociatedProject",
'class'=>'Propal', 'class'=>'Propal',
'table'=>'propal', 'table'=>'propal',
'datefieldname'=>'datep',
'test'=>$conf->propal->enabled && $user->rights->propale->lire), 'test'=>$conf->propal->enabled && $user->rights->propale->lire),
'order'=>array( 'order'=>array(
'title'=>"ListOrdersAssociatedProject", 'title'=>"ListOrdersAssociatedProject",
'class'=>'Commande', 'class'=>'Commande',
'table'=>'commande', 'table'=>'commande',
'datefieldname'=>'date_commande',
'test'=>$conf->commande->enabled && $user->rights->commande->lire), 'test'=>$conf->commande->enabled && $user->rights->commande->lire),
'invoice'=>array( 'invoice'=>array(
'title'=>"ListInvoicesAssociatedProject", 'title'=>"ListInvoicesAssociatedProject",
'class'=>'Facture', 'class'=>'Facture',
'margin'=>'add', 'margin'=>'add',
'table'=>'facture', 'table'=>'facture',
'datefieldname'=>'datef',
'test'=>$conf->facture->enabled && $user->rights->facture->lire), 'test'=>$conf->facture->enabled && $user->rights->facture->lire),
'invoice_predefined'=>array( 'invoice_predefined'=>array(
'title'=>"ListPredefinedInvoicesAssociatedProject", 'title'=>"ListPredefinedInvoicesAssociatedProject",
'class'=>'FactureRec', 'class'=>'FactureRec',
'table'=>'facture_rec', 'table'=>'facture_rec',
'datefieldname'=>'datec',
'test'=>$conf->facture->enabled && $user->rights->facture->lire), 'test'=>$conf->facture->enabled && $user->rights->facture->lire),
'order_supplier'=>array( 'order_supplier'=>array(
'title'=>"ListSupplierOrdersAssociatedProject", 'title'=>"ListSupplierOrdersAssociatedProject",
'class'=>'CommandeFournisseur', 'class'=>'CommandeFournisseur',
'table'=>'commande_fournisseur', 'table'=>'commande_fournisseur',
'datefieldname'=>'date_commande',
'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire), 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire),
'invoice_supplier'=>array( 'invoice_supplier'=>array(
'title'=>"ListSupplierInvoicesAssociatedProject", 'title'=>"ListSupplierInvoicesAssociatedProject",
'class'=>'FactureFournisseur', 'class'=>'FactureFournisseur',
'margin'=>'minus', 'margin'=>'minus',
'table'=>'facture_fourn', 'table'=>'facture_fourn',
'datefieldname'=>'datef',
'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire), 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire),
'contract'=>array( 'contract'=>array(
'title'=>"ListContractAssociatedProject", 'title'=>"ListContractAssociatedProject",
'class'=>'Contrat', 'class'=>'Contrat',
'table'=>'contrat', 'table'=>'contrat',
'datefieldname'=>'date_contrat',
'test'=>$conf->contrat->enabled && $user->rights->contrat->lire), 'test'=>$conf->contrat->enabled && $user->rights->contrat->lire),
'intervention'=>array( 'intervention'=>array(
'title'=>"ListFichinterAssociatedProject", 'title'=>"ListFichinterAssociatedProject",
'class'=>'Fichinter', 'class'=>'Fichinter',
'table'=>'fichinter', 'table'=>'fichinter',
'datefieldname'=>'date_valid',
'disableamount'=>1, 'disableamount'=>1,
'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire), 'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire),
'trip'=>array( 'trip'=>array(
'title'=>"ListTripAssociatedProject", 'title'=>"ListTripAssociatedProject",
'class'=>'Deplacement', 'class'=>'Deplacement',
'table'=>'deplacement', 'table'=>'deplacement',
'datefieldname'=>'dated',
'margin'=>'minus', 'margin'=>'minus',
'disableamount'=>1, 'disableamount'=>1,
'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire), 'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire),
@ -203,6 +226,7 @@ $listofreferent=array(
'title'=>"ListActionsAssociatedProject", 'title'=>"ListActionsAssociatedProject",
'class'=>'ActionComm', 'class'=>'ActionComm',
'table'=>'actioncomm', 'table'=>'actioncomm',
'datefieldname'=>'datep',
'disableamount'=>1, 'disableamount'=>1,
'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->lire) 'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->lire)
); );
@ -216,25 +240,49 @@ if ($action=="addelement")
setEventMessage($mailchimp->error,'errors'); setEventMessage($mailchimp->error,'errors');
} }
}elseif ($action == "unlink") { }elseif ($action == "unlink") {
$tablename = GETPOST("tablename"); $tablename = GETPOST("tablename");
$elementselectid = GETPOST("elementselect"); $elementselectid = GETPOST("elementselect");
$result = $project->remove_element($tablename, $elementselectid); $result = $project->remove_element($tablename, $elementselectid);
if ($result < 0) { if ($result < 0) {
setEventMessage($project->error, 'errors'); setEventMessage($project->error, 'errors');
} }
} }
$showdatefilter=0;
foreach ($listofreferent as $key => $value) foreach ($listofreferent as $key => $value)
{ {
$title=$value['title']; $title=$value['title'];
$classname=$value['class']; $classname=$value['class'];
$tablename=$value['table']; $tablename=$value['table'];
$datefieldname=$value['datefieldname'];
$qualified=$value['test']; $qualified=$value['test'];
if ($qualified) if ($qualified)
{ {
if (! $showdatefilter)
{
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$projectid.'" method="post">';
print '<input type="hidden" name="tablename" value="'.$tablename.'">';
print '<input type="hidden" name="action" value="addelement">';
print '<table><tr>';
//print '<td>'.$langs->trans("Filter").':</td>';
print '<td>'.$langs->trans("From").' ';
print $form->select_date($dates,'dates',0,0,1);
print '</td>';
print '<td>'.$langs->trans("to").' ';
print $form->select_date($datee,'datee',0,0,1);
print '</td>';
print '<td>';
print '<input type="submit" name="refresh" value="'.$langs->trans("Refresh").'" class="button">';
print '</td>';
print '</tr></table>';
print '</form><br>';
$showdatefilter++;
}
print '<br>'; print '<br>';
print_titre($langs->trans($title)); print_titre($langs->trans($title));
@ -247,6 +295,8 @@ foreach ($listofreferent as $key => $value)
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$projectid.'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$projectid.'" method="post">';
print '<input type="hidden" name="tablename" value="'.$tablename.'">'; print '<input type="hidden" name="tablename" value="'.$tablename.'">';
print '<input type="hidden" name="action" value="addelement">'; print '<input type="hidden" name="action" value="addelement">';
print '<input type="hidden" name="datesrfc" value="'.dol_print_date($dates,'dayhourrfc').'">';
print '<input type="hidden" name="dateerfc" value="'.dol_print_date($datee,'dayhourrfc').'">';
print '<table><tr><td>'.$langs->trans("SelectElement").'</td>'; print '<table><tr><td>'.$langs->trans("SelectElement").'</td>';
print '<td>'.$selectList.'</td>'; print '<td>'.$selectList.'</td>';
print '<td><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("AddElement")).'"></td>'; print '<td><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("AddElement")).'"></td>';
@ -260,11 +310,13 @@ foreach ($listofreferent as $key => $value)
print '<td width="100" align="center">'.$langs->trans("Date").'</td>'; print '<td width="100" align="center">'.$langs->trans("Date").'</td>';
print '<td>'.$langs->trans("ThirdParty").'</td>'; print '<td>'.$langs->trans("ThirdParty").'</td>';
if (empty($value['disableamount'])) print '<td align="right" width="120">'.$langs->trans("AmountHT").'</td>'; if (empty($value['disableamount'])) print '<td align="right" width="120">'.$langs->trans("AmountHT").'</td>';
else print '<td width="120"></td>';
if (empty($value['disableamount'])) print '<td align="right" width="120">'.$langs->trans("AmountTTC").'</td>'; if (empty($value['disableamount'])) print '<td align="right" width="120">'.$langs->trans("AmountTTC").'</td>';
else print '<td width="120"></td>';
print '<td align="right" width="200">'.$langs->trans("Status").'</td>'; print '<td align="right" width="200">'.$langs->trans("Status").'</td>';
print '</tr>'; print '</tr>';
$elementarray = $project->get_element_list($key, $tablename); $elementarray = $project->get_element_list($key, $tablename, $datefieldname, $dates, $datee);
if (count($elementarray)>0 && is_array($elementarray)) if (is_array($elementarray) && count($elementarray)>0)
{ {
$var=true; $var=true;
$total_ht = 0; $total_ht = 0;
@ -314,6 +366,7 @@ foreach ($listofreferent as $key => $value)
if (! $qualifiedfortotal) print '</strike>'; if (! $qualifiedfortotal) print '</strike>';
print '</td>'; print '</td>';
} }
else print '<td></td>';
// Amount // Amount
if (empty($value['disableamount'])) if (empty($value['disableamount']))
@ -324,6 +377,7 @@ foreach ($listofreferent as $key => $value)
if (! $qualifiedfortotal) print '</strike>'; if (! $qualifiedfortotal) print '</strike>';
print '</td>'; print '</td>';
} }
else print '<td></td>';
// Status // Status
print '<td align="right">'.$element->getLibStatut(5).'</td>'; print '<td align="right">'.$element->getLibStatut(5).'</td>';
@ -339,10 +393,16 @@ foreach ($listofreferent as $key => $value)
print '<tr class="liste_total"><td colspan="4">'.$langs->trans("Number").': '.$i.'</td>'; print '<tr class="liste_total"><td colspan="4">'.$langs->trans("Number").': '.$i.'</td>';
if (empty($value['disableamount'])) print '<td align="right" width="100">'.$langs->trans("TotalHT").' : '.price($total_ht).'</td>'; if (empty($value['disableamount'])) print '<td align="right" width="100">'.$langs->trans("TotalHT").' : '.price($total_ht).'</td>';
else print '<td></td>';
if (empty($value['disableamount'])) print '<td align="right" width="100">'.$langs->trans("TotalTTC").' : '.price($total_ttc).'</td>'; if (empty($value['disableamount'])) print '<td align="right" width="100">'.$langs->trans("TotalTTC").' : '.price($total_ttc).'</td>';
else print '<td></td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '</tr>'; print '</tr>';
} }
else // error
{
print $elementarray;
}
print "</table>"; print "</table>";

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -191,12 +191,10 @@ if ($result > 0)
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
// Help
print '<br>'.$langs->trans("NotificationsDesc").'<br>';
dol_fiche_end(); dol_fiche_end();
// Help
print $langs->trans("NotificationsDesc").'<br><br>';
print "\n"; print "\n";
@ -212,7 +210,7 @@ if ($result > 0)
// Line with titles // Line with titles
print '<table width="100%" class="noborder">'; print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Contact"),$_SERVER["PHP_SELF"],"c.lastname",'',$param,'"width="45%"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Target"),$_SERVER["PHP_SELF"],"c.lastname",'',$param,'"width="45%"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"a.titre",'',$param,'"width="35%"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"a.titre",'',$param,'"width="35%"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"",'',$param,'"width="10%"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"",'',$param,'"width="10%"',$sortfield,$sortorder);
print_liste_field_titre(''); print_liste_field_titre('');
@ -265,13 +263,40 @@ if ($result > 0)
// Line with titles // Line with titles
print '<table width="100%" class="noborder">'; print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Contact"),$_SERVER["PHP_SELF"],"c.lastname",'',$param,'"width="45%"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Target"),$_SERVER["PHP_SELF"],"c.lastname",'',$param,'"width="45%"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"a.titre",'',$param,'"width="35%"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"a.titre",'',$param,'"width="35%"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"",'',$param,'"width="10%"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"",'',$param,'"width="10%"',$sortfield,$sortorder);
print_liste_field_titre('','',''); print_liste_field_titre('','','');
print '</tr>'; print '</tr>';
// List of notifications for contacts // List of notifications enabled for fixed email
foreach($conf->global as $key => $val)
{
if (! preg_match('/^NOTIFICATION_FIXEDEMAIL_(.*)/', $key, $reg)) continue;
//print $key.' - '.$val.' - '.$reg[1].'<br>';
print '<tr '.$bc[$var].'><td>'.$val;
if (isValidEmail($val))
{
print ' &lt;'.$val.'&gt;';
}
else
{
$langs->load("errors");
print ' &nbsp; '.img_warning().' '.$langs->trans("ErrorBadEMail",$val);
}
print '</td>';
print '<td>';
$label=($langs->trans("Notify_".$reg[1])!="Notify_".$reg[1]?$langs->trans("Notify_".$reg[1]):$reg[1]);
print $label;
print '</td>';
print '<td>';
print $langs->trans("Email");
print '</td>';
print '<td align="right">'.$langs->trans("SeeModuleSetup").'</td>';
print '</tr>';
}
// List of notifications enabled for contacts
$sql = "SELECT n.rowid, n.type,"; $sql = "SELECT n.rowid, n.type,";
$sql.= " a.code, a.label,"; $sql.= " a.code, a.label,";
$sql.= " c.rowid as contactid, c.lastname, c.firstname, c.email"; $sql.= " c.rowid as contactid, c.lastname, c.firstname, c.email";
@ -343,21 +368,22 @@ if ($result > 0)
// Line with titles // Line with titles
print '<table width="100%" class="noborder">'; print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Contact"),$_SERVER["PHP_SELF"],"c.lastname",'',$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Target"),$_SERVER["PHP_SELF"],"c.lastname",'',$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"a.titre",'',$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"a.titre",'',$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"",'',$param,'',$sortfield,$sortorder);
//print_liste_field_titre($langs->trans("Object"),$_SERVER["PHP_SELF"],"",'',$param,'"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"a.daten",'',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"a.daten",'',$param,'align="right"',$sortfield,$sortorder);
print '</tr>'; print '</tr>';
// List // List
$sql = "SELECT n.rowid, n.daten, n.email, n.objet_type, n.objet_id,"; $sql = "SELECT n.rowid, n.daten, n.email, n.objet_type, n.objet_id as object_id, n.type,";
$sql.= " c.rowid as id, c.lastname, c.firstname, c.email,"; $sql.= " c.rowid as id, c.lastname, c.firstname, c.email as contactemail,";
$sql.= " a.code, a.label"; $sql.= " a.code, a.label";
$sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,"; $sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,";
$sql.= " ".MAIN_DB_PREFIX."notify as n, "; $sql.= " ".MAIN_DB_PREFIX."notify as n ";
$sql.= " ".MAIN_DB_PREFIX."socpeople as c"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as c ON n.fk_contact = c.rowid";
$sql.= " WHERE a.rowid = n.fk_action"; $sql.= " WHERE a.rowid = n.fk_action";
$sql.= " AND c.rowid = n.fk_contact"; $sql.= " AND n.fk_soc = ".$object->id;
$sql.= " AND c.fk_soc = ".$object->id;
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
@ -373,17 +399,37 @@ if ($result > 0)
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$contactstatic->id=$obj->id; print '<tr '.$bc[$var].'><td>';
$contactstatic->lastname=$obj->lastname; if ($obj->id > 0)
$contactstatic->firstname=$obj->firstname; {
print '<tr '.$bc[$var].'><td>'.$contactstatic->getNomUrl(1); $contactstatic->id=$obj->id;
print $obj->email?' &lt;'.$obj->email.'&gt;':$langs->trans("NoMail"); $contactstatic->lastname=$obj->lastname;
$contactstatic->firstname=$obj->firstname;
print $contactstatic->getNomUrl(1);
print $obj->email?' &lt;'.$obj->email.'&gt;':$langs->trans("NoMail");
}
else
{
print $obj->email;
}
print '</td>'; print '</td>';
print '<td>'; print '<td>';
$label=($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label); $label=($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label);
print $label; print $label;
print '</td>'; print '</td>';
// TODO Add link to object here print '<td>';
if ($obj->type == 'email') print $langs->trans("Email");
if ($obj->type == 'sms') print $langs->trans("Sms");
print '</td>';
// TODO Add link to object here for other types
/*print '<td>';
if ($obj->object_type == 'order')
{
$orderstatic->id=$obj->object_id;
$orderstatic->ref=...
print $orderstatic->getNomUrl(1);
}
print '</td>';*/
// print // print
print'<td align="right">'.dol_print_date($db->jdate($obj->daten), 'dayhour').'</td>'; print'<td align="right">'.dol_print_date($db->jdate($obj->daten), 'dayhour').'</td>';
print '</tr>'; print '</tr>';
@ -400,7 +446,7 @@ if ($result > 0)
} }
else dol_print_error('','RecordNotFound'); else dol_print_error('','RecordNotFound');
$db->close();
llxFooter(); llxFooter();
$db->close();

View File

@ -1004,9 +1004,9 @@ div.blockvmenupair, div.blockvmenuimpair, div.blockvmenubookmarks
background-repeat:repeat-x; background-repeat:repeat-x;
<?php } ?> <?php } ?>
border-left: 1px solid #AAA; border-left: 1px solid #AAA;
border-right: 1px solid #CCC; border-right: 1px solid #BBB;
border-bottom: 1px solid #CCC; border-bottom: 1px solid #BBB;
border-top: 1px solid #CCC; border-top: 1px solid #BBB;
border-radius: 5px; border-radius: 5px;
-moz-border-radius: 5px; -moz-border-radius: 5px;
-moz-box-shadow: 3px 3px 4px #DDD; -moz-box-shadow: 3px 3px 4px #DDD;
@ -1361,10 +1361,10 @@ div.tabBar {
-moz-border-radius:6px; -moz-border-radius:6px;
-webkit-border-radius: 6px; -webkit-border-radius: 6px;
border-radius: 6px; border-radius: 6px;
border-right: 1px solid #CCCCCC; border-right: 1px solid #BBB;
border-bottom: 1px solid #CCCCCC; border-bottom: 1px solid #BBB;
border-left: 1px solid #D0D0D0; border-left: 1px solid #BBB;
border-top: 1px solid #D8D8D8; border-top: 1px solid #CCC;
width: auto; width: auto;
<?php if ($usecss3) { ?> <?php if ($usecss3) { ?>
background-image: -o-linear-gradient(bottom, rgba(<?php echo $colorbacktabcard1; ?>, 0.5) 25%, rgba(<?php echo $colorbacktabcard2; ?>, 0.5) 100%); background-image: -o-linear-gradient(bottom, rgba(<?php echo $colorbacktabcard1; ?>, 0.5) 25%, rgba(<?php echo $colorbacktabcard2; ?>, 0.5) 100%);
@ -1420,9 +1420,9 @@ a.tab:link, a.tab:visited, a.tab:hover, a.tab#active {
box-shadow: 0 -1px 4px rgba(0,0,0,.1); box-shadow: 0 -1px 4px rgba(0,0,0,.1);
border-bottom: none; border-bottom: none;
border-right: 1px solid #CCCCCC; border-right: 1px solid #BBB;
border-left: 1px solid #D0D0D0; border-left: 1px solid #BBB;
border-top: 1px solid #D8D8D8; border-top: 1px solid #CCC;
<?php if ($usecss3) { ?> <?php if ($usecss3) { ?>
background-image: -o-linear-gradient(bottom, rgb(<?php echo $colorbackvmenu1; ?>) 35%, rgb(<?php echo $colorbackvmenu2; ?>) 100%); background-image: -o-linear-gradient(bottom, rgb(<?php echo $colorbackvmenu1; ?>) 35%, rgb(<?php echo $colorbackvmenu2; ?>) 100%);

View File

@ -1792,7 +1792,7 @@ class User extends CommonObject
$result.=($lien.img_object($langs->trans("ShowUser"),'user').$lienfin); $result.=($lien.img_object($langs->trans("ShowUser"),'user').$lienfin);
if ($withpicto != 2) $result.=' '; if ($withpicto != 2) $result.=' ';
} }
$result.=$lien.$this->getFullName($langs).$lienfin; $result.=$lien.$this->getFullName($langs,'','',16).$lienfin;
return $result; return $result;
} }
@ -1941,7 +1941,7 @@ class User extends CommonObject
if ($this->office_fax && ! empty($conf->global->LDAP_FIELD_FAX)) $info[$conf->global->LDAP_FIELD_FAX] = $this->office_fax; if ($this->office_fax && ! empty($conf->global->LDAP_FIELD_FAX)) $info[$conf->global->LDAP_FIELD_FAX] = $this->office_fax;
if ($this->note && ! empty($conf->global->LDAP_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_FIELD_DESCRIPTION] = $this->note; if ($this->note && ! empty($conf->global->LDAP_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_FIELD_DESCRIPTION] = $this->note;
if ($this->email && ! empty($conf->global->LDAP_FIELD_MAIL)) $info[$conf->global->LDAP_FIELD_MAIL] = $this->email; if ($this->email && ! empty($conf->global->LDAP_FIELD_MAIL)) $info[$conf->global->LDAP_FIELD_MAIL] = $this->email;
if ($this->skype && ! empty($conf->global->LDAP_FIELD_SKYPE)) $info[$conf->global->LDAP_FIELD_SKYPE] = $this->skype; if ($this->skype && ! empty($conf->global->LDAP_FIELD_SKYPE)) $info[$conf->global->LDAP_FIELD_SKYPE] = $this->skype;
if ($conf->global->LDAP_SERVER_TYPE == 'egroupware') if ($conf->global->LDAP_SERVER_TYPE == 'egroupware')
{ {
@ -1994,7 +1994,7 @@ class User extends CommonObject
$this->firstname='SPECIMEN'; $this->firstname='SPECIMEN';
$this->note='This is a note'; $this->note='This is a note';
$this->email='email@specimen.com'; $this->email='email@specimen.com';
$this->skype='tom.hanson'; $this->skype='tom.hanson';
$this->office_phone='0999999999'; $this->office_phone='0999999999';
$this->office_fax='0999999998'; $this->office_fax='0999999998';
$this->user_mobile='0999999997'; $this->user_mobile='0999999997';
@ -2223,16 +2223,15 @@ class User extends CommonObject
/** /**
* Reconstruit l'arborescence hierarchique des users sous la forme d'un tableau * Reconstruit l'arborescence hierarchique des users sous la forme d'un tableau
* Renvoi un tableau de tableau('id','id_parent',...) trie selon arbre et avec: * Set and return this->users that is an array sorted according to tree with arrays of:
* id = id du user * id = id user
* id_parent = id du user parent * lastname
* id_children = tableau des id enfant * firstname
* name = nom du user
* fullname = nom avec chemin complet du user * fullname = nom avec chemin complet du user
* fullpath = chemin complet compose des id * fullpath = chemin complet compose des id: "_grandparentid_parentid_id"
* *
* @param int $deleteafterid Removed all users including the leaf $deleteafterid (and all its child) in user tree. * @param int $deleteafterid Removed all users including the leaf $deleteafterid (and all its child) in user tree.
* @return array Array of users. this->users and this->parentof are set. * @return array Array of users $this->users. Note: $this->parentof is also set.
*/ */
function get_full_tree($deleteafterid=0) function get_full_tree($deleteafterid=0)
{ {
@ -2311,6 +2310,29 @@ class User extends CommonObject
return $this->users; return $this->users;
} }
/**
* Return list of all childs users in herarchy.
*
* @return array Array of user id lower than user. This overwrite this->users.
*/
function getAllChildIds()
{
// Init this->users
$this->get_full_tree();
$idtoscan=$this->id;
$childids=array();
dol_syslog("Build childid for id = ".$idtoscan);
foreach($this->users as $id => $val)
{
//var_dump($val['fullpath']);
if (preg_match('/_'.$idtoscan.'_/', $val['fullpath'])) $childids[$val['id']]=$val['id'];
}
return $childids;
}
/** /**
* For user id_user and its childs available in this->users, define property fullpath and fullname * For user id_user and its childs available in this->users, define property fullpath and fullname
* *

View File

@ -62,7 +62,7 @@ print_fiche_titre($langs->trans("ListOfUsers"). ' ('.$langs->trans("HierarchicVi
// Charge tableau des categories // Load hierarchy of users
$user_arbo = $userstatic->get_full_tree(); $user_arbo = $userstatic->get_full_tree();
// Define fulltree array // Define fulltree array