Merge pull request #2 from Dolibarr/develop

MAJ BRANCHE DEV
This commit is contained in:
Teddy 2014-10-30 14:38:16 +01:00
commit 6e3d984e5b
187 changed files with 3216 additions and 2129 deletions

View File

@ -5,6 +5,14 @@ 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: 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)
- New: Can add product into category from category card. - New: Can add product into category from category card.
@ -62,9 +70,14 @@ For users:
- New: Add option MAIN_GENERATE_INVOICES_WITH_PICTURE to show picture - New: Add option MAIN_GENERATE_INVOICES_WITH_PICTURE to show picture
onto PDF like MAIN_GENERATE_PROPOSALS_WITH_PICTURE dir for proposals. onto PDF like MAIN_GENERATE_PROPOSALS_WITH_PICTURE dir for proposals.
- New: Add more search field in list of cheque deposits. - New: Add more search field in list of cheque deposits.
- New: Add feature to order to invoice on supplier part - New: Add feature to order to invoice on supplier part.
- New : Use of MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR to use disk cache for big excel export.
- New: Direct invoice creation from predefined invoice.
- New: Add dunning into accountancy report.
- New: Add favorite button into country dictionary to put value on top select list
- Upgrade phpexcel lib to 1.7.8 - Upgrade phpexcel lib to 1.7.8
- New : Use of MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR to use disk cache for big excel export - New : Use of MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR to use disk cache for big excel export
- New : Option on extrafields to have them always editable regardless of the document status
- Fix: [ bug #1487 ] PAYMENT_DELETE trigger does not intercept trigger action - Fix: [ bug #1487 ] PAYMENT_DELETE trigger does not intercept trigger action
- Fix: [ bug #1470, #1472, #1473] User trigger problem - Fix: [ bug #1470, #1472, #1473] User trigger problem
- Fix: [ bug #1489, #1491 ] Intervention trigger problem - Fix: [ bug #1489, #1491 ] Intervention trigger problem
@ -82,8 +95,7 @@ For users:
- Fix: [ bug #1506, #1507 ] ECM trigger error problem - Fix: [ bug #1506, #1507 ] ECM trigger error problem
- Fix: [ bug #1469 ] Triggers CONTACT_MODIFY and CONTACT_DELETE duplicates error message - Fix: [ bug #1469 ] Triggers CONTACT_MODIFY and CONTACT_DELETE duplicates error message
- Fix: [ bug #1537 ] Difference between societe.nom and adherent.societe. - Fix: [ bug #1537 ] Difference between societe.nom and adherent.societe.
- New: Direct invoice creation from predefined invoice
- New: Add dunning into accountancy report
For users, new experimental module (need to set feature level of instance to experimental to see them): For users, new experimental module (need to set feature level of instance to experimental to see them):
- New: Module Accounting Expert to manage accountancy - New: Module Accounting Expert to manage accountancy
Special Thanks to developpers : Special Thanks to developpers :
@ -120,6 +132,8 @@ For developers:
- New: renamed table llx_c_pays to llx_c_country & libelle field to label. - New: renamed table llx_c_pays to llx_c_country & libelle field to label.
- New: Added hook "formConfirm" and "doActions" for fichinter card - New: Added hook "formConfirm" and "doActions" for fichinter card
- New: Can search list of thirdparties from web service on part of name. - New: Can search list of thirdparties from web service on part of name.
- New: Function getCurrencyAmount is marked as deprecated. Use function price to output a price
including currency symbol.
- Qual: Renamed table llx_c_civilite into llx_c_civility, - Qual: Renamed table llx_c_civilite into llx_c_civility,
field civilite into label in the same table, field civilite into label in the same table,
and field civilite into civility in other table. and field civilite into civility in other table.
@ -131,6 +145,8 @@ For developers:
WARNING: Following changes may create regression for some external modules, but was necessary to make 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".
@ -146,6 +162,10 @@ Dolibarr better:
- Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice
- Fix: bug 1588 : relative discount - Fix: bug 1588 : relative discount
- Fix: label of input method not tranlated. - Fix: label of input method not tranlated.
- Fix: box of customer and propsects were not correctly disabled.
- Fix: right and error management #1961
- Fix: Fix Error when trying to clone an Order #1943
- Fix: [ bug #1618 ] PHP Error thrown when saving a barcode
***** ChangeLog for 3.6.1 compared to 3.6.* ***** ***** 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

@ -25,4 +25,6 @@ then
find ./htdocs -type f -iname "*.php" -exec chmod a-x {} \; find ./htdocs -type f -iname "*.php" -exec chmod a-x {} \;
chmod a+x ./scripts/*/*.php chmod a+x ./scripts/*/*.php
chmod a+x ./scripts/*/*.sh chmod a+x ./scripts/*/*.sh
chmod g-w ./scripts/*/*.php
chmod g-w ./scripts/*/*.sh
fi fi

View File

@ -159,7 +159,7 @@ if ($conf->use_javascript_ajax)
print '<br>'; print '<br>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Statistics").'</td></tr>'; print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Statistics").'</td></tr>';
print '<tr><td align="center">'; print '<tr '.$bc[0].'><td align="center" colspan="2">';
$SommeA=0; $SommeA=0;
$SommeB=0; $SommeB=0;

View File

@ -154,7 +154,7 @@ print '<tr class="liste_titre">';
print '<td colspan="2">'.$langs->trans("ActionsEvents").'</td>'; print '<td colspan="2">'.$langs->trans("ActionsEvents").'</td>';
print '<td><a href="'.$_SERVER["PHP_SELF"].'?action=selectall">'.$langs->trans("All").'</a>/<a href="'.$_SERVER["PHP_SELF"].'?action=selectnone">'.$langs->trans("None").'</a>'; print '<td><a href="'.$_SERVER["PHP_SELF"].'?action=selectall">'.$langs->trans("All").'</a>/<a href="'.$_SERVER["PHP_SELF"].'?action=selectnone">'.$langs->trans("None").'</a>';
print '</tr>'."\n"; print '</tr>'."\n";
// Show each trigger // Show each trigger (list is in c_action_trigger)
if (! empty($triggers)) if (! empty($triggers))
{ {
foreach ($triggers as $trigger) foreach ($triggers as $trigger)

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

@ -117,7 +117,7 @@ if ( ($action == 'update' && empty($_POST["cancel"]))
} }
else dol_syslog($imgThumbMini); else dol_syslog($imgThumbMini);
} }
else dol_syslog($langs->trans("ErrorImageFormatNotSupported"),LOG_WARNING); else dol_syslog("ErrorImageFormatNotSupported",LOG_WARNING);
} }
else if (preg_match('/^ErrorFileIsInfectedWithAVirus/',$result)) else if (preg_match('/^ErrorFileIsInfectedWithAVirus/',$result))
{ {
@ -135,7 +135,8 @@ if ( ($action == 'update' && empty($_POST["cancel"]))
else else
{ {
$error++; $error++;
setEventMessage($langs->trans("ErrorOnlyPngJpgSupported"),'errors'); $langs->load("errors");
setEventMessage($langs->trans("ErrorBadImageFormat"),'errors');
} }
} }
} }
@ -226,13 +227,15 @@ if ($action == 'addthumb')
else else
{ {
$error++; $error++;
setEventMessage($langs->trans("ErrorImageFormatNotSupported"),'errors'); $langs->load("errors");
dol_syslog($langs->transnoentities("ErrorImageFormatNotSupported"),LOG_WARNING); setEventMessage($langs->trans("ErrorBadImageFormat"),'errors');
dol_syslog($langs->transnoentities("ErrorBadImageFormat"),LOG_WARNING);
} }
} }
else else
{ {
$error++; $error++;
$langs->load("errors");
setEventMessage($langs->trans("ErrorFileDoesNotExists",$_GET["file"]),'errors'); setEventMessage($langs->trans("ErrorFileDoesNotExists",$_GET["file"]),'errors');
dol_syslog($langs->transnoentities("ErrorFileDoesNotExists",$_GET["file"]),LOG_WARNING); dol_syslog($langs->transnoentities("ErrorFileDoesNotExists",$_GET["file"]),LOG_WARNING);
} }

View File

@ -131,7 +131,7 @@ $tabsql=array();
$tabsql[1] = "SELECT f.rowid as rowid, f.code, f.libelle, c.code as country_code, c.label as country, f.active FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_country as c WHERE f.fk_pays=c.rowid"; $tabsql[1] = "SELECT f.rowid as rowid, f.code, f.libelle, c.code as country_code, c.label as country, f.active FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_country as c WHERE f.fk_pays=c.rowid";
$tabsql[2] = "SELECT d.rowid as rowid, d.code_departement as code, d.nom as libelle, d.fk_region as region_id, r.nom as region, c.code as country_code, c.label as country, d.active FROM ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid and r.active=1 and c.active=1"; $tabsql[2] = "SELECT d.rowid as rowid, d.code_departement as code, d.nom as libelle, d.fk_region as region_id, r.nom as region, c.code as country_code, c.label as country, d.active FROM ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid and r.active=1 and c.active=1";
$tabsql[3] = "SELECT r.rowid as rowid, r.code_region as code, r.nom as libelle, r.fk_pays as country_id, c.code as country_code, c.label as country, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE r.fk_pays=c.rowid and c.active=1"; $tabsql[3] = "SELECT r.rowid as rowid, r.code_region as code, r.nom as libelle, r.fk_pays as country_id, c.code as country_code, c.label as country, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE r.fk_pays=c.rowid and c.active=1";
$tabsql[4] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_country"; $tabsql[4] = "SELECT rowid as rowid, code, label, active, favorite FROM ".MAIN_DB_PREFIX."c_country";
$tabsql[5] = "SELECT c.rowid as rowid, c.code as code, c.label, c.active FROM ".MAIN_DB_PREFIX."c_civility AS c"; $tabsql[5] = "SELECT c.rowid as rowid, c.code as code, c.label, c.active FROM ".MAIN_DB_PREFIX."c_civility AS c";
$tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.type, a.active, a.module, a.color, a.position FROM ".MAIN_DB_PREFIX."c_actioncomm AS a"; $tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.type, a.active, a.module, a.color, a.position FROM ".MAIN_DB_PREFIX."c_actioncomm AS a";
$tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, a.deductible, c.code as country_code, c.label as country, a.fk_pays as country_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_pays=c.rowid and c.active=1"; $tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, a.deductible, c.code as country_code, c.label as country, a.fk_pays as country_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_pays=c.rowid and c.active=1";
@ -387,13 +387,14 @@ if ($id == 11)
$langs->load("bills"); $langs->load("bills");
$langs->load("interventions"); $langs->load("interventions");
$elementList = array( $elementList = array(
'proposal' => $langs->trans('Proposal'), '' => '',
'order' => $langs->trans('Order'), // 'proposal' => $langs->trans('Proposal'),
'invoice' => $langs->trans('Bill'), // 'order' => $langs->trans('Order'),
// 'invoice' => $langs->trans('Bill'),
'invoice_supplier' => $langs->trans('SupplierBill'), 'invoice_supplier' => $langs->trans('SupplierBill'),
'order_supplier' => $langs->trans('SupplierOrder'), 'order_supplier' => $langs->trans('SupplierOrder'),
'intervention' => $langs->trans('InterventionCard'), // 'intervention' => $langs->trans('InterventionCard'),
'contract' => $langs->trans('Contract'), // 'contract' => $langs->trans('Contract'),
'project' => $langs->trans('Project'), 'project' => $langs->trans('Project'),
'project_task' => $langs->trans('Task'), 'project_task' => $langs->trans('Task'),
'agenda' => $langs->trans('Agenda'), 'agenda' => $langs->trans('Agenda'),
@ -402,10 +403,11 @@ if ($id == 11)
'propal' => $langs->trans('Proposal'), 'propal' => $langs->trans('Proposal'),
'commande' => $langs->trans('Order'), 'commande' => $langs->trans('Order'),
'facture' => $langs->trans('Bill'), 'facture' => $langs->trans('Bill'),
'facture_fourn' => $langs->trans('SupplierBill'), // 'facture_fourn' => $langs->trans('SupplierBill'),
'fichinter' => $langs->trans('InterventionCard') 'fichinter' => $langs->trans('InterventionCard')
); );
if (! empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) $elementList["societe"] = $langs->trans('ThirdParty'); if (! empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) $elementList["societe"] = $langs->trans('ThirdParty');
asort($elementList);
$sourceList = array( $sourceList = array(
'internal' => $langs->trans('Internal'), 'internal' => $langs->trans('Internal'),
'external' => $langs->trans('External') 'external' => $langs->trans('External')
@ -677,6 +679,46 @@ if ($action == $acts[1])
} }
} }
// favorite
if ($action == 'activate_favorite')
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$rowid."'";
}
elseif ($_GET["code"]) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".$_GET["code"]."'";
}
$result = $db->query($sql);
if (!$result)
{
dol_print_error($db);
}
}
// disable favorite
if ($action == 'disable_favorite')
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$rowid."'";
}
elseif ($_GET["code"]) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".$_GET["code"]."'";
}
$result = $db->query($sql);
if (!$result)
{
dol_print_error($db);
}
}
/* /*
* View * View
@ -709,6 +751,7 @@ if ($action == 'delete')
{ {
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$_GET["code"].'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1); print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$_GET["code"].'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1);
} }
//var_dump($elementList);
/* /*
* Show a dictionary * Show a dictionary
@ -813,7 +856,7 @@ if ($id)
} }
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
} }
print '<td colspan="3">'; print '<td colspan="4">';
print '<input type="hidden" name="id" value="'.$id.'">'; print '<input type="hidden" name="id" value="'.$id.'">';
print '&nbsp;</td>'; print '&nbsp;</td>';
print '</tr>'; print '</tr>';
@ -928,8 +971,11 @@ if ($id)
print getTitleFieldOfList($valuetoshow,0,$_SERVER["PHP_SELF"],($sortable?$fieldlist[$field]:''),($page?'page='.$page.'&':'').'&id='.$id,"","align=".$align,$sortfield,$sortorder); print getTitleFieldOfList($valuetoshow,0,$_SERVER["PHP_SELF"],($sortable?$fieldlist[$field]:''),($page?'page='.$page.'&':'').'&id='.$id,"","align=".$align,$sortfield,$sortorder);
} }
} }
// Favorite - Only activated on country dictionary
if ($id == 4) print getTitleFieldOfList($langs->trans("Favorite"),0,$_SERVER["PHP_SELF"],"favorite",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder);
print getTitleFieldOfList($langs->trans("Status"),0,$_SERVER["PHP_SELF"],"active",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder); print getTitleFieldOfList($langs->trans("Status"),0,$_SERVER["PHP_SELF"],"active",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder);
print '<td colspan="2" class="liste_titre">&nbsp;</td>'; print '<td colspan="3" class="liste_titre">&nbsp;</td>';
print '</tr>'; print '</tr>';
// Lines with values // Lines with values
@ -1142,6 +1188,16 @@ if ($id)
$url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&amp;code='.(! empty($obj->code)?$obj->code:'').'&amp;id='.$id.'&amp;'; $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&amp;code='.(! empty($obj->code)?$obj->code:'').'&amp;id='.$id.'&amp;';
// Favorite
// Only activated on country dictionary
if ($id == 4)
{
print '<td align="center" class="nowrap">';
if ($iserasable) print '<a href="'.$url.'action='.$acts[$obj->favorite].'_favorite">'.$actl[$obj->favorite].'</a>';
else print $langs->trans("AlwaysActive");
print '</td>';
}
// Active // Active
print '<td align="center" class="nowrap">'; print '<td align="center" class="nowrap">';
if ($isdisable) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>'; if ($isdisable) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';

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,14 +40,27 @@ 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"));
} }
@ -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++) {
@ -135,9 +136,7 @@ $langs->load("cashdesk");
$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

@ -621,8 +621,17 @@ function formCategory($db,$object,$typeid,$socid=0,$showclassifyform=1)
if ($typeid == 3) $title = $langs->trans("MembersCategoriesShort"); if ($typeid == 3) $title = $langs->trans("MembersCategoriesShort");
if ($typeid == 4) $title = $langs->trans("ContactCategoriesShort"); if ($typeid == 4) $title = $langs->trans("ContactCategoriesShort");
$linktocreate='';
if ($showclassifyform && $user->rights->categorie->creer)
{
$linktocreate='<a href="'.DOL_URL_ROOT.'/categories/card.php?action=create&amp;origin='.$object->id.'&type='.$typeid.'&urlfrom='.urlencode($_SERVER["PHP_SELF"].'?'.(($typeid==1||$typeid==2)?'socid':'id').'='.$object->id.'&type='.$typeid).'">';
$linktocreate.=$langs->trans("CreateCat").' ';
$linktocreate.=img_picto($langs->trans("Create"),'filenew');
$linktocreate.="</a>";
}
print '<br>'; print '<br>';
print_fiche_titre($title,'',''); print_fiche_titre($title,$linktocreate,'');
// Form to add record into a category // Form to add record into a category
if ($showclassifyform) if ($showclassifyform)
@ -634,19 +643,10 @@ function formCategory($db,$object,$typeid,$socid=0,$showclassifyform=1)
print '<input type="hidden" name="id" value="'.$object->id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="40%">'; print '<tr class="liste_titre"><td width="40%">';
print $langs->trans("ClassifyInCategory").' &nbsp;'; print '<span class="hideonsmartphone">'.$langs->trans("ClassifyInCategory").' &nbsp;</span>';
print $form->select_all_categories($typeid,'auto'); print $form->select_all_categories($typeid,'auto');
print '</td><td>';
print '<input type="submit" class="button" value="'.$langs->trans("Classify").'"></td>';
if ($user->rights->categorie->creer)
{
print '<td align="right">';
print '<a href="'.DOL_URL_ROOT.'/categories/card.php?action=create&amp;origin='.$object->id.'&type='.$typeid.'&urlfrom='.urlencode($_SERVER["PHP_SELF"].'?'.(($typeid==1||$typeid==2)?'socid':'id').'='.$object->id.'&type='.$typeid).'">';
print $langs->trans("CreateCat").' ';
print img_picto($langs->trans("Create"),'filenew');
print "</a>";
print '</td>'; print '</td>';
} print '<td><input type="submit" class="button" value="'.$langs->trans("Classify").'"></td>';
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';
print '</form>'; print '</form>';
@ -679,10 +679,7 @@ function formCategory($db,$object,$typeid,$socid=0,$showclassifyform=1)
print "<tr ".$bc[$var].">"; print "<tr ".$bc[$var].">";
// Categorie // Categorie
print "<td>"; print "<td>".img_object('','category').' '.$way."</td>";
//$c->id=;
//print $c->getNomUrl(1);
print img_object('','category').' '.$way."</td>";
// Link to delete from category // Link to delete from category
print '<td align="right">'; print '<td align="right">';

View File

@ -171,7 +171,7 @@ $nbofentries=(count($data) - 1);
if ($nbofentries > 0) if ($nbofentries > 0)
{ {
print '<tr><td colspan="3">'; print '<tr '.$bc[0].'><td colspan="3">';
tree_recur($data,$data[0],0); tree_recur($data,$data[0],0);
print '</td></tr>'; print '</td></tr>';
} }

View File

@ -853,8 +853,8 @@ class ActionComm extends CommonObject
} }
/** /**
* Renvoie nom clicable (avec eventuellement le picto) * Return URL of event
* Utilise $this->id, $this->code et $this->label * Use $this->id, $this->type_code, $this->label and $this->type_label
* *
* @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul * @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
* @param int $maxlength Nombre de caracteres max dans libelle * @param int $maxlength Nombre de caracteres max dans libelle
@ -865,39 +865,34 @@ class ActionComm extends CommonObject
*/ */
function getNomUrl($withpicto=0,$maxlength=0,$classname='',$option='',$overwritepicto='') function getNomUrl($withpicto=0,$maxlength=0,$classname='',$option='',$overwritepicto='')
{ {
global $langs; global $conf,$langs;
$result=''; $result='';
if ($option=='birthday') $lien = '<a '.($classname?'class="'.$classname.'" ':'').'href="'.DOL_URL_ROOT.'/contact/perso.php?id='.$this->id.'">'; if ($option=='birthday') $lien = '<a '.($classname?'class="'.$classname.'" ':'').'href="'.DOL_URL_ROOT.'/contact/perso.php?id='.$this->id.'">';
else $lien = '<a '.($classname?'class="'.$classname.'" ':'').'href="'.DOL_URL_ROOT.'/comm/action/card.php?id='.$this->id.'">'; else $lien = '<a '.($classname?'class="'.$classname.'" ':'').'href="'.DOL_URL_ROOT.'/comm/action/card.php?id='.$this->id.'">';
$lienfin='</a>'; $lienfin='</a>';
$label=$this->label; $label=$this->label;
if (empty($label)) $label=$this->libelle; // Fro backward compatibility if (empty($label)) $label=$this->libelle; // For backward compatibility
//print 'rrr'.$this->libelle; //print 'rrr'.$this->libelle.'-'.$withpicto;
if ($withpicto == 2) if ($withpicto == 2)
{ {
$libelle=$label; $libelle=$label;
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle=$langs->trans("Action".$this->type_code); if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle=$langs->transnoentities("Action".$this->type_code);
$libelleshort=''; $libelleshort='';
} }
else if (empty($this->libelle))
{
$libelle=$label;
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle=$langs->trans("Action".$this->type_code);
$libelleshort=dol_trunc($label, $maxlength);
}
else else
{ {
$libelle=$label; $libelle=(empty($this->libelle)?$label:$this->libelle.(($label && $label != $this->libelle)?' '.$label:''));
$libelleshort=dol_trunc($label,$maxlength); if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($libelle)) $libelle=($langs->transnoentities("Action".$this->type_code) != "Action".$this->type_code)?$langs->transnoentities("Action".$this->type_code):$this->type_label;
$libelleshort=dol_trunc($libelle,$maxlength);
} }
if ($withpicto) if ($withpicto)
{ {
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) // Add code into ()
{ {
$libelle.=(($this->type_code && $libelle!=$langs->trans("Action".$this->type_code) && $langs->trans("Action".$this->type_code)!="Action".$this->type_code)?' ('.$langs->trans("Action".$this->type_code).')':''); $libelle.=(($this->type_code && $libelle!=$langs->transnoentities("Action".$this->type_code) && $langs->transnoentities("Action".$this->type_code)!="Action".$this->type_code)?' ('.$langs->transnoentities("Action".$this->type_code).')':'');
} }
$result.=$lien.img_object($langs->trans("ShowAction").': '.$libelle,($overwritepicto?$overwritepicto:'action')).$lienfin; $result.=$lien.img_object($langs->trans("ShowAction").': '.$libelle,($overwritepicto?$overwritepicto:'action')).$lienfin;
} }

View File

@ -414,7 +414,7 @@ $sql.= ' a.percent,';
$sql.= ' a.fk_user_author,a.fk_user_action,a.fk_user_done,'; $sql.= ' a.fk_user_author,a.fk_user_action,a.fk_user_done,';
$sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,'; $sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,';
$sql.= ' a.fk_soc, a.fk_contact,'; $sql.= ' a.fk_soc, a.fk_contact,';
$sql.= ' ca.code'; $sql.= ' ca.code as type_code, ca.libelle as type_label';
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; $sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
if ($usergroup > 0) $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ugu"; if ($usergroup > 0) $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ugu";
@ -483,12 +483,20 @@ if ($resql)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
// Discard auto action if option is on
if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO')
{
$i++;
continue;
}
// Create a new object action // Create a new object action
$event=new ActionComm($db); $event=new ActionComm($db);
$event->id=$obj->id; $event->id=$obj->id;
$event->datep=$db->jdate($obj->datep); // datep and datef are GMT date $event->datep=$db->jdate($obj->datep); // datep and datef are GMT date
$event->datef=$db->jdate($obj->datep2); $event->datef=$db->jdate($obj->datep2);
$event->type_code=$obj->code; $event->type_code=$obj->type_code;
$event->type_label=$obj->type_label;
$event->libelle=$obj->label; $event->libelle=$obj->label;
$event->percentage=$obj->percent; $event->percentage=$obj->percent;
$event->authorid=$obj->fk_user_author; // user id of creator $event->authorid=$obj->fk_user_author; // user id of creator
@ -876,6 +884,7 @@ if (count($listofextcals))
$maxnbofchar=18; $maxnbofchar=18;
$cachethirdparties=array(); $cachethirdparties=array();
$cachecontacts=array(); $cachecontacts=array();
$cacheusers=array();
// Define theme_datacolor array // Define theme_datacolor array
$color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/graph-color.php"; $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/graph-color.php";
@ -1028,7 +1037,7 @@ else // View by day
$today=0; $today=0;
$todayarray=dol_getdate($now,'fast'); $todayarray=dol_getdate($now,'fast');
if ($todayarray['mday']==$day && $todayarray['mon']==$month && $todayarray['year']==$year) $today=1; if ($todayarray['mday']==$day && $todayarray['mon']==$month && $todayarray['year']==$year) $today=1;
if ($today) $style='cal_today'; //if ($today) $style='cal_today';
$timestamp=dol_mktime(12,0,0,$month,$day,$year); $timestamp=dol_mktime(12,0,0,$month,$day,$year);
$arraytimestamp=dol_getdate($timestamp); $arraytimestamp=dol_getdate($timestamp);
@ -1087,7 +1096,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
global $user, $conf, $langs; global $user, $conf, $langs;
global $action, $filter, $filtera, $filtert, $filterd, $status, $actioncode; // Filters used into search form global $action, $filter, $filtera, $filtert, $filterd, $status, $actioncode; // Filters used into search form
global $theme_datacolor; global $theme_datacolor;
global $cachethirdparties, $cachecontacts, $colorindexused; global $cachethirdparties, $cachecontacts, $cacheusers, $colorindexused;
print '<div id="dayevent_'.sprintf("%04d",$year).sprintf("%02d",$month).sprintf("%02d",$day).'" class="dayevent">'."\n"; print '<div id="dayevent_'.sprintf("%04d",$year).sprintf("%02d",$month).sprintf("%02d",$day).'" class="dayevent">'."\n";
@ -1146,11 +1155,17 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
if (in_array($user->id, $keysofuserassigned)) if (in_array($user->id, $keysofuserassigned))
{ {
$nummytasks++; $cssclass='family_mytasks'; $nummytasks++; $cssclass='family_mytasks';
// TODO Set a color using user color
// Must defined rule to choose color of who to use. if (empty($cacheusers[$event->userownerid]))
// event->ownerid will still contains user id of owner {
// event->userassigned will be an array in future. $newuser=new User($db);
// $color=$user->color; $newuser->fetch($event->userownerid);
$cacheusers[$event->userownerid]=$newuser;
}
//var_dump($cacheusers[$event->userownerid]->color);
// We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
if (! empty($cacheusers[$event->userownerid]->color)) $color=$cacheusers[$event->userownerid]->color;
} }
else if ($event->type_code == 'ICALEVENT') else if ($event->type_code == 'ICALEVENT')
{ {
@ -1171,6 +1186,17 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
else else
{ {
$numother++; $cssclass='family_other'; $numother++; $cssclass='family_other';
if (empty($cacheusers[$event->userownerid]))
{
$newuser=new User($db);
$newuser->fetch($event->userownerid);
$cacheusers[$event->userownerid]=$newuser;
}
//var_dump($cacheusers[$event->userownerid]->color);
// We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
if (! empty($cacheusers[$event->userownerid]->color)) $color=$cacheusers[$event->userownerid]->color;
} }
if ($color == -1) // Color was not forced. Set color according to color index. if ($color == -1) // Color was not forced. Set color according to color index.
{ {

View File

@ -44,6 +44,8 @@ $status=GETPOST("status",'alpha');
$type=GETPOST('type'); $type=GETPOST('type');
$actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_USE_EVENT_TYPE)?'AC_OTH':'')); $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_USE_EVENT_TYPE)?'AC_OTH':''));
$dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth'), GETPOST('dateselectday'), GETPOST('dateselectyear')); $dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth'), GETPOST('dateselectday'), GETPOST('dateselectyear'));
$datestart=dol_mktime(0, 0, 0, GETPOST('datestartmonth'), GETPOST('datestartday'), GETPOST('datestartyear'));
$dateend=dol_mktime(0, 0, 0, GETPOST('dateendmonth'), GETPOST('dateendday'), GETPOST('dateendyear'));
if ($actioncode == '') $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE); if ($actioncode == '') $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE);
if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS); if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS);
@ -123,13 +125,19 @@ if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday"))
* View * View
*/ */
$form=new Form($db);
$nav='';
$nav.=' &nbsp; <form name="dateselect" action="'.$_SERVER["PHP_SELF"].'?action=show_peruser'.$param.'">';
$nav.=$form->select_date($dateselect, 'dateselect', 0, 0, 1, '', 1, 0, 1);
$nav.=' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';
$nav.='</form>';
$now=dol_now(); $now=dol_now();
$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; $help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
llxHeader('',$langs->trans("Agenda"),$help_url); llxHeader('',$langs->trans("Agenda"),$help_url);
$form=new Form($db);
// Define list of all external calendars // Define list of all external calendars
$listofextcals=array(); $listofextcals=array();
@ -148,7 +156,7 @@ if ($type) $param.="&type=".$type;
$sql = "SELECT s.nom as societe, s.rowid as socid, s.client,"; $sql = "SELECT s.nom as societe, s.rowid as socid, s.client,";
$sql.= " a.id, a.datep as dp, a.datep2 as dp2,"; $sql.= " a.id, a.datep as dp, a.datep2 as dp2,";
$sql.= " a.fk_contact, a.note, a.label, a.percent as percent,"; $sql.= " a.fk_contact, a.note, a.label, a.percent as percent,";
$sql.= " c.code as acode, c.libelle,"; $sql.= " c.code as type_code, c.libelle as type_label,";
$sql.= " ua.login as loginauthor, ua.rowid as useridauthor,"; $sql.= " ua.login as loginauthor, ua.rowid as useridauthor,";
$sql.= " ut.login as logintodo, ut.rowid as useridtodo,"; $sql.= " ut.login as logintodo, ut.rowid as useridtodo,";
//$sql.= " ud.login as logindone, ud.rowid as useriddone,"; //$sql.= " ud.login as logindone, ud.rowid as useriddone,";
@ -188,8 +196,9 @@ if ($filtera > 0 || $filtert > 0 || $filterd > 0 || $usergroup > 0)
if ($usergroup > 0) $sql.= ($filtera>0||$filtert>0||$filterd>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup; if ($usergroup > 0) $sql.= ($filtera>0||$filtert>0||$filterd>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup;
$sql.= ")"; $sql.= ")";
} }
//if ($dateselect > 0) $sql.= " AND a.datep BETWEEN '".$db->idate($dateselect)."' AND '".$db->idate($dateselect+3600*24-1).'"'; if ($dateselect > 0) $sql.= " AND a.datep2 >= '".$db->idate($dateselect)."' AND a.datep <= '".$db->idate($dateselect+3600*24-1)."'";
if ($dateselect > 0) $sql.= " AND a.datep BETWEEN '".$db->idate($dateselect)."' AND '".$db->idate($dateselect+3600*24-1)."'"; if ($datestart > 0) $sql.= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart+3600*24-1)."'";
if ($dateend > 0) $sql.= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend+3600*24-1)."'";
$sql.= $db->order($sortfield,$sortorder); $sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($limit + 1, $offset); $sql.= $db->plimit($limit + 1, $offset);
//print $sql; //print $sql;
@ -236,7 +245,7 @@ if ($resql)
} }
*/ */
print_barre_liste($newtitle, $page, $_SERVER["PHP_SELF"], $param,$sortfield,$sortorder,$link,$num,0,''); print_barre_liste($newtitle, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $link, $num, 0, '', 0, $nav);
//print '<br>'; //print '<br>';
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'?'.$param.'">'."\n"; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'?'.$param.'">'."\n";
@ -250,7 +259,7 @@ if ($resql)
print_liste_field_titre($langs->trans("DateEnd"),$_SERVER["PHP_SELF"],"a.datep2",$param,'','align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateEnd"),$_SERVER["PHP_SELF"],"a.datep2",$param,'','align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Contact"),$_SERVER["PHP_SELF"],"a.fk_contact",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Contact"),$_SERVER["PHP_SELF"],"a.fk_contact",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("ActionUserAsk"),$_SERVER["PHP_SELF"],"ua.login",$param,"","",$sortfield,$sortorder); //print_liste_field_titre($langs->trans("ActionUserAsk"),$_SERVER["PHP_SELF"],"ua.login",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("ActionsOwnedBy"),$_SERVER["PHP_SELF"],"ut.login",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("ActionsOwnedBy"),$_SERVER["PHP_SELF"],"ut.login",$param,"","",$sortfield,$sortorder);
//print_liste_field_titre($langs->trans("DoneBy"),$_SERVER["PHP_SELF"],"ud.login",$param,"","",$sortfield,$sortorder); //print_liste_field_titre($langs->trans("DoneBy"),$_SERVER["PHP_SELF"],"ud.login",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"a.percent",$param,"",'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"a.percent",$param,"",'align="right"',$sortfield,$sortorder);
@ -259,12 +268,14 @@ if ($resql)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td class="liste_titre" align="center">'; print '<td class="liste_titre" align="center">';
print $form->select_date($dateselect, 'dateselect', 0, 0, 1, '', 1, 0, 1); print $form->select_date($datestart, 'datestart', 0, 0, 1, '', 1, 0, 1);
print '</td>';
print '<td class="liste_titre" align="center">';
print $form->select_date($dateend, 'dateend', 0, 0, 1, '', 1, 0, 1);
print '</td>'; print '</td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>'; //print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td class="liste_titre" align="right"><input class="liste_titre" type="image" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">'; print '<td class="liste_titre" align="right"><input class="liste_titre" type="image" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
//print '&nbsp; '; //print '&nbsp; ';
@ -281,6 +292,13 @@ if ($resql)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
// Discard auto action if option is on
if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO')
{
$i++;
continue;
}
$var=!$var; $var=!$var;
print "<tr ".$bc[$var].">"; print "<tr ".$bc[$var].">";
@ -288,7 +306,8 @@ if ($resql)
// Action (type) // Action (type)
print '<td>'; print '<td>';
$actionstatic->id=$obj->id; $actionstatic->id=$obj->id;
$actionstatic->type_code=$obj->acode; $actionstatic->type_code=$obj->type_code;
$actionstatic->type_label=$obj->type_label;
$actionstatic->libelle=$obj->label; $actionstatic->libelle=$obj->label;
print $actionstatic->getNomUrl(1,28); print $actionstatic->getNomUrl(1,28);
print '</td>'; print '</td>';
@ -337,6 +356,7 @@ if ($resql)
print '</td>'; print '</td>';
// User author // User author
/*
print '<td align="left">'; print '<td align="left">';
if ($obj->useridauthor) if ($obj->useridauthor)
{ {
@ -347,6 +367,7 @@ if ($resql)
} }
else print '&nbsp;'; else print '&nbsp;';
print '</td>'; print '</td>';
*/
// User to do // User to do
print '<td align="left">'; print '<td align="left">';

View File

@ -395,6 +395,13 @@ if ($resql)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
// Discard auto action if option is on
if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO')
{
$i++;
continue;
}
// Create a new object action // Create a new object action
$event=new ActionComm($db); $event=new ActionComm($db);
$event->id=$obj->id; $event->id=$obj->id;
@ -710,6 +717,11 @@ if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
print '<div style="float: left; padding: 2px; margin-right: 6px;"><div class="peruser_busy" style="width:16px; float: left; margin-right: 4px;">&nbsp;</div>'; print '<div style="float: left; padding: 2px; margin-right: 6px;"><div class="peruser_busy" style="width:16px; float: left; margin-right: 4px;">&nbsp;</div>';
print $langs->trans("Other"); print $langs->trans("Other");
print '</div>'; print '</div>';
/* TODO Show this if at least one cumulated event
print '<div style="float: left; padding: 2px; margin-right: 6px;"><div style="background: #222222; width:16px; float: left; margin-right: 4px;">&nbsp;</div>';
print $langs->trans("SeveralEvents");
print '</div>';
*/
} }
// Add js code to manage click on a box // Add js code to manage click on a box
@ -734,7 +746,7 @@ jQuery(document).ready(function() {
else if (ids.indexOf(",") > -1) /* There is several events */ else if (ids.indexOf(",") > -1) /* There is several events */
{ {
/* alert(\'several events\'); */ /* alert(\'several events\'); */
url = "'.DOL_URL_ROOT.'/comm/action/listactions.php?usertodo="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+dateselectday; url = "'.DOL_URL_ROOT.'/comm/action/listactions.php?usertodo="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day;
window.location.href = url; window.location.href = url;
} }
else /* One event */ else /* One event */

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)) { {
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;
if (! empty($conf->global->MAIN_MULTILANGS)) { $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 = new Translate("", $conf);
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang);
$outputlangs->setDefaultLang($newlang); $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 $ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); $object->generateDocument($model, $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,18 +487,25 @@ else if ($action == 'add' && $user->rights->propal->creer) {
{ {
$db->commit(); $db->commit();
// 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;
if (! empty($conf->global->MAIN_MULTILANGS)) $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 = new Translate("", $conf);
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang);
$outputlangs->setDefaultLang($newlang); $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 $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);
} }
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
@ -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) {
@ -2008,62 +2038,9 @@ if ($action == 'create')
print '</tr>'; print '</tr>';
} }
// Other attributes (TODO Move this into an include) // Other attributes
$res = $object->fetch_optionals($object->id, $extralabels); $cols = 3;
$parameters = array('colspan' => ' colspan="3"'); include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified
// by
// hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
foreach ($extrafields->attribute_label as $key => $label)
{
if ($action == 'edit_extras')
{
$value = (isset($_POST ["options_" . $key]) ? $_POST ["options_" . $key] : $object->array_options ["options_" . $key]);
}
else
{
$value = $object->array_options ["options_" . $key];
}
if ($extrafields->attribute_type [$key] == 'separate')
{
print $extrafields->showSeparator($key);
}
else
{
print '<tr><td';
if (! empty($extrafields->attribute_required [$key])) print ' class="fieldrequired"';
print '>' . $label . '</td><td colspan="5">';
// Convert date into timestamp format
if (in_array($extrafields->attribute_type [$key], array('date','datetime'))) {
$value = isset($_POST ["options_" . $key]) ? dol_mktime($_POST ["options_" . $key . "hour"], $_POST ["options_" . $key . "min"], 0, $_POST ["options_" . $key . "month"], $_POST ["options_" . $key . "day"], $_POST ["options_" . $key . "year"]) : $db->jdate($object->array_options ['options_' . $key]);
}
if ($action == 'edit_extras' && $user->rights->propal->creer && GETPOST('attribute') == $key)
{
print '<form enctype="multipart/form-data" action="' . $_SERVER["PHP_SELF"] . '" method="post" name="formsoc">';
print '<input type="hidden" name="action" value="update_extras">';
print '<input type="hidden" name="attribute" value="' . $key . '">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="id" value="' . $object->id . '">';
print $extrafields->showInputField($key, $value);
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '</form>';
}
else
{
print $extrafields->showOutputField($key, $value);
if ($object->statut == 0 && $user->rights->propal->creer)
print '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=edit_extras&attribute=' . $key . '">' . img_picto('', 'edit') . ' ' . $langs->trans('Modify') . '</a>';
}
print '</td></tr>' . "\n";
}
}
}
// Amount HT // Amount HT
print '<tr><td height="10" width="25%">' . $langs->trans('AmountHT') . '</td>'; print '<tr><td height="10" width="25%">' . $langs->trans('AmountHT') . '</td>';

View File

@ -186,7 +186,7 @@ if ($id > 0 || ! empty($ref))
// Si fichier png PDF d'1 page trouve // Si fichier png PDF d'1 page trouve
if (file_exists($fileimage)) if (file_exists($fileimage))
{ {
print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercupropal&file='.urlencode($relativepathimage).'">'; print '<img style="background: #FFF" src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercupropal&file='.urlencode($relativepathimage).'">';
} }
// Si fichier png PDF de plus d'1 page trouve // Si fichier png PDF de plus d'1 page trouve
elseif (file_exists($fileimagebis)) elseif (file_exists($fileimagebis))
@ -199,13 +199,12 @@ elseif (file_exists($fileimagebis))
if (file_exists($dir_output.$preview)) if (file_exists($dir_output.$preview))
{ {
print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercupropal&file='.urlencode($preview).'"><p>'; print '<img style="background: #FFF" src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercupropal&file='.urlencode($preview).'"><p>';
} }
} }
} }
print '</div>';
$db->close();
llxFooter(); llxFooter();
$db->close();

View File

@ -1326,16 +1326,23 @@ 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)
{ {
if (! $notrigger) dol_print_error($this->db);
$error++;
}
// Trigger calls
if (! $error && ! $notrigger)
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('PROPAL_VALIDATE',$user); $result=$this->call_trigger('PROPAL_VALIDATE',$user);
@ -1345,6 +1352,8 @@ class Propal extends CommonObject
if (! $error) 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))
{ {
@ -1354,16 +1363,23 @@ class Propal extends CommonObject
$newref = dol_sanitizeFileName($num); $newref = dol_sanitizeFileName($num);
$dirsource = $conf->propal->dir_output.'/'.$oldref; $dirsource = $conf->propal->dir_output.'/'.$oldref;
$dirdest = $conf->propal->dir_output.'/'.$newref; $dirdest = $conf->propal->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))
{ {
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->propal->dir_output.'/'.$newref.'/'.$oldref.'*.*'); $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);
}
} }
} }
} }
@ -1377,12 +1393,6 @@ class Propal extends CommonObject
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
else
{
$this->db->rollback();
return -2;
}
}
else else
{ {
$this->db->rollback(); $this->db->rollback();

View File

@ -206,7 +206,7 @@ if ($id > 0 || ! empty($ref))
// Si fichier png PDF d'1 page trouve // Si fichier png PDF d'1 page trouve
if (file_exists($fileimage)) if (file_exists($fileimage))
{ {
print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercucommande&file='.urlencode($relativepathimage).'">'; print '<img style="background: #FFF" src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercucommande&file='.urlencode($relativepathimage).'">';
} }
// Si fichier png PDF de plus d'1 page trouve // Si fichier png PDF de plus d'1 page trouve
elseif (file_exists($fileimagebis)) elseif (file_exists($fileimagebis))
@ -219,13 +219,12 @@ elseif (file_exists($fileimagebis))
if (file_exists($dir_output.$preview)) if (file_exists($dir_output.$preview))
{ {
print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercucommande&file='.urlencode($preview).'"><p>'; print '<img style="background: #FFF" src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercucommande&file='.urlencode($preview).'"><p>';
} }
} }
} }
print '</div>';
$db->close();
llxFooter(); llxFooter();
$db->close();

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
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs; $outputlangs = $langs;
$newlang = ''; $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
$newlang = $_REQUEST['lang_id']; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $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
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs; $outputlangs = $langs;
$newlang = ''; $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
$newlang = $_REQUEST['lang_id']; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $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');
@ -2130,60 +2135,9 @@ if ($action == 'create' && $user->rights->commande->creer) {
print '</tr>'; print '</tr>';
} }
// Other attributes (TODO Move this into an include) // Other attributes
$parameters = array('colspan' => ' colspan="3"'); $cols = 3;
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
foreach ($extrafields->attribute_label as $key => $label)
{
if ($action == 'edit_extras')
{
$value = (isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
}
else
{
$value = $object->array_options["options_" . $key];
}
if ($extrafields->attribute_type[$key] == 'separate')
{
print $extrafields->showSeparator($key);
}
else
{
print '<tr><td';
if (! empty($extrafields->attribute_required [$key])) print ' class="fieldrequired"';
print '>' . $label . '</td><td colspan="5">';
// Convert date into timestamp format
if (in_array($extrafields->attribute_type [$key], array('date','datetime')))
{
$value = isset($_POST["options_" . $key]) ? dol_mktime($_POST["options_" . $key . "hour"], $_POST["options_" . $key . "min"], 0, $_POST["options_" . $key . "month"], $_POST["options_" . $key . "day"], $_POST["options_" . $key . "year"]) : $db->jdate($object->array_options ['options_' . $key]);
}
if ($action == 'edit_extras' && $user->rights->commande->creer && GETPOST('attribute') == $key)
{
print '<form enctype="multipart/form-data" action="' . $_SERVER["PHP_SELF"] . '" method="post" name="formsoc">';
print '<input type="hidden" name="action" value="update_extras">';
print '<input type="hidden" name="attribute" value="' . $key . '">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="id" value="' . $object->id . '">';
print $extrafields->showInputField($key, $value);
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '</form>';
}
else
{
print $extrafields->showOutputField($key, $value);
if ($object->statut == 0 && $user->rights->commande->creer)
print '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=edit_extras&attribute=' . $key . '">' . img_picto('', 'edit') . ' ' . $langs->trans('Modify') . '</a>';
}
print '</td></tr>' . "\n";
}
}
}
$rowspan = 4; $rowspan = 4;
if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0)

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';
@ -226,6 +227,7 @@ class Commande extends CommonOrder
{ {
$num = $this->ref; $num = $this->ref;
} }
$this->newref = $num;
// Validate // Validate
$sql = "UPDATE ".MAIN_DB_PREFIX."commande"; $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
@ -273,41 +275,47 @@ 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)
}
}
}
if (! $error)
{ {
// Call trigger $dirsource=$fileentry['name'];
$result=$this->call_trigger('ORDER_VALIDATE',$user); $dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource);
if ($result < 0) $error++; $dirsource=$fileentry['path'].'/'.$dirsource;
// End call triggers $dirdest=$fileentry['path'].'/'.$dirdest;
@rename($dirsource, $dirdest);
}
}
}
}
} }
// Set new ref and current status // Set new ref and current status
@ -898,6 +906,13 @@ class Commande extends CommonOrder
$this->date_validation = ''; $this->date_validation = '';
$this->ref_client = ''; $this->ref_client = '';
// Set ref
require_once DOL_DOCUMENT_ROOT ."/core/modules/commande/".$conf->global->COMMANDE_ADDON.'.php';
$obj = $conf->global->COMMANDE_ADDON;
$modCommande = new $obj;
$this->ref = $modCommande->getNextValue($objsoc,$this);
// Create clone // Create clone
$result=$this->create($user); $result=$this->create($user);
if ($result < 0) $error++; if ($result < 0) $error++;

View File

@ -233,7 +233,11 @@ foreach ($accounts as $key=>$type)
$total[$acc->currency_code] += $solde; $total[$acc->currency_code] += $solde;
} }
} }
if (! $found) print '<tr '.$bc[$var].'><td colspan="6">'.$langs->trans("None").'</td></tr>'; if (! $found)
{
$var = !$var;
print '<tr '.$bc[$var].'><td colspan="6">'.$langs->trans("None").'</td></tr>';
}
// Total // Total
foreach ($total as $key=>$solde) foreach ($total as $key=>$solde)
{ {

View File

@ -112,7 +112,7 @@ if ($conf->salaries->enabled)
$total = 0 ; $total = 0 ;
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"s.datev","",$param,'width="120"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"s.datev","",$param,'width="140px"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"s.label","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"s.label","",$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"s.amount","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"s.amount","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("RefPayment"),$_SERVER["PHP_SELF"],"s.rowid","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("RefPayment"),$_SERVER["PHP_SELF"],"s.rowid","",$param,'',$sortfield,$sortorder);
@ -145,7 +145,7 @@ if ($conf->salaries->enabled)
$i++; $i++;
} }
print '<tr class="liste_total"><td align="right" colspan="2">'.$langs->trans("Total").'</td>'; print '<tr class="liste_total"><td colspan="2">'.$langs->trans("Total").'</td>';
print '<td align="right">'.price($total)."</td>"; print '<td align="right">'.price($total)."</td>";
print '<td align="center">&nbsp;</td>'; print '<td align="center">&nbsp;</td>';
print '<td align="center">&nbsp;</td>'; print '<td align="center">&nbsp;</td>';
@ -175,7 +175,7 @@ if ($conf->tax->enabled)
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"cs.date_ech","",$param,'width="120"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"cs.date_ech","",$param,'width="140px"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"c.libelle","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"c.libelle","",$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"cs.fk_type","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"cs.fk_type","",$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"cs.amount","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"cs.amount","",$param,'align="right"',$sortfield,$sortorder);
@ -305,7 +305,7 @@ if ($conf->tax->enabled)
$total = 0 ; $total = 0 ;
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"pv.datev","",$param,'width="120"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"pv.datev","",$param,'width="140px"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"pv.label","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"pv.label","",$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"pv.amount","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"pv.amount","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("RefPayment"),$_SERVER["PHP_SELF"],"pv.rowid","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("RefPayment"),$_SERVER["PHP_SELF"],"pv.rowid","",$param,'',$sortfield,$sortorder);
@ -338,7 +338,7 @@ if ($conf->tax->enabled)
$i++; $i++;
} }
print '<tr class="liste_total"><td align="right" colspan="2">'.$langs->trans("Total").'</td>'; print '<tr class="liste_total"><td colspan="2">'.$langs->trans("Total").'</td>';
print '<td align="right">'.price($total)."</td>"; print '<td align="right">'.price($total)."</td>";
print '<td align="center">&nbsp;</td>'; print '<td align="center">&nbsp;</td>';
print '<td align="center">&nbsp;</td>'; print '<td align="center">&nbsp;</td>';

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
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs; $outputlangs = $langs;
$newlang = ''; $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
$newlang = $_REQUEST['lang_id']; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $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
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs; $outputlangs = $langs;
$newlang = ''; $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
$newlang = $_REQUEST['lang_id']; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $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');
} }
@ -3324,52 +3345,9 @@ if ($action == 'create')
print '</tr>'; print '</tr>';
} }
// Other attributes (TODO Move this into an include) // Other attributes
$res = $object->fetch_optionals($object->id, $extralabels); $cols = 5;
$parameters = array('colspan' => ' colspan="5"', "cols" => 5); include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by
// hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
foreach ($extrafields->attribute_label as $key => $label)
{
if ($action == 'edit_extras') {
$value = (isset($_POST["options_" . $key]) ? $_POST["options_" . $key] : $object->array_options ["options_" . $key]);
} else {
$value = $object->array_options ["options_" . $key];
}
if ($extrafields->attribute_type [$key] == 'separate') {
print $extrafields->showSeparator($key);
} else {
print '<tr><td';
if (! empty($extrafields->attribute_required [$key]))
print ' class="fieldrequired"';
print '>' . $label . '</td><td colspan="5">';
// Convert date into timestamp format
if (in_array($extrafields->attribute_type [$key], array('date','datetime'))) {
$value = isset($_POST["options_" . $key]) ? dol_mktime($_POST["options_" . $key . "hour"], $_POST["options_" . $key . "min"], 0, $_POST["options_" . $key . "month"], $_POST["options_" . $key . "day"], $_POST["options_" . $key . "year"]) : $db->jdate($object->array_options ['options_' . $key]);
}
if ($action == 'edit_extras' && $user->rights->facture->creer && GETPOST('attribute') == $key) {
print '<form enctype="multipart/form-data" action="' . $_SERVER["PHP_SELF"] . '" method="post" name="formsoc">';
print '<input type="hidden" name="action" value="update_extras">';
print '<input type="hidden" name="attribute" value="' . $key . '">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="id" value="' . $object->id . '">';
print $extrafields->showInputField($key, $value);
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '</form>';
} else {
print $extrafields->showOutputField($key, $value);
if ($object->statut == 0 && $user->rights->facture->creer)
print '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=edit_extras&attribute=' . $key . '">' . img_picto('', 'edit') . ' ' . $langs->trans('Modify') . '</a>';
}
print '</td></tr>' . "\n";
}
}
}
print '</table><br>'; print '</table><br>';
@ -3622,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";
@ -3644,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>';
@ -3657,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;
@ -3675,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 {
@ -3685,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

@ -398,7 +398,7 @@ if ($id > 0 || ! empty($ref))
// Si fichier png PDF d'1 page trouve // Si fichier png PDF d'1 page trouve
if (file_exists($fileimage)) if (file_exists($fileimage))
{ {
print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercufacture&file='.urlencode($relativepathimage).'">'; print '<img style="background: #FFF" src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercufacture&file='.urlencode($relativepathimage).'">';
} }
// Si fichier png PDF de plus d'1 page trouve // Si fichier png PDF de plus d'1 page trouve
elseif (file_exists($fileimagebis)) elseif (file_exists($fileimagebis))
@ -411,12 +411,12 @@ elseif (file_exists($fileimagebis))
if (file_exists($dir_output.$preview)) if (file_exists($dir_output.$preview))
{ {
print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercufacture&file='.urlencode($preview).'"><p>'; print '<img style="background: #FFF" src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercufacture&file='.urlencode($preview).'"><p>';
} }
} }
} }
$db->close();
llxFooter(); llxFooter();
$db->close();

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
* @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='', $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,43 +1740,48 @@ 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)
}
}
}
// Trigger calls
if (! $error)
{ {
// Call trigger $dirsource=$fileentry['name'];
$result=$this->call_trigger('BILL_VALIDATE',$user); $dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource);
if ($result < 0) $error++; $dirsource=$fileentry['path'].'/'.$dirsource;
//TODO: Restoring ref, facnumber, statut, brouillon to previous value if trigger fail $dirdest=$fileentry['path'].'/'.$dirdest;
// End call triggers @rename($dirsource, $dirdest);
}
}
}
}
} }
// Set new ref and define current statut // Set new ref and define current statut

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
$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;
contrat_pdf_create($db, $object->id, $object->modelpdf, $outputlangs); $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, 'contract'); $keys=array_keys($tmp); $model=$keys[0]; }
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
} }
*/
unset($_POST ['prod_entry_mode']); unset($_POST ['prod_entry_mode']);
@ -1189,52 +1188,8 @@ else
} }
// Other attributes // Other attributes
$parameters=array('colspan' => ' colspan="3"'); $cols = 3;
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
$res = $object->fetch_optionals($object->id, $extralabels);
if (empty($reshook) && ! empty($extrafields->attribute_label)) {
foreach ($extrafields->attribute_label as $key => $label) {
if ($action == 'edit_extras') {
$value = (isset($_POST ["options_" . $key]) ? $_POST ["options_" . $key] : $object->array_options ["options_" . $key]);
} else {
$value = $object->array_options ["options_" . $key];
}
if ($extrafields->attribute_type [$key] == 'separate') {
print $extrafields->showSeparator($key);
} else {
print '<tr><td';
if (! empty($extrafields->attribute_required [$key]))
print ' class="fieldrequired"';
print '>' . $label . '</td><td colspan="5">';
// Convert date into timestamp format
if (in_array($extrafields->attribute_type [$key], array('date','datetime'))) {
$value = isset($_POST ["options_" . $key]) ? dol_mktime($_POST ["options_" . $key . "hour"], $_POST ["options_" . $key . "min"], 0, $_POST ["options_" . $key . "month"], $_POST ["options_" . $key . "day"], $_POST ["options_" . $key . "year"]) : $db->jdate($object->array_options ['options_' . $key]);
}
if ($action == 'edit_extras' && $user->rights->commande->creer && GETPOST('attribute') == $key) {
print '<form enctype="multipart/form-data" action="' . $_SERVER["PHP_SELF"] . '" method="post" name="formcontract">';
print '<input type="hidden" name="action" value="update_extras">';
print '<input type="hidden" name="attribute" value="' . $key . '">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="id" value="' . $object->id . '">';
print $extrafields->showInputField($key, $value);
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '</form>';
} else {
print $extrafields->showOutputField($key, $value);
if ($object->statut == 0 && $user->rights->commande->creer)
print '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=edit_extras&attribute=' . $key . '">' . img_picto('', 'edit') . ' ' . $langs->trans('Modify') . '</a>';
}
print '</td></tr>' . "\n";
}
}
}
print "</table>"; print "</table>";

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

@ -141,7 +141,7 @@ if ($action == 'add')
} }
} }
$result=$extrafields->addExtraField($_POST['attrname'],$_POST['label'],$_POST['type'],$_POST['pos'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0),$default_value,$params); $result=$extrafields->addExtraField($_POST['attrname'],$_POST['label'],$_POST['type'],$_POST['pos'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0),$default_value,$params,(GETPOST('alwayseditable')?1:0));
if ($result > 0) if ($result > 0)
{ {
setEventMessage($langs->trans('SetupSaved')); setEventMessage($langs->trans('SetupSaved'));
@ -278,7 +278,7 @@ if ($action == 'update')
$params['options'][$key] = $value; $params['options'][$key] = $value;
} }
} }
$result=$extrafields->update($_POST['attrname'],$_POST['label'],$_POST['type'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0),$pos,$params); $result=$extrafields->update($_POST['attrname'],$_POST['label'],$_POST['type'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0),$pos,$params,(GETPOST('alwayseditable')?1:0));
if ($result > 0) if ($result > 0)
{ {
setEventMessage($langs->trans('SetupSaved')); setEventMessage($langs->trans('SetupSaved'));

View File

@ -0,0 +1,52 @@
<?php
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/ajax/productonoff.php
* \brief File to set tosell and tobuy for product
*/
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
$action=GETPOST('action','alpha');
$id=GETPOST('id', 'int');
$value=GETPOST('value', 'int');
$object = new GenericObject($db);
/*
* View
*/
top_httphead();
print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
// Registering new values
if (! empty($action) && ! empty($id) && $user->rights->produit->creer) {
if ($action == 'setstatus')
$object->setValueFrom('tosell', $value, 'product', $id);
else if ($action == 'setstatus_buy')
$object->setValueFrom('tobuy', $value, 'product', $id);
}

View File

@ -37,12 +37,28 @@ class box_clients extends ModeleBoxes
var $depends = array("societe"); var $depends = array("societe");
var $db; var $db;
var $param; var $enabled = 1;
var $info_box_head = array(); var $info_box_head = array();
var $info_box_contents = array(); var $info_box_contents = array();
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
function __construct($db,$param='')
{
global $conf, $user;
$this->db = $db;
// disable box for such cases
if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option
}
/** /**
* Load data for box to show them later * Load data for box to show them later
* *

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),
); );
$this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"', 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][] = 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

@ -58,12 +58,12 @@ class box_propales extends ModeleBoxes
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";
@ -71,7 +71,8 @@ class box_propales extends ModeleBoxes
$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 ";
else $sql.= " ORDER BY p.tms DESC, p.ref DESC ";
$sql.= $db->plimit($max, 0); $sql.= $db->plimit($max, 0);
$result = $db->query($sql); $result = $db->query($sql);
@ -85,12 +86,16 @@ class box_propales extends ModeleBoxes
while ($i < $num) while ($i < $num)
{ {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$date=$db->jdate($objp->dp);
$datec=$db->jdate($objp->datec); $datec=$db->jdate($objp->datec);
$datem=$db->jdate($objp->tms);
$dateterm=$db->jdate($objp->fin_validite); $dateterm=$db->jdate($objp->fin_validite);
$dateclose=$db->jdate($objp->date_cloture); $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,
@ -110,9 +115,13 @@ class box_propales 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' => $propalstatic->LibStatut($objp->fk_statut,3)); 'text' => $propalstatic->LibStatut($objp->fk_statut,3));
$i++; $i++;

View File

@ -39,11 +39,28 @@ class box_prospect extends ModeleBoxes
var $depends = array("societe"); var $depends = array("societe");
var $db; var $db;
var $enabled = 1;
var $info_box_head = array(); var $info_box_head = array();
var $info_box_contents = array(); var $info_box_contents = array();
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
function __construct($db,$param='')
{
global $conf, $user;
$this->db = $db;
// disable box for such cases
if (! empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) $this->enabled=0; // disabled by this option
}
/** /**
* Load data into info_box_contents array to show array later. * Load data into info_box_contents array to show array later.
* *

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,6 +85,7 @@ class box_supplier_orders 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);
$urlo = DOL_URL_ROOT."/fourn/commande/card.php?id=".$objp->rowid; $urlo = DOL_URL_ROOT."/fourn/commande/card.php?id=".$objp->rowid;
@ -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

@ -118,10 +118,10 @@ class CMailFile
$this->mixed_boundary = "multipart_x." . time() . ".x_boundary"; $this->mixed_boundary = "multipart_x." . time() . ".x_boundary";
// On defini related_boundary // On defini related_boundary
$this->related_boundary = 'mul_'.dol_hash(uniqid("dolibarr2")); $this->related_boundary = 'mul_'.dol_hash(uniqid("dolibarr2"), 3); // Force md5 hash (does not contains special chars)
// On defini alternative_boundary // On defini alternative_boundary
$this->alternative_boundary = 'mul_'.dol_hash(uniqid("dolibarr3")); $this->alternative_boundary = 'mul_'.dol_hash(uniqid("dolibarr3"), 3); // Force md5 hash (does not contains special chars)
// If ending method not defined // If ending method not defined
if (empty($conf->global->MAIN_MAIL_SENDMODE)) $conf->global->MAIN_MAIL_SENDMODE='mail'; if (empty($conf->global->MAIN_MAIL_SENDMODE)) $conf->global->MAIN_MAIL_SENDMODE='mail';
@ -971,7 +971,7 @@ class CMailFile
} }
// cid // cid
$this->html_images[$i]["cid"] = dol_hash(uniqid(time())); $this->html_images[$i]["cid"] = dol_hash(uniqid(time()), 3); // Force md5 hash (does not contains special chars)
$this->html = preg_replace("/src=\"$src\"|src='$src'/i", "src=\"cid:".$this->html_images[$i]["cid"]."\"", $this->html); $this->html = preg_replace("/src=\"$src\"|src='$src'/i", "src=\"cid:".$this->html_images[$i]["cid"]."\"", $this->html);
} }
$i++; $i++;

View File

@ -1747,6 +1747,7 @@ abstract class CommonObject
* @param string $origin Linked element type * @param string $origin Linked element type
* @param int $origin_id Linked element id * @param int $origin_id Linked element id
* @return int <=0 if KO, >0 if OK * @return int <=0 if KO, >0 if OK
* @see fetchObjectLinked, updateObjectLinked, deleteObjectLinked
*/ */
function add_object_linked($origin=null, $origin_id=null) function add_object_linked($origin=null, $origin_id=null)
{ {
@ -1790,6 +1791,7 @@ abstract class CommonObject
* @param string $targettype Object target type * @param string $targettype Object target type
* @param string $clause 'OR' or 'AND' clause used when both source id and target id are provided * @param string $clause 'OR' or 'AND' clause used when both source id and target id are provided
* @return void * @return void
* @see add_object_linked, updateObjectLinked, deleteObjectLinked
*/ */
function fetchObjectLinked($sourceid='',$sourcetype='',$targetid='',$targettype='',$clause='OR') function fetchObjectLinked($sourceid='',$sourcetype='',$targetid='',$targettype='',$clause='OR')
{ {
@ -1819,6 +1821,12 @@ abstract class CommonObject
$sourcetype = (! empty($sourcetype) ? $sourcetype : $this->element); $sourcetype = (! empty($sourcetype) ? $sourcetype : $this->element);
$targettype = (! empty($targettype) ? $targettype : $this->element); $targettype = (! empty($targettype) ? $targettype : $this->element);
if (empty($sourceid) && empty($targetid))
{
dol_print_error('','Bad usage of function. No parameter defined and no id defined');
return -1;
}
// Links beetween objects are stored in this table // Links beetween objects are stored in this table
$sql = 'SELECT fk_source, sourcetype, fk_target, targettype'; $sql = 'SELECT fk_source, sourcetype, fk_target, targettype';
$sql.= ' FROM '.MAIN_DB_PREFIX.'element_element'; $sql.= ' FROM '.MAIN_DB_PREFIX.'element_element';
@ -1944,6 +1952,7 @@ abstract class CommonObject
* @param int $targetid Object target id * @param int $targetid Object target id
* @param string $targettype Object target type * @param string $targettype Object target type
* @return int >0 if OK, <0 if KO * @return int >0 if OK, <0 if KO
* @see add_object_linked, fetObjectLinked, deleteObjectLinked
*/ */
function updateObjectLinked($sourceid='', $sourcetype='', $targetid='', $targettype='') function updateObjectLinked($sourceid='', $sourcetype='', $targetid='', $targettype='')
{ {
@ -1989,6 +1998,7 @@ abstract class CommonObject
* @param int $targetid Object target id * @param int $targetid Object target id
* @param string $targettype Object target type * @param string $targettype Object target type
* @return int >0 if OK, <0 if KO * @return int >0 if OK, <0 if KO
* @see add_object_linked, updateObjectLinked, fetchObjectLinked
*/ */
function deleteObjectLinked($sourceid='', $sourcetype='', $targetid='', $targettype='') function deleteObjectLinked($sourceid='', $sourcetype='', $targetid='', $targettype='')
{ {

View File

@ -50,6 +50,8 @@ class ExtraFields
var $attribute_param; var $attribute_param;
// Int to store position of attribute // Int to store position of attribute
var $attribute_pos; var $attribute_pos;
// Int to store if attribute is editable regardless of the document status
var $attribute_alwayseditable;
var $error; var $error;
var $errno; var $errno;
@ -103,9 +105,10 @@ class ExtraFields
* @param int $required Is field required or not * @param int $required Is field required or not
* @param string $default_value Defaulted value * @param string $default_value Defaulted value
* @param array $param Params for field * @param array $param Params for field
* @param int $alwayseditable Is attribute always editable regardless of the document status
* @return int <=0 if KO, >0 if OK * @return int <=0 if KO, >0 if OK
*/ */
function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0,$default_value='', $param=0) function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param=0, $alwayseditable=0)
{ {
if (empty($attrname)) return -1; if (empty($attrname)) return -1;
if (empty($label)) return -1; if (empty($label)) return -1;
@ -119,7 +122,7 @@ class ExtraFields
if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' || $type == 'separate') if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' || $type == 'separate')
{ {
// Add declaration of field into table // Add declaration of field into table
$result2=$this->create_label($attrname,$label,$type,$pos,$size,$elementtype, $unique, $required, $param); $result2=$this->create_label($attrname,$label,$type,$pos,$size,$elementtype, $unique, $required, $param, $alwayseditable);
$err2=$this->errno; $err2=$this->errno;
if ($result2 > 0 || ($err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' && $err2 == 'DB_ERROR_RECORD_ALREADY_EXISTS')) if ($result2 > 0 || ($err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' && $err2 == 'DB_ERROR_RECORD_ALREADY_EXISTS'))
{ {
@ -217,9 +220,10 @@ class ExtraFields
* @param int $unique Is field unique or not * @param int $unique Is field unique or not
* @param int $required Is field required or not * @param int $required Is field required or not
* @param array||string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param array||string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
* @param int $alwayseditable Is attribute always editable regardless of the document status
* @return int <=0 if KO, >0 if OK * @return int <=0 if KO, >0 if OK
*/ */
private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='') private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0)
{ {
global $conf; global $conf;
@ -241,7 +245,7 @@ class ExtraFields
$params=''; $params='';
} }
$sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(name, label, type, pos, size, entity, elementtype, fieldunique, fieldrequired, param)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(name, label, type, pos, size, entity, elementtype, fieldunique, fieldrequired, param, alwayseditable)";
$sql.= " VALUES('".$attrname."',"; $sql.= " VALUES('".$attrname."',";
$sql.= " '".$this->db->escape($label)."',"; $sql.= " '".$this->db->escape($label)."',";
$sql.= " '".$type."',"; $sql.= " '".$type."',";
@ -251,7 +255,8 @@ class ExtraFields
$sql.= " '".$elementtype."',"; $sql.= " '".$elementtype."',";
$sql.= " '".$unique."',"; $sql.= " '".$unique."',";
$sql.= " '".$required."',"; $sql.= " '".$required."',";
$sql.= " '".$params."'"; $sql.= " '".$params."',";
$sql.= " '".$alwayseditable."'";
$sql.=')'; $sql.=')';
dol_syslog(get_class($this)."::create_label", LOG_DEBUG); dol_syslog(get_class($this)."::create_label", LOG_DEBUG);
@ -347,9 +352,10 @@ class ExtraFields
* @param int $required Is field required or not * @param int $required Is field required or not
* @param int $pos Position of attribute * @param int $pos Position of attribute
* @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
* @param int $alwayseditable Is attribute always editable regardless of the document status
* @return int >0 if OK, <=0 if KO * @return int >0 if OK, <=0 if KO
*/ */
function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos=0,$param='') function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0)
{ {
$table=$elementtype.'_extrafields'; $table=$elementtype.'_extrafields';
@ -384,7 +390,7 @@ class ExtraFields
{ {
if ($label) if ($label)
{ {
$result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param); $result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param,$alwayseditable);
} }
if ($result > 0) if ($result > 0)
{ {
@ -432,9 +438,10 @@ class ExtraFields
* @param int $required Is field required or not * @param int $required Is field required or not
* @param int $pos Position of attribute * @param int $pos Position of attribute
* @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
* @param int $alwayseditable Is attribute always editable regardless of the document status
* @return int <=0 if KO, >0 if OK * @return int <=0 if KO, >0 if OK
*/ */
private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='') private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0)
{ {
global $conf; global $conf;
dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required); dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required);
@ -465,6 +472,7 @@ class ExtraFields
$sql.= " fieldunique,"; $sql.= " fieldunique,";
$sql.= " fieldrequired,"; $sql.= " fieldrequired,";
$sql.= " pos,"; $sql.= " pos,";
$sql.= " alwayseditable,";
$sql.= " param"; $sql.= " param";
$sql.= ") VALUES ("; $sql.= ") VALUES (";
$sql.= "'".$attrname."',"; $sql.= "'".$attrname."',";
@ -476,6 +484,7 @@ class ExtraFields
$sql.= " '".$unique."',"; $sql.= " '".$unique."',";
$sql.= " '".$required."',"; $sql.= " '".$required."',";
$sql.= " '".$pos."',"; $sql.= " '".$pos."',";
$sql.= " '".$alwayseditable."',";
$sql.= " '".$param."'"; $sql.= " '".$param."'";
$sql.= ")"; $sql.= ")";
dol_syslog(get_class($this)."::update_label", LOG_DEBUG); dol_syslog(get_class($this)."::update_label", LOG_DEBUG);
@ -529,7 +538,7 @@ class ExtraFields
if (!$forceload && !empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) if (!$forceload && !empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))
return $array_name_label; return $array_name_label;
$sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos"; $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable";
$sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; $sql.= " FROM ".MAIN_DB_PREFIX."extrafields";
$sql.= " WHERE entity IN (0,".$conf->entity.")"; $sql.= " WHERE entity IN (0,".$conf->entity.")";
if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'"; if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'";
@ -557,6 +566,7 @@ class ExtraFields
$this->attribute_required[$tab->name]=$tab->fieldrequired; $this->attribute_required[$tab->name]=$tab->fieldrequired;
$this->attribute_param[$tab->name]=unserialize($tab->param); $this->attribute_param[$tab->name]=unserialize($tab->param);
$this->attribute_pos[$tab->name]=$tab->pos; $this->attribute_pos[$tab->name]=$tab->pos;
$this->attribute_alwayseditable[$tab->name]=$tab->alwayseditable;
} }
} }

View File

@ -161,29 +161,29 @@ class HookManager
{ {
//print "Before hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction." result=".$result."<br>\n"; //print "Before hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction." result=".$result."<br>\n";
//print 'class='.get_class($actionclassinstance).' method='.$method.' action='.$action; // jump to next module/class if method does not exists
// jump to next class if method does not exists
if (! method_exists($actionclassinstance,$method)) continue; if (! method_exists($actionclassinstance,$method)) continue;
// test to avoid to run twice a hook, when a module implements several active contexts // test to avoid to run twice a hook, when a module implements several active contexts
if (in_array($module,$modulealreadyexecuted)) continue; if (in_array($module,$modulealreadyexecuted)) continue;
$modulealreadyexecuted[$module]=$module; // Use the $currentcontext in method for avoid to run twice $modulealreadyexecuted[$module]=$module; // Use the $currentcontext in method for avoid to run twice
// Clean class (an error may have been set into a previous call of another method for same module/hook)
$actionclassinstance->error=0;
$actionclassinstance->errors=array();
// Add current context for avoid method execution in bad context, you can add this test in your method : eg if($currentcontext != 'formfile') return; // Add current context for avoid method execution in bad context, you can add this test in your method : eg if($currentcontext != 'formfile') return;
$parameters['currentcontext'] = $context; $parameters['currentcontext'] = $context;
// Hooks that must return int (hooks with type 'addreplace') // Hooks that must return int (hooks with type 'addreplace')
if ($hooktype == 'addreplace') if ($hooktype == 'addreplace')
{ {
dol_syslog("Call method ".$method." of class ".get_class($actionclassinstance).", module=".$module.", hooktype=".$hooktype, LOG_DEBUG);
$resaction += $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example) $resaction += $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example)
if ($resaction < 0 || ! empty($actionclassinstance->error) || (! empty($actionclassinstance->errors) && count($actionclassinstance->errors) > 0)) if ($resaction < 0 || ! empty($actionclassinstance->error) || (! empty($actionclassinstance->errors) && count($actionclassinstance->errors) > 0))
{ {
$error++; $error++;
$this->error=$actionclassinstance->error; $this->errors=array_merge($this->errors, (array) $actionclassinstance->errors); $this->error=$actionclassinstance->error; $this->errors=array_merge($this->errors, (array) $actionclassinstance->errors);
// TODO dead code to remove (do not enable this, but fix hook instead) dol_syslog("Error on hook module=".$module.", method ".$method.", class ".get_class($actionclassinstance).", hooktype=".$hooktype.(empty($this->error)?'':" ".$this->error).(empty($this->errors)?'':" ".join(",",$this->errors)), LOG_ERR);
/* Change must be inside the method of hook if required. Only hook must decide if $action must be modified or not.
if ($method == 'doActions')
{
if ($action=='add') $action='create';
if ($action=='update') $action='edit';
}*/
} }
if (is_array($actionclassinstance->results)) $this->resArray =array_merge($this->resArray, $actionclassinstance->results); if (is_array($actionclassinstance->results)) $this->resArray =array_merge($this->resArray, $actionclassinstance->results);
@ -195,6 +195,7 @@ class HookManager
// TODO. this should be done into the method of hook by returning nothing // TODO. this should be done into the method of hook by returning nothing
if (is_array($parameters) && ! empty($parameters['special_code']) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actionclassinstance->module_number) continue; if (is_array($parameters) && ! empty($parameters['special_code']) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actionclassinstance->module_number) continue;
//dol_syslog("Call method ".$method." of class ".get_class($actionclassinstance).", module=".$module.", hooktype=".$hooktype, LOG_DEBUG);
$result = $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example) $result = $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example)
if (! empty($actionclassinstance->results) && is_array($actionclassinstance->results)) $this->resArray =array_merge($this->resArray, $actionclassinstance->results); if (! empty($actionclassinstance->results) && is_array($actionclassinstance->results)) $this->resArray =array_merge($this->resArray, $actionclassinstance->results);

View File

@ -14,6 +14,7 @@
* Copyright (C) 2011 Herve Prot <herve.prot@symeos.com> * Copyright (C) 2011 Herve Prot <herve.prot@symeos.com>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2013 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2013 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -193,7 +194,7 @@ class Form
{ {
$ret.='<td align="left">'; $ret.='<td align="left">';
$ret.='<input type="submit" class="button" name="modify" value="'.$langs->trans("Modify").'">'; $ret.='<input type="submit" class="button" name="modify" value="'.$langs->trans("Modify").'">';
$ret.='<br>'."\n"; if (preg_match('/ckeditor|textarea/',$typeofdata)) $ret.='<br>'."\n";
$ret.='<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; $ret.='<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
$ret.='</td>'; $ret.='</td>';
} }
@ -477,9 +478,11 @@ class Form
$out=''; $out='';
$countryArray=array(); $countryArray=array();
$favorite=array();
$label=array(); $label=array();
$atleastonefavorite=0;
$sql = "SELECT rowid, code as code_iso, code_iso as code_iso3, label"; $sql = "SELECT rowid, code as code_iso, code_iso as code_iso3, label, favorite";
$sql.= " FROM ".MAIN_DB_PREFIX."c_country"; $sql.= " FROM ".MAIN_DB_PREFIX."c_country";
$sql.= " WHERE active = 1"; $sql.= " WHERE active = 1";
//$sql.= " ORDER BY code ASC"; //$sql.= " ORDER BY code ASC";
@ -502,15 +505,22 @@ class Form
$countryArray[$i]['code_iso'] = $obj->code_iso; $countryArray[$i]['code_iso'] = $obj->code_iso;
$countryArray[$i]['code_iso3'] = $obj->code_iso3; $countryArray[$i]['code_iso3'] = $obj->code_iso3;
$countryArray[$i]['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso)!="Country".$obj->code_iso?$langs->transnoentitiesnoconv("Country".$obj->code_iso):($obj->label!='-'?$obj->label:'')); $countryArray[$i]['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso)!="Country".$obj->code_iso?$langs->transnoentitiesnoconv("Country".$obj->code_iso):($obj->label!='-'?$obj->label:''));
$countryArray[$i]['favorite'] = $obj->favorite;
$favorite[$i] = $obj->favorite;
$label[$i] = dol_string_unaccent($countryArray[$i]['label']); $label[$i] = dol_string_unaccent($countryArray[$i]['label']);
$i++; $i++;
} }
array_multisort($label, SORT_ASC, $countryArray); array_multisort($favorite, SORT_DESC, $label, SORT_ASC, $countryArray);
foreach ($countryArray as $row) foreach ($countryArray as $row)
{ {
//print 'rr'.$selected.'-'.$row['label'].'-'.$row['code_iso'].'<br>'; if ($row['favorite'] && $row['code_iso']) $atleastonefavorite++;
if (empty($row['favorite']) && $atleastonefavorite)
{
$atleastonefavorite=0;
$out.= '<option value="" disabled="disabled">----------------------</option>';
}
if ($selected && $selected != '-1' && ($selected == $row['rowid'] || $selected == $row['code_iso'] || $selected == $row['code_iso3'] || $selected == $row['label']) ) if ($selected && $selected != '-1' && ($selected == $row['rowid'] || $selected == $row['code_iso'] || $selected == $row['code_iso3'] || $selected == $row['label']) )
{ {
$foundselected=true; $foundselected=true;
@ -1135,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
@ -2703,6 +2716,7 @@ class Form
* @param int $maxlength Maximum length for labels * @param int $maxlength Maximum length for labels
* @param int $excludeafterid Exclude all categories after this leaf in category tree. * @param int $excludeafterid Exclude all categories after this leaf in category tree.
* @return void * @return void
* @see select_categories
*/ */
function select_all_categories($type, $selected='', $htmlname="parent", $maxlength=64, $excludeafterid=0) function select_all_categories($type, $selected='', $htmlname="parent", $maxlength=64, $excludeafterid=0)
{ {
@ -4390,7 +4404,7 @@ class Form
{ {
global $dolibarr_main_url_root; global $dolibarr_main_url_root;
$ret.='<!-- Put link to gravatar -->'; $ret.='<!-- Put link to gravatar -->';
$ret.='<img alt="Photo found on Gravatar" title="Photo Gravatar.com - email '.$email.'" border="0" width="'.$width.'" src="http://www.gravatar.com/avatar/'.dol_hash($email).'?s='.$width.'&d='.urlencode(dol_buildpath('/theme/common/nophoto.jpg',2)).'">'; $ret.='<img alt="Photo found on Gravatar" title="Photo Gravatar.com - email '.$email.'" border="0" width="'.$width.'" src="http://www.gravatar.com/avatar/'.dol_hash($email,3).'?s='.$width.'&d='.urlencode(dol_buildpath('/theme/common/nophoto.jpg',2)).'">'; // gravatar need md5 hash
} }
else else
{ {

View File

@ -266,6 +266,8 @@ class FormActions
if ($selected == 'manual') $selected='AC_OTH'; if ($selected == 'manual') $selected='AC_OTH';
if ($selected == 'auto') $selected='AC_OTH_AUTO'; if ($selected == 'auto') $selected='AC_OTH_AUTO';
if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']);
print $form->selectarray($htmlname, $arraylist, $selected); print $form->selectarray($htmlname, $arraylist, $selected);
if ($user->admin && empty($onlyautoornot) && empty($hideinfohelp)) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); if ($user->admin && empty($onlyautoornot) && empty($hideinfohelp)) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
} }

View File

@ -682,22 +682,21 @@ class FormCompany
* @param string $selected Default selected value * @param string $selected Default selected value
* @param string $htmlname HTML select name * @param string $htmlname HTML select name
* @param string $source Source ('internal' or 'external') * @param string $source Source ('internal' or 'external')
* @param string $order Sort criteria * @param string $sortorder Sort criteria
* @param int $showempty 1=Add en empty line * @param int $showempty 1=Add en empty line
* @return void * @return void
*/ */
function selectTypeContact($object, $selected, $htmlname = 'type', $source='internal', $order='code', $showempty=0) function selectTypeContact($object, $selected, $htmlname = 'type', $source='internal', $sortorder='code', $showempty=0)
{ {
if (is_object($object) && method_exists($object, 'liste_type_contact')) if (is_object($object) && method_exists($object, 'liste_type_contact'))
{ {
$lesTypes = $object->liste_type_contact($source, $order, 0, 1); $lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1);
print '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">'; print '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
if ($showempty) print '<option value="0"></option>'; if ($showempty) print '<option value="0"></option>';
foreach($lesTypes as $key=>$value) foreach($lesTypes as $key=>$value)
{ {
print '<option value="'.$key.'"'; print '<option value="'.$key.'"';
if ($key == $selected) if ($key == $selected) print ' selected';
print ' selected';
print '>'.$value.'</option>'; print '>'.$value.'</option>';
} }
print "</select>\n"; print "</select>\n";

View File

@ -73,12 +73,12 @@ class FormFile
global $conf,$langs, $hookmanager; global $conf,$langs, $hookmanager;
$hookmanager->initHooks(array('formfile')); $hookmanager->initHooks(array('formfile'));
if (! empty($conf->browser->phone)) return 0; if (! empty($conf->browser->layout) && $conf->browser->layout != 'classic') return 0;
if ((! empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD) && $useajax) || ($useajax==2)) if ((! empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD) && $useajax) || ($useajax==2))
{ {
// TODO: Cheeck this works with 2 forms on same page // TODO: Check this works with 2 forms on same page
// TODO: Cheeck this works with GED module, otherwise, force useajax to 0 // TODO: Check this works with GED module, otherwise, force useajax to 0
// TODO: This does not support option savingdocmask // TODO: This does not support option savingdocmask
// TODO: This break feature to upload links too // TODO: This break feature to upload links too
return $this->_formAjaxFileUpload($object); return $this->_formAjaxFileUpload($object);

View File

@ -699,7 +699,7 @@ class FormMail
$sql.= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")"; $sql.= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")";
if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')";
$sql.= $db->order("lang,label","ASC"); $sql.= $db->order("lang,label","ASC");
print $sql; //print $sql;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)

View File

@ -307,6 +307,7 @@ class FormOther
* @param string $htmlname Name of combo list * @param string $htmlname Name of combo list
* @param int $nocateg Show also an entry "Not categorized" * @param int $nocateg Show also an entry "Not categorized"
* @return string Html combo list code * @return string Html combo list code
* @see select_all_categories
*/ */
function select_categories($type,$selected=0,$htmlname='search_categ',$nocateg=0) function select_categories($type,$selected=0,$htmlname='search_categ',$nocateg=0)
{ {
@ -318,7 +319,7 @@ class FormOther
$tab_categs = $static_categs->get_full_arbo($type); $tab_categs = $static_categs->get_full_arbo($type);
// Print a select with each of them // Print a select with each of them
$moreforfilter ='<select class="flat" name="'.$htmlname.'">'; $moreforfilter ='<select class="flat" id="select_categ_'.$htmlname.'" name="'.$htmlname.'">';
$moreforfilter.='<option value="">&nbsp;</option>'; // Should use -1 to say nothing $moreforfilter.='<option value="">&nbsp;</option>'; // Should use -1 to say nothing
if (is_array($tab_categs)) if (is_array($tab_categs))

View File

@ -167,7 +167,7 @@ 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
@ -175,7 +175,7 @@ class FormProjets
*/ */
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))
{ {
@ -162,14 +158,18 @@ class InfoBox
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

@ -155,7 +155,7 @@ class MobileDetect
'Asus' => 'Asus.*Galaxy|PadFone.*Mobile', 'Asus' => 'Asus.*Galaxy|PadFone.*Mobile',
// @ref: http://www.micromaxinfo.com/mobiles/smartphones // @ref: http://www.micromaxinfo.com/mobiles/smartphones
// Added because the codes might conflict with Acer Tablets. // Added because the codes might conflict with Acer Tablets.
'Micromax' => 'Micromax.*\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\b', 'Micromax' => 'Micromax.*\bA\d+\b',
'Palm' => 'PalmSource|Palm', // avantgo|blazer|elaine|hiptop|plucker|xiino ; @todo - complete the regex. 'Palm' => 'PalmSource|Palm', // avantgo|blazer|elaine|hiptop|plucker|xiino ; @todo - complete the regex.
'Vertu' => 'Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature', // Just for fun ;) 'Vertu' => 'Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature', // Just for fun ;)
// @ref: http://www.pantech.co.kr/en/prod/prodList.do?gbrand=VEGA (PANTECH) // @ref: http://www.pantech.co.kr/en/prod/prodList.do?gbrand=VEGA (PANTECH)
@ -179,7 +179,7 @@ class MobileDetect
protected static $tabletDevices = array( protected static $tabletDevices = array(
'iPad' => 'iPad|iPad.*Mobile', // @todo: check for mobile friendly emails topic. 'iPad' => 'iPad|iPad.*Mobile', // @todo: check for mobile friendly emails topic.
'NexusTablet' => 'Android.*Nexus[\s]+(7|10)|^.*Android.*Nexus(?:(?!Mobile).)*$', 'NexusTablet' => 'Android.*Nexus[\s]+(7|10)|^.*Android.*Nexus(?:(?!Mobile).)*$',
'SamsungTablet' => 'SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-I9205|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705C|SM-T535|SM-T331', // SCH-P709|SCH-P729|SM-T2558 - Samsung Mega - treat them like a regular phone. 'SamsungTablet' => 'SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P\d+|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-N8000|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-N8010|GT-N8005|GT-N8020|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-I9205|SM-T\d+|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-P6000|SM-T3100|SGH-I467|XE500|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|XE500T1C|SM-P605V|SM-P905V|SM-P600X|SM-P900X', // SCH-P709|SCH-P729|SM-T2558 - Samsung Mega - treat them like a regular phone.
// @reference: http://www.labnol.org/software/kindle-user-agent-string/20378/ // @reference: http://www.labnol.org/software/kindle-user-agent-string/20378/
'Kindle' => 'Kindle|Silk.*Accelerated|Android.*\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE)\b', 'Kindle' => 'Kindle|Silk.*Accelerated|Android.*\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE)\b',
// Only the Surface tablets with Windows RT are considered mobile. // Only the Surface tablets with Windows RT are considered mobile.
@ -963,9 +963,14 @@ class MobileDetect
$this->setDetectionType(self::DETECTION_TYPE_MOBILE); $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
if ($this->checkHttpHeadersForMobile()) { if ($this->checkHttpHeadersForMobile())
{
//print "Found it's a mobile from http header";
return true; return true;
} else { }
else
{
//print "Check into user agent ".$this->getUserAgent();
return $this->matchDetectionRulesAgainstUA(); return $this->matchDetectionRulesAgainstUA();
} }

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,8 +85,11 @@ class Notify
{ {
global $conf; global $conf;
$num=-1; $error=0;
$num=0;
if (! $error)
{
$sql = "SELECT n.rowid"; $sql = "SELECT n.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n,"; $sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n,";
$sql.= " ".MAIN_DB_PREFIX."socpeople as c,"; $sql.= " ".MAIN_DB_PREFIX."socpeople as c,";
@ -99,7 +103,7 @@ class Notify
$sql.= " AND s.entity IN (".getEntity('societe', 1).")"; $sql.= " AND s.entity IN (".getEntity('societe', 1).")";
$sql.= " AND s.rowid = ".$socid; $sql.= " AND s.rowid = ".$socid;
dol_syslog("Notify.class::countDefinedNotifications ".$action.", ".$socid."", LOG_DEBUG); dol_syslog(get_class($this)."::countDefinedNotifications ".$action.", ".$socid."", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
@ -108,10 +112,23 @@ class Notify
} }
else else
{ {
$error++;
$this->error=$this->db->error.' sql='.$sql; $this->error=$this->db->error.' sql='.$sql;
return -1; }
} }
if (! $error)
{
// List of notifications enabled for fixed email
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;
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_syslog(get_class($this)."::send action=".$action.", object=".$object->id);
$langs->load("other"); $langs->load("other");
dol_syslog(get_class($this)."::send action=".$action.", socid=".$socid.", texte=".$texte.", objet_type=".$objet_type.", objet_id=".$objet_id.", file=".$file); // 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
$sql = "SELECT s.nom, c.email, c.rowid as cid, c.lastname, c.firstname,"; // 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)
$subject = '['.$application.'] '.$langs->transnoentitiesnoconv("DolibarrNotification");
$message = $langs->transnoentities("YouReceiveMailBecauseOfNotification",$application,$mysoc->name)."\n";
$message.= $langs->transnoentities("YouReceiveMailBecauseOfNotification2",$application,$mysoc->name)."\n";
$message.= "\n";
$message.= $texte;
// Add link
$link='';
switch($objet_type)
{ {
case 'ficheinter': $outputlangs = new Translate('', $conf);
$link='/fichinter/card.php?id='.$objet_id; $outputlangs->setDefaultLang($obj->default_lang);
}
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; break;
case 'propal': case 'ORDER_VALIDATE':
$link='/comm/propal.php?id='.$objet_id; $link='/commande/card.php?id='.$object->id;
$dir_output = $conf->commande->dir_output;
$object_type = 'order';
$mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated",$object->ref);
break; break;
case 'facture': case 'PROPAL_VALIDATE':
$link='/compta/facture.php?facid='.$objet_id; $link='/comm/propal.php?id='.$object->id;
$dir_output = $conf->propal->dir_output;
$object_type = 'propal';
$mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated",$object->ref);
break; break;
case 'order': case 'FICHINTER_VALIDATE':
$link='/commande/card.php?id='.$objet_id; $link='/fichinter/card.php?id='.$object->id;
$dir_output = $conf->facture->dir_output;
$object_type = 'ficheinter';
$mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated",$object->ref);
break; break;
case 'order_supplier': case 'ORDER_SUPPLIER_APPROVE':
$link='/fourn/commande/card.php?id='.$objet_id; $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; break;
} }
// Define $urlwithroot $ref = dol_sanitizeFileName($object->ref);
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); $pdf_path = $dir_output."/".$ref."/".$ref.".pdf";
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file if (! dol_is_file($pdf_path))
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current {
if ($link) $message.="\n".$urlwithroot.$link; // We can't add PDF as it is not generated yet.
$filepdf = '';
}
else
{
$filepdf = $pdf_path;
}
$filename = basename($file); $subject = '['.$application.'] '.$outputlangs->transnoentitiesnoconv("DolibarrNotification");
$mimefile=dol_mimetype($file); $message = $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification",$application,$mysoc->name)."\n";
$message.= $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification2",$application,$mysoc->name)."\n";
$msgishtml=0; $message.= "\n";
$message.= $mesg;
$replyto = $conf->notification->email_from; if ($link) $message=dol_concatdesc($message,$urlwithroot.$link);
$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

@ -194,7 +194,7 @@ class RssParser
} }
$this->_urlRSS = $urlRSS; $this->_urlRSS = $urlRSS;
$newpathofdestfile=$cachedir.'/'.dol_hash($this->_urlRSS); $newpathofdestfile=$cachedir.'/'.dol_hash($this->_urlRSS,3); // Force md5 hash (does not contains special chars)
$newmask='0644'; $newmask='0644';
//dol_syslog("RssPArser::parser parse url=".$urlRSS." => cache file=".$newpathofdestfile); //dol_syslog("RssPArser::parser parse url=".$urlRSS." => cache file=".$newpathofdestfile);

View File

@ -1159,7 +1159,7 @@ class SMTPs
$this->_msgContent[$strType]['data'] = $strContent; $this->_msgContent[$strType]['data'] = $strContent;
if ( $this->getMD5flag() ) if ( $this->getMD5flag() )
$this->_msgContent[$strType]['md5'] = dol_hash($strContent); $this->_msgContent[$strType]['md5'] = dol_hash($strContent, 3);
//} //}
} }
@ -1329,7 +1329,7 @@ class SMTPs
$this->_msgContent['attachment'][$strFileName]['data'] = $strContent; $this->_msgContent['attachment'][$strFileName]['data'] = $strContent;
if ( $this->getMD5flag() ) if ( $this->getMD5flag() )
$this->_msgContent['attachment'][$strFileName]['md5'] = dol_hash($strContent); $this->_msgContent['attachment'][$strFileName]['md5'] = dol_hash($strContent, 3);
} }
} }
@ -1356,7 +1356,7 @@ class SMTPs
$this->_msgContent['image'][$strImageName]['data'] = $strContent; $this->_msgContent['image'][$strImageName]['data'] = $strContent;
if ( $this->getMD5flag() ) if ( $this->getMD5flag() )
$this->_msgContent['image'][$strImageName]['md5'] = dol_hash($strContent); $this->_msgContent['image'][$strImageName]['md5'] = dol_hash($strContent, 3);
} }
} }
// END DOL_CHANGE LDR // END DOL_CHANGE LDR
@ -1487,8 +1487,8 @@ class SMTPs
function _setBoundary() function _setBoundary()
{ {
$this->_smtpsBoundary = "multipart_x." . time() . ".x_boundary"; $this->_smtpsBoundary = "multipart_x." . time() . ".x_boundary";
$this->_smtpsRelatedBoundary = 'mul_'.dol_hash(uniqid("dolibarr2")); $this->_smtpsRelatedBoundary = 'mul_'.dol_hash(uniqid("dolibarr2"), 3);
$this->_smtpsAlternativeBoundary = 'mul_'.dol_hash(uniqid("dolibarr3")); $this->_smtpsAlternativeBoundary = 'mul_'.dol_hash(uniqid("dolibarr3"), 3);
} }
/** /**

View File

@ -701,6 +701,7 @@ class Translate
* @param string $currency_code Currency Code * @param string $currency_code Currency Code
* @param string $amount If not '', show currency + amount according to langs ($10, 10€). * @param string $amount If not '', show currency + amount according to langs ($10, 10€).
* @return string Amount + Currency symbol encoded into UTF8 * @return string Amount + Currency symbol encoded into UTF8
* @deprecated Use method price to output a price
*/ */
function getCurrencyAmount($currency_code, $amount) function getCurrencyAmount($currency_code, $amount)
{ {

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

@ -965,6 +965,7 @@ function complete_dictionary_with_modules(&$taborder,&$tabname,&$tablib,&$tabsql
{ {
//var_dump($objMod->dictionaries['tabname']); //var_dump($objMod->dictionaries['tabname']);
$taborder[] = 0; $taborder[] = 0;
$tabfieldcheck[] = array(); $tabhelp[] = array();
foreach($objMod->dictionaries['tabname'] as $val) foreach($objMod->dictionaries['tabname'] as $val)
{ {
$taborder[] = count($tabname)+1; $taborder[] = count($tabname)+1;
@ -978,7 +979,7 @@ function complete_dictionary_with_modules(&$taborder,&$tabname,&$tablib,&$tabsql
foreach($objMod->dictionaries['tabfieldinsert'] as $val) $tabfieldinsert[] = $val; foreach($objMod->dictionaries['tabfieldinsert'] as $val) $tabfieldinsert[] = $val;
foreach($objMod->dictionaries['tabrowid'] as $val) $tabrowid[] = $val; foreach($objMod->dictionaries['tabrowid'] as $val) $tabrowid[] = $val;
foreach($objMod->dictionaries['tabcond'] as $val) $tabcond[] = $val; foreach($objMod->dictionaries['tabcond'] as $val) $tabcond[] = $val;
foreach($objMod->dictionaries['tabfieldcheck'] as $val) $tabfieldcheck[] = $val; if (! empty($objMod->dictionaries['tabfieldcheck'])) foreach($objMod->dictionaries['tabfieldcheck'] as $val) $tabfieldcheck[] = $val;
if (! empty($objMod->dictionaries['tabhelp'])) foreach($objMod->dictionaries['tabhelp'] as $val) $tabhelp[] = $val; if (! empty($objMod->dictionaries['tabhelp'])) foreach($objMod->dictionaries['tabhelp'] as $val) $tabhelp[] = $val;
//foreach($objMod->dictionaries['tabsqlsort'] as $val) $tablib[] = $val; //foreach($objMod->dictionaries['tabsqlsort'] as $val) $tablib[] = $val;
//$tabname = array_merge ($tabname, $objMod->dictionaries['tabname']); //$tabname = array_merge ($tabname, $objMod->dictionaries['tabname']);

View File

@ -459,3 +459,91 @@ function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0,
return $out; return $out;
} }
/**
* On/off button for product tosell or tobuy
*
* @param int $id Id product to set
* @param string $code Name of constant : status or status_buy
* @param array $input Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid'))
* @return void
*/
function ajax_productonoff($id, $code, $input=array())
{
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
global $conf, $langs, $db;
$object = new Product($db);
$object->fetch($id);
$out= '<script type="text/javascript">
$(function() {
var input = '.json_encode($input).';
// Set constant
$("#set_'.$code.'").click(function() {
$.get( "'.DOL_URL_ROOT.'/core/ajax/productonoff.php", {
action: \'set'.$code.'\',
value: \'1\',
id: \''.$id.'\'
},
function() {
$("#set_'.$code.'").hide();
$("#del_'.$code.'").show();
// Enable another element
if (input.disabled && input.disabled.length > 0) {
$.each(input.disabled, function(key,value) {
$("#" + value).removeAttr("disabled");
if ($("#" + value).hasClass("butActionRefused") == true) {
$("#" + value).removeClass("butActionRefused");
$("#" + value).addClass("butAction");
}
});
// Show another element
} else if (input.showhide && input.showhide.length > 0) {
$.each(input.showhide, function(key,value) {
$("#" + value).show();
});
}
});
});
// Del constant
$("#del_'.$code.'").click(function() {
$.get( "'.DOL_URL_ROOT.'/core/ajax/productonoff.php", {
action: \'set'.$code.'\',
value: \'0\',
id: \''.$id.'\'
},
function() {
$("#del_'.$code.'").hide();
$("#set_'.$code.'").show();
// Disable another element
if (input.disabled && input.disabled.length > 0) {
$.each(input.disabled, function(key,value) {
$("#" + value).attr("disabled", true);
if ($("#" + value).hasClass("butAction") == true) {
$("#" + value).removeClass("butAction");
$("#" + value).addClass("butActionRefused");
}
});
// Hide another element
} else if (input.showhide && input.showhide.length > 0) {
$.each(input.showhide, function(key,value) {
$("#" + value).hide();
});
}
});
});
});
</script>';
if ($code=='status') {
$out.= '<span id="set_'.$code.'" class="linkobject '.($object->$code==1?'hideobject':'').'">'.img_picto($langs->trans("ProductStatusNotOnSell"),'switch_off').'</span>';
$out.= '<span id="del_'.$code.'" class="linkobject '.($object->$code==1?'':'hideobject').'">'.img_picto($langs->trans("ProductStatusOnSell"),'switch_on').'</span>';
}
if ($code=='status_buy') {
$out.= '<span id="set_'.$code.'" class="linkobject '.($object->$code==1?'hideobject':'').'">'.img_picto($langs->trans("ProductStatusNotOnBuy"),'switch_off').'</span>';
$out.= '<span id="del_'.$code.'" class="linkobject '.($object->$code==1?'':'hideobject').'">'.img_picto($langs->trans("ProductStatusOnBuy"),'switch_on').'</span>';
}
return $out;
}

View File

@ -67,7 +67,7 @@ function societe_prepare_head($object)
if (! empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) if (! empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES))
{ {
$head[$h][0] = DOL_URL_ROOT.'/societe/societecontact.php?socid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/societe/societecontact.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Contact"); $head[$h][1] = $langs->trans("ContactsAddresses");
$head[$h][2] = 'contact'; $head[$h][2] = 'contact';
$h++; $h++;
} }
@ -131,7 +131,7 @@ function societe_prepare_head($object)
$head[$h][0] = DOL_URL_ROOT.'/societe/notify/card.php?socid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/societe/notify/card.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Notifications"); $head[$h][1] = $langs->trans("Notifications");
if($nbNote > 0) $head[$h][1].= ' ('.$nbNote.')'; if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
$head[$h][2] = 'notify'; $head[$h][2] = 'notify';
$h++; $h++;
} }
@ -142,7 +142,7 @@ function societe_prepare_head($object)
if(!empty($object->note_public)) $nbNote++; if(!empty($object->note_public)) $nbNote++;
$head[$h][0] = DOL_URL_ROOT.'/societe/note.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/societe/note.php?id='.$object->id;
$head[$h][1] = $langs->trans("Note"); $head[$h][1] = $langs->trans("Note");
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++;
@ -152,7 +152,7 @@ function societe_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.'/societe/document.php?socid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/societe/document.php?socid='.$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] = 'document'; $head[$h][2] = 'document';
$h++; $h++;
} }
@ -492,7 +492,7 @@ function show_projects($conf,$langs,$db,$object,$backtopage='')
$projectstatic = new Project($db); $projectstatic = new Project($db);
$i=0; $i=0;
$var=true; $var=false;
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
@ -522,7 +522,8 @@ function show_projects($conf,$langs,$db,$object,$backtopage='')
} }
else else
{ {
print '<tr><td colspan="3">'.$langs->trans("None").'</td></tr>'; $var = false;
print '<tr '.$bc[$var].'><td colspan="4">'.$langs->trans("None").'</td></tr>';
} }
$db->free($result); $db->free($result);
} }
@ -680,7 +681,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
$result = $db->query($sql); $result = $db->query($sql);
$num = $db->num_rows($result); $num = $db->num_rows($result);
$var=true; $var=false;
if ($num) if ($num)
{ {
$i=0; $i=0;

View File

@ -60,7 +60,7 @@ function contract_prepare_head($object)
if(!empty($object->note_public)) $nbNote++; if(!empty($object->note_public)) $nbNote++;
$head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$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++;
} }
@ -70,7 +70,7 @@ function contract_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.'/contrat/document.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/contrat/document.php?id='.$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

@ -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

@ -72,7 +72,7 @@ function fichinter_prepare_head($object)
if(!empty($object->note_public)) $nbNote++; if(!empty($object->note_public)) $nbNote++;
$head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$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++;
} }
@ -82,7 +82,7 @@ function fichinter_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.'/fichinter/document.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/fichinter/document.php?id='.$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

@ -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

@ -63,7 +63,7 @@ function facturefourn_prepare_head($object)
if(!empty($object->note_public)) $nbNote++; if(!empty($object->note_public)) $nbNote++;
$head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/fourn/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++;
} }
@ -73,7 +73,7 @@ function facturefourn_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.'/fourn/facture/document.php?facid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/fourn/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++;
@ -135,7 +135,7 @@ function ordersupplier_prepare_head($object)
if(!empty($object->note_public)) $nbNote++; if(!empty($object->note_public)) $nbNote++;
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$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++;
} }
@ -145,7 +145,7 @@ function ordersupplier_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.'/fourn/commande/document.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/document.php?id='.$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

@ -148,6 +148,7 @@ function getBrowserInfo()
$detectmobile=new MobileDetect(); $detectmobile=new MobileDetect();
$phone=$detectmobile->isMobile(); $phone=$detectmobile->isMobile();
$tablet=$detectmobile->isTablet(); $tablet=$detectmobile->isTablet();
unset($detectmobile); // free memory
return array('browsername'=>$name, 'browserversion'=>$version, 'browseros'=>$os, 'browserfirefox'=>$firefox, 'layout'=> ($tablet?'tablet':($phone?'phone':'classic')), 'phone'=>$phone, 'tablet'=>$tablet); return array('browsername'=>$name, 'browserversion'=>$version, 'browseros'=>$os, 'browserfirefox'=>$firefox, 'layout'=> ($tablet?'tablet':($phone?'phone':'classic')), 'phone'=>$phone, 'tablet'=>$tablet);
} }
@ -170,11 +171,11 @@ function dol_shutdown()
* Return value of a param into GET or POST supervariable * Return value of a param into GET or POST supervariable
* *
* @param string $paramname Name of parameter to found * @param string $paramname Name of parameter to found
* @param string $check Type of check (''=no check, 'int'=check it's numeric, 'alpha'=check it's text and sign, 'aZ'=check it's a-z only, 'array'=check it's array, 'san_alpha'= Use filter_var with FILTER_SANITIZE_STRING, 'custom'= custom filter specify $filter and $options) * @param string $check Type of check (''=no check, 'int'=check it's numeric, 'alpha'=check it's text and sign, 'aZ'=check it's a-z only, 'array'=check it's array, 'san_alpha'= Use filter_var with FILTER_SANITIZE_STRING (do not use this for free text string), 'custom'= custom filter specify $filter and $options)
* @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)
{ {
@ -453,6 +454,18 @@ function dol_string_nospecial($str,$newstr='_',$badchars='')
return str_replace($forbidden_chars_to_replace,$newstr,str_replace($forbidden_chars_to_remove,"",$str)); return str_replace($forbidden_chars_to_replace,$newstr,str_replace($forbidden_chars_to_remove,"",$str));
} }
/**
* Encode string for xml usage
*
* @param string $string String to encode
* @return string String encoded
*/
function dolEscapeXML($string)
{
return strtr($string, array('\''=>'&apos;','"'=>'&quot;','&'=>'&amp;','<'=>'&lt;','>'=>'&gt;'));
}
/** /**
* Returns text escaped for inclusion into javascript code * Returns text escaped for inclusion into javascript code
* *
@ -658,7 +671,7 @@ function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $p
{ {
$isactive=(is_numeric($active) && $i == $active) || (! is_numeric($active) && $active == $links[$i][2]); $isactive=(is_numeric($active) && $i == $active) || (! is_numeric($active) && $active == $links[$i][2]);
$out.='<div class="inline-block tabsElem'.((! $isactive && ! empty($conf->global->MAIN_HIDE_INACTIVETAB_ON_PRINT))?' hideonprint':'').'">'; $out.='<div class="inline-block tabsElem'.($isactive ? ' tabsElemActive' : '').((! $isactive && ! empty($conf->global->MAIN_HIDE_INACTIVETAB_ON_PRINT))?' hideonprint':'').'">';
if (isset($links[$i][2]) && $links[$i][2] == 'image') if (isset($links[$i][2]) && $links[$i][2] == 'image')
{ {
if (!empty($links[$i][0])) if (!empty($links[$i][0]))
@ -2628,9 +2641,10 @@ function load_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath
* @param int $totalnboflines Total number of records/lines for all pages (if known) * @param int $totalnboflines Total number of records/lines for all pages (if known)
* @param string $picto Icon to use before title (should be a 32x32 transparent png file) * @param string $picto Icon to use before title (should be a 32x32 transparent png file)
* @param int $pictoisfullpath 1=Icon name is a full absolute url of image * @param int $pictoisfullpath 1=Icon name is a full absolute url of image
* @param string $morehtml More html to show
* @return void * @return void
*/ */
function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=0, $picto='title.png', $pictoisfullpath=0) function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=0, $picto='title.png', $pictoisfullpath=0, $morehtml='')
{ {
global $conf,$langs; global $conf,$langs;
@ -2706,6 +2720,7 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so
} }
} }
print_fleche_navigation($page,$file,$options,$nextpage,$pagelist); print_fleche_navigation($page,$file,$options,$nextpage,$pagelist);
if ($morehtml) print $morehtml;
print '</td>'; print '</td>';
print '</tr></table>'."\n"; print '</tr></table>'."\n";
@ -3715,6 +3730,7 @@ function dol_nl2br($stringtoencode,$nl2brmode=0,$forxml=false)
} }
} }
/** /**
* This function is called to encode a string into a HTML string but differs from htmlentities because * This function is called to encode a string into a HTML string but differs from htmlentities because
* all entities but &,<,> are converted. This permits to encode special chars to entities with no double * all entities but &,<,> are converted. This permits to encode special chars to entities with no double
@ -4543,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

@ -581,9 +581,10 @@ function array2table($data,$tableMarkup=1,$tableoptions='',$troptions='',$tdopti
* @param Societe $objsoc The company that own the object we need a counter for * @param Societe $objsoc The company that own the object we need a counter for
* @param string $date Date to use for the {y},{m},{d} tags. * @param string $date Date to use for the {y},{m},{d} tags.
* @param string $mode 'next' for next value or 'last' for last value * @param string $mode 'next' for next value or 'last' for last value
* @param bool $bentityon activate the entity filterdefault is true (for modules not compatible with multicompany)
* @return string New value (numeric) or error message * @return string New value (numeric) or error message
*/ */
function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$mode='next') function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$mode='next', $bentityon=true)
{ {
global $conf; global $conf;
@ -784,6 +785,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
$sql.= " FROM ".MAIN_DB_PREFIX.$table; $sql.= " FROM ".MAIN_DB_PREFIX.$table;
$sql.= " WHERE ".$field." LIKE '".$maskLike."'"; $sql.= " WHERE ".$field." LIKE '".$maskLike."'";
$sql.= " AND ".$field." NOT LIKE '%PROV%'"; $sql.= " AND ".$field." NOT LIKE '%PROV%'";
if ($bentityon) // only if entity enable
$sql.= " AND entity IN (".getEntity($table, 1).")"; $sql.= " AND entity IN (".getEntity($table, 1).")";
if ($where) $sql.=$where; if ($where) $sql.=$where;
if ($sqlwhere) $sql.=' AND '.$sqlwhere; if ($sqlwhere) $sql.=' AND '.$sqlwhere;
@ -824,6 +826,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
$sql.= " FROM ".MAIN_DB_PREFIX.$table; $sql.= " FROM ".MAIN_DB_PREFIX.$table;
$sql.= " WHERE ".$field." LIKE '".$maskLike."'"; $sql.= " WHERE ".$field." LIKE '".$maskLike."'";
$sql.= " AND ".$field." NOT LIKE '%PROV%'"; $sql.= " AND ".$field." NOT LIKE '%PROV%'";
if ($bentityon) // only if entity enable
$sql.= " AND entity IN (".getEntity($table, 1).")"; $sql.= " AND entity IN (".getEntity($table, 1).")";
if ($where) $sql.=$where; if ($where) $sql.=$where;
if ($sqlwhere) $sql.=' AND '.$sqlwhere; if ($sqlwhere) $sql.=' AND '.$sqlwhere;
@ -877,6 +880,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
$maskrefclient_sql.= " FROM ".MAIN_DB_PREFIX.$table; $maskrefclient_sql.= " FROM ".MAIN_DB_PREFIX.$table;
//$sql.= " WHERE ".$field." not like '(%'"; //$sql.= " WHERE ".$field." not like '(%'";
$maskrefclient_sql.= " WHERE ".$field." LIKE '".$maskrefclient_maskLike."'"; $maskrefclient_sql.= " WHERE ".$field." LIKE '".$maskrefclient_maskLike."'";
if ($bentityon) // only if entity enable
$maskrefclient_sql.= " AND entity IN (".getEntity($table, 1).")"; $maskrefclient_sql.= " AND entity IN (".getEntity($table, 1).")";
if ($where) $maskrefclient_sql.=$where; //use the same optional where as general mask if ($where) $maskrefclient_sql.=$where; //use the same optional where as general mask
if ($sqlwhere) $maskrefclient_sql.=' AND '.$sqlwhere; //use the same sqlwhere as general mask if ($sqlwhere) $maskrefclient_sql.=' AND '.$sqlwhere; //use the same sqlwhere as general mask
@ -1337,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

@ -88,7 +88,7 @@ function member_prepare_head($object)
$head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$object->id;
$head[$h][1] = $langs->trans("Note"); $head[$h][1] = $langs->trans("Note");
$head[$h][2] = 'note'; $head[$h][2] = 'note';
if($nbNote > 0) $head[$h][1].= ' ('.$nbNote.')'; if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$object->id;

View File

@ -89,7 +89,7 @@ function commande_prepare_head($object)
if(!empty($object->note_public)) $nbNote++; if(!empty($object->note_public)) $nbNote++;
$head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$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++;
} }
@ -99,7 +99,7 @@ function commande_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.'/commande/document.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$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

@ -71,7 +71,7 @@ function project_prepare_head($object)
if(!empty($object->note_public)) $nbNote++; if(!empty($object->note_public)) $nbNote++;
$head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$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] = 'notes'; $head[$h][2] = 'notes';
$h++; $h++;
} }
@ -81,7 +81,7 @@ function project_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.'/projet/document.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$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] = 'document'; $head[$h][2] = 'document';
$h++; $h++;
@ -149,7 +149,7 @@ function task_prepare_head($object)
if(!empty($object->note_public)) $nbNote++; if(!empty($object->note_public)) $nbNote++;
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');; $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');;
$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] = 'task_notes'; $head[$h][2] = 'task_notes';
$h++; $h++;
} }

View File

@ -83,7 +83,7 @@ function propal_prepare_head($object)
if(!empty($object->note_public)) $nbNote++; if(!empty($object->note_public)) $nbNote++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?id='.$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++;
} }
@ -93,7 +93,7 @@ function propal_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.'/comm/propal/document.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?id='.$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] = 'document'; $head[$h][2] = 'document';
$h++; $h++;

View File

@ -70,11 +70,11 @@ function dol_decode($chain)
/** /**
* Returns a hash of a string. * Returns a hash of a string.
* If constant MAIN_SECURITY_HASH_ALGO is defined, we use this function as hashing function (md5 by default) * If constant MAIN_SECURITY_HASH_ALGO is defined, we use this function as hashing function.
* If constant MAIN_SECURITY_SALT is defined, we use it as a salt * If constant MAIN_SECURITY_SALT is defined, we use it as a salt.
* *
* @param string $chain String to hash * @param string $chain String to hash
* @param int $type Type of hash (0:auto, 1:sha1, 2:sha1+md5) * @param int $type Type of hash (0:auto, 1:sha1, 2:sha1+md5, 3:md5)
* @return string Hash of string * @return string Hash of string
*/ */
function dol_hash($chain,$type=0) function dol_hash($chain,$type=0)
@ -86,9 +86,12 @@ function dol_hash($chain,$type=0)
if ($type == 1) return sha1($chain); if ($type == 1) return sha1($chain);
else if ($type == 2) return sha1(md5($chain)); else if ($type == 2) return sha1(md5($chain));
else if ($type == 3) return md5($chain);
else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1') return sha1($chain); else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1') return sha1($chain);
else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1md5') return sha1(md5($chain)); else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1md5') return sha1(md5($chain));
else return md5($chain);
// No enconding defined
return md5($chain);
} }

View File

@ -440,7 +440,7 @@ function encodedecode_dbpassconf($level=0)
/** /**
* Return a generated password using default module * Return a generated password using default module
* *
* @param boolean $generic true=Create generic password (a MD5 string), false=Use the configured password generation module * @param boolean $generic true=Create generic password (use default crypt function), false=Use the configured password generation module
* @return string New value for password * @return string New value for password
*/ */
function getRandomPassword($generic=false) function getRandomPassword($generic=false)

View File

@ -101,7 +101,7 @@ function user_prepare_head($object)
if(!empty($object->note)) $nbNote++; if(!empty($object->note)) $nbNote++;
$head[$h][0] = DOL_URL_ROOT.'/user/note.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/user/note.php?id='.$object->id;
$head[$h][1] = $langs->trans("Note"); $head[$h][1] = $langs->trans("Note");
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++;
@ -111,7 +111,7 @@ function user_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.'/user/document.php?userid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/user/document.php?userid='.$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] = 'document'; $head[$h][2] = 'document';
$h++; $h++;

View File

@ -334,7 +334,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
$array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_objet=$this->get_substitutionarray_object($object,$outputlangs);
$array_other=$this->get_substitutionarray_other($user,$outputlangs); $array_other=$this->get_substitutionarray_other($outputlangs);
$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other); $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other);
complete_substitutions_array($tmparray, $outputlangs, $object); complete_substitutions_array($tmparray, $outputlangs, $object);

View File

@ -343,7 +343,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures
$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
$array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_objet=$this->get_substitutionarray_object($object,$outputlangs);
$array_propal=is_object($propal_object)?$this->get_substitutionarray_object($propal_object,$outputlangs,'propal'):array(); $array_propal=is_object($propal_object)?$this->get_substitutionarray_object($propal_object,$outputlangs,'propal'):array();
$array_other=$this->get_substitutionarray_other($user,$outputlangs); $array_other=$this->get_substitutionarray_other($outputlangs);
$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_propal,$array_other); $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_propal,$array_other);
complete_substitutions_array($tmparray, $outputlangs, $object); complete_substitutions_array($tmparray, $outputlangs, $object);

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

@ -504,7 +504,7 @@ class doc_generic_project_odt extends ModelePDFProjects
$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
$array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_objet=$this->get_substitutionarray_object($object,$outputlangs);
$array_other=$this->get_substitutionarray_other($user,$outputlangs); $array_other=$this->get_substitutionarray_other($outputlangs);
$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other); $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other);
complete_substitutions_array($tmparray, $outputlangs, $object); complete_substitutions_array($tmparray, $outputlangs, $object);

View File

@ -490,7 +490,7 @@ class doc_generic_task_odt extends ModelePDFTask
$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
$array_objet=$this->get_substitutionarray_object($project,$outputlangs); $array_objet=$this->get_substitutionarray_object($project,$outputlangs);
$array_other=$this->get_substitutionarray_other($user,$outputlangs); $array_other=$this->get_substitutionarray_other($outputlangs);
$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other); $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other);
complete_substitutions_array($tmparray, $outputlangs, $object); complete_substitutions_array($tmparray, $outputlangs, $object);

View File

@ -368,7 +368,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
$array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_objet=$this->get_substitutionarray_object($object,$outputlangs);
$array_other=$this->get_substitutionarray_other($user,$outputlangs); $array_other=$this->get_substitutionarray_other($outputlangs);
$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other); $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other);
complete_substitutions_array($tmparray, $outputlangs, $object); complete_substitutions_array($tmparray, $outputlangs, $object);

View File

@ -101,6 +101,8 @@
<tr><td><?php echo $langs->trans("Unique"); ?></td><td class="valeur"><input id="unique" type="checkbox" name="unique" <?php echo (GETPOST('unique')?' checked="true"':''); ?>></td></tr> <tr><td><?php echo $langs->trans("Unique"); ?></td><td class="valeur"><input id="unique" type="checkbox" name="unique" <?php echo (GETPOST('unique')?' checked="true"':''); ?>></td></tr>
<!-- Required --> <!-- Required -->
<tr><td><?php echo $langs->trans("Required"); ?></td><td class="valeur"><input id="required" type="checkbox" name="required" <?php echo (GETPOST('required')?' checked="true"':''); ?>></td></tr> <tr><td><?php echo $langs->trans("Required"); ?></td><td class="valeur"><input id="required" type="checkbox" name="required" <?php echo (GETPOST('required')?' checked="true"':''); ?>></td></tr>
<!-- Always editable -->
<tr><td><?php echo $langs->trans("AlwaysEditable"); ?></td><td class="valeur"><input id="alwayseditable" type="checkbox" name="alwayseditable" <?php echo (GETPOST('alwayseditable')?' checked="true"':''); ?>></td></tr>
</table> </table>
<div align="center"><br><input type="submit" name="button" class="button" value="<?php echo $langs->trans("Save"); ?>"> &nbsp; <div align="center"><br><input type="submit" name="button" class="button" value="<?php echo $langs->trans("Save"); ?>"> &nbsp;

View File

@ -54,6 +54,7 @@ $size=$extrafields->attribute_size[$attrname];
$unique=$extrafields->attribute_unique[$attrname]; $unique=$extrafields->attribute_unique[$attrname];
$required=$extrafields->attribute_required[$attrname]; $required=$extrafields->attribute_required[$attrname];
$pos=$extrafields->attribute_pos[$attrname]; $pos=$extrafields->attribute_pos[$attrname];
$alwayseditable=$extrafields->attribute_alwayseditable[$attrname];
$param=$extrafields->attribute_param[$attrname]; $param=$extrafields->attribute_param[$attrname];
if((($type == 'select') || ($type == 'checkbox') ||(($type == 'radio'))) && is_array($param)) if((($type == 'select') || ($type == 'checkbox') ||(($type == 'radio'))) && is_array($param))
@ -110,6 +111,8 @@ if(($type == 'select') || ($type == 'sellist') || ($type == 'checkbox') ||(($typ
<tr><td><?php echo $langs->trans("Unique"); ?></td><td class="valeur"><input id="unique" type="checkbox" name="unique" <?php echo ($unique?' checked="true"':''); ?>></td></tr> <tr><td><?php echo $langs->trans("Unique"); ?></td><td class="valeur"><input id="unique" type="checkbox" name="unique" <?php echo ($unique?' checked="true"':''); ?>></td></tr>
<!-- Required --> <!-- Required -->
<tr><td><?php echo $langs->trans("Required"); ?></td><td class="valeur"><input id="required" type="checkbox" name="required" <?php echo ($required?' checked="true"':''); ?>></td></tr> <tr><td><?php echo $langs->trans("Required"); ?></td><td class="valeur"><input id="required" type="checkbox" name="required" <?php echo ($required?' checked="true"':''); ?>></td></tr>
<!-- Always editable -->
<tr><td><?php echo $langs->trans("AlwaysEditable"); ?></td><td class="valeur"><input id="alwayseditable" type="checkbox" name="alwayseditable" <?php echo ($alwayseditable?' checked="true"':''); ?>></td></tr>
</table> </table>

Some files were not shown because too many files have changed in this diff Show More