Merge remote branch 'upstream/develop' into fccard

Conflicts:
	htdocs/commande/card.php
This commit is contained in:
frederic34 2015-11-11 17:23:37 +01:00
commit cd738ef483
125 changed files with 1991 additions and 1481 deletions

View File

@ -133,12 +133,19 @@ Voici un liste de fonctionnalites pas encore gérées par Dolibarr:
- Dolibarr ne fait pas le café (pas encore). - Dolibarr ne fait pas le café (pas encore).
## RESEAUX SOCIAUX ## ACTUALITES ET RESEAUX SOCIAUX
Suivez le projet Dolibarr project sur Suivez le projet Dolibarr project sur les réseaux francophones
Facebook: <https://www.facebook.com/dolibarr.fr> - Facebook: <https://www.facebook.com/dolibarr.fr>
- Google+: <https://plus.google.com/+DolibarrFrance>
- Twitter: <http://www.twitter.com/dolibarr_france>
Google+: <https://plus.google.com/+DolibarrFrance> ou sur les réseaux anglophones
Twitter: <http://www.twitter.com/dolibarr_france> - [Facebook](https://www.facebook.com/dolibarr)
- [Google+](https://plus.google.com/+DolibarrOrg)
- [Twitter](http://www.twitter.com/dolibarr)
- [LinkedIn](https://www.linkedin.com/company/association-dolibarr)
- [YouTube](https://www.youtube.com/user/DolibarrERPCRM)
- [GitHub](https://github.com/Dolibarr/dolibarr)

View File

@ -1,6 +1,6 @@
# DOLIBARR ERP & CRM # DOLIBARR ERP & CRM
![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/develop.svg) ![Downloads per day](https://img.shields.io/sourceforge/dd/dolibarr.svg) ![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/develop.svg) ![Downloads per day](https://img.shields.io/sourceforge/dm/dolibarr.svg)
Dolibarr ERP & CRM is a modern software to manage your organization's activity (contacts, suppliers, invoices, orders, stocks, agenda, ...). Dolibarr ERP & CRM is a modern software to manage your organization's activity (contacts, suppliers, invoices, orders, stocks, agenda, ...).
@ -16,9 +16,9 @@ You can use it as a standalone application or as a web application to be able to
Dolibarr is released 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 (GPL-3+). Dolibarr is released 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 (GPL-3+).
See the [COPYING](COPYING) file for a full copy of the license. See the [COPYING](https://github.com/Dolibarr/dolibarr/blob/develop/COPYING) file for a full copy of the license.
Other licenses apply for some included dependencies. See [COPYRIGHT](COPYRIGHT) for a full list. Other licenses apply for some included dependencies. See [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) for a full list.
## INSTALLING ## INSTALLING
@ -65,9 +65,9 @@ You can use a Web server and a supported database (MySQL recommended) to install
*Note: migration process can safely be done multiple times.* *Note: migration process can safely be done multiple times.*
## NEWS ## WHAT'S NEW
See the [ChangeLog](ChangeLog) file. See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) file.
## FEATURES ## FEATURES
@ -153,9 +153,9 @@ Administrator, user, developer and translator's documentations are available alo
Dolibarr is the work of many contributors over the years and uses some fine libraries. Dolibarr is the work of many contributors over the years and uses some fine libraries.
See [COPYRIGHT](COPYRIGHT) file. See [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) file.
## SOCIAL NETWORKS ## NEWS AND SOCIAL NETWORKS
Follow Dolibarr project on: Follow Dolibarr project on:

View File

@ -239,7 +239,7 @@ http://packages.qa.debian.org/t/tcpdf.html
##### Create/Maintain dolibarr package ##### Create/Maintain dolibarr package
To update dolibarr debian package when upstream version has changed To update dolibarr debian package when upstream (official version of external project) has changed:
* You can git clone debian git repo * You can git clone debian git repo
> git clone git.debian.org:/git/collab-maint/dolibarr.git [dolibarr-debian] > git clone git.debian.org:/git/collab-maint/dolibarr.git [dolibarr-debian]
@ -284,10 +284,10 @@ Then check/modify also the user/date signature:
- Name and email must match value into debian/control file (Entry added here is used by next step). - Name and email must match value into debian/control file (Entry added here is used by next step).
To update dolibarr debian package when only files into debian has changed To update dolibarr debian package when only files into debian has changed, or if you include manually backport:
* Change files and commit. * Change files and commit.
* Add a tag debian/x.y.z+dfsgw-2 (increase the last 1 into 2) * Add a tag debian/x.y.z+dfsgw-2 (increase the last 1 into 2, 3...)
Once files has been prepared, it's time to test: Once files has been prepared, it's time to test:

66
composer.lock generated
View File

@ -4,7 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "f441e6348ae7862942693cab10810418", "hash": "d88b5c84a9ea1af354d867ba2e2ab251",
"content-hash": "85e60ec7f8ab593387c7bd10d8db860d",
"packages": [ "packages": [
{ {
"name": "ccampbell/chromephp", "name": "ccampbell/chromephp",
@ -126,6 +127,64 @@
"homepage": "https://github.com/firephp/firephp-core", "homepage": "https://github.com/firephp/firephp-core",
"time": "2013-04-23 15:28:20" "time": "2013-04-23 15:28:20"
}, },
{
"name": "mike42/escpos-php",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/mike42/escpos-php.git",
"reference": "0564ff94de45564221eca99c4cd5ab24492894c2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mike42/escpos-php/zipball/0564ff94de45564221eca99c4cd5ab24492894c2",
"reference": "0564ff94de45564221eca99c4cd5ab24492894c2",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "4.5.*"
},
"type": "library",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Roni Saha",
"email": "roni.cse@gmail.com"
},
{
"name": "Michael Billington",
"email": "michael.billington@gmail.com"
},
{
"name": "Gergely Radics",
"email": "gerifield@ustream.tv"
},
{
"name": "Warren Doyle",
"email": "w.doyle@fuelled.co"
},
{
"name": "vharo",
"email": "vharo@geepok.com"
}
],
"description": "Thermal receipt printer library, for use with ESC/POS compatible printers",
"homepage": "https://github.com/mike42/escpos-php",
"keywords": [
"ESC-POS",
"driver",
"escpos",
"print",
"receipt"
],
"time": "2015-11-02 10:50:46"
},
{ {
"name": "mobiledetect/mobiledetectlib", "name": "mobiledetect/mobiledetectlib",
"version": "2.8.3", "version": "2.8.3",
@ -424,13 +483,16 @@
"pdf417", "pdf417",
"qrcode" "qrcode"
], ],
"abandoned": "tecnickcom/tcpdf",
"time": "2015-01-28 18:51:40" "time": "2015-01-28 18:51:40"
} }
], ],
"packages-dev": [], "packages-dev": [],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": [], "stability-flags": {
"mike42/escpos-php": 20
},
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {

View File

@ -19,8 +19,8 @@
*/ */
/** /**
* \file dev/intdata/generate-facture.php * \file dev/intdata/generate-invoice.php
* \brief Script de generation de donnees aleatoires pour les factures * \brief Script example to inject random customer invoices (for load tests)
*/ */
// Test si mode batch // Test si mode batch

View File

@ -20,8 +20,8 @@
*/ */
/** /**
* \file dev/initdata/generate-commande.php * \file dev/initdata/generate-order.php
* \brief Script de generation de donnees aleatoires pour les commandes * \brief Script example to inject random orders (for load tests)
*/ */
// Test si mode batch // Test si mode batch

View File

@ -20,8 +20,8 @@
*/ */
/** /**
* \file dev/initdata/generate-produit.php * \file dev/initdata/generate-product.php
* \brief Script de generation de donnees aleatoires pour les produits * \brief Script example to inject random products (for load tests)
*/ */
// Test si mode batch // Test si mode batch

View File

@ -20,8 +20,8 @@
*/ */
/** /**
* \file dev/initdata/generate-propale.php * \file dev/initdata/generate-proposal.php
* \brief Script de generation de donnees aleatoires pour les propales * \brief Script example to inject random proposals (for load tests)
*/ */
// Test si mode batch // Test si mode batch

View File

@ -20,8 +20,8 @@
*/ */
/** /**
* \file dev/initdata/generate-societe.php * \file dev/initdata/generate-thirdparty.php
* \brief Script de generation de donnees aleatoires pour les societes * \brief Script example to inject random thirdparties (for load tests)
*/ */
// Test si mode batch // Test si mode batch

View File

@ -15,6 +15,8 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/ * or see http://www.gnu.org/
*
* Get a distant dump file and load it into a mysql database
*/ */
$sapi_type = php_sapi_name(); $sapi_type = php_sapi_name();
@ -32,9 +34,10 @@ $error=0;
$sourceserver=isset($argv[1])?$argv[1]:''; // user@server:/src/file $sourceserver=isset($argv[1])?$argv[1]:''; // user@server:/src/file
$password=isset($argv[2])?$argv[2]:''; $password=isset($argv[2])?$argv[2]:'';
$database=isset($argv[3])?$argv[3]:''; $dataserver=isset($argv[3])?$argv[3]:'';
$loginbase=isset($argv[4])?$argv[4]:''; $database=isset($argv[4])?$argv[4]:'';
$passwordbase=isset($argv[5])?$argv[5]:''; $loginbase=isset($argv[5])?$argv[5]:'';
$passwordbase=isset($argv[6])?$argv[6]:'';
// Include Dolibarr environment // Include Dolibarr environment
$res=0; $res=0;
@ -64,7 +67,7 @@ if (preg_match('/^(.*)@(.*):(.*)$/',$sourceserver,$reg))
} }
if (empty($sourceserver) || empty($server) || empty($login) || empty($sourcefile) || empty($password) || empty($database) || empty($loginbase) || empty($passwordbase)) if (empty($sourceserver) || empty($server) || empty($login) || empty($sourcefile) || empty($password) || empty($database) || empty($loginbase) || empty($passwordbase))
{ {
print "Usage: $script_file login@server:/src/file.(sql|gz|bz2) passssh database loginbase passbase\n"; print "Usage: $script_file login@server:/src/file.(sql|gz|bz2) passssh databaseserver databasename loginbase passbase\n";
print "Return code: 0 if success, <>0 if error\n"; print "Return code: 0 if success, <>0 if error\n";
print "Warning, this script may take a long time.\n"; print "Warning, this script may take a long time.\n";
exit(-1); exit(-1);
@ -108,14 +111,14 @@ if ($connection)
print 'Get file '.$sourcefile.' into '.$targetdir.$targetfile."\n"; print 'Get file '.$sourcefile.' into '.$targetdir.$targetfile."\n";
ssh2_scp_recv($connection, $sourcefile, $targetdir.$targetfile); ssh2_scp_recv($connection, $sourcefile, $targetdir.$targetfile);
$fullcommand="cat ".$targetdir.$targetfile." | mysql -u".$loginbase." -p".$passwordbase." -D ".$database; $fullcommand="cat ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database;
if (preg_match('/\.bz2$/',$targetfile)) if (preg_match('/\.bz2$/',$targetfile))
{ {
$fullcommand="bzip2 -c -d ".$targetdir.$targetfile." | mysql -u".$loginbase." -p".$passwordbase." -D ".$database; $fullcommand="bzip2 -c -d ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database;
} }
if (preg_match('/\.gz$/',$targetfile)) if (preg_match('/\.gz$/',$targetfile))
{ {
$fullcommand="gzip -d ".$targetdir.$targetfile." | mysql -u".$loginbase." -p".$passwordbase." -D ".$database; $fullcommand="gzip -d ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database;
} }
print "Load dump with ".$fullcommand."\n"; print "Load dump with ".$fullcommand."\n";
$output=array(); $output=array();

View File

@ -619,17 +619,28 @@ foreach ($skeletonfiles as $skeletonfile => $outfile)
$targetcontent=preg_replace('/'.preg_quote("if (! empty(\$arrayfields['t.field1']['checked'])) print '<td>'.\$obj->field1.'</td>';",'/').'/', $varprop, $targetcontent); $targetcontent=preg_replace('/'.preg_quote("if (! empty(\$arrayfields['t.field1']['checked'])) print '<td>'.\$obj->field1.'</td>';",'/').'/', $varprop, $targetcontent);
$targetcontent=preg_replace('/'.preg_quote("if (! empty(\$arrayfields['t.field2']['checked'])) print '<td>'.\$obj->field2.'</td>';",'/').'/', '', $targetcontent); $targetcontent=preg_replace('/'.preg_quote("if (! empty(\$arrayfields['t.field2']['checked'])) print '<td>'.\$obj->field2.'</td>';",'/').'/', '', $targetcontent);
// LIST_OF_TD_LABEL_FIELDS_CREATE and EDIT - List of td for card view // LIST_OF_TD_LABEL_FIELDS_CREATE - List of td for card view
$varprop="\n"; $varprop="\n";
$cleanparam=''; $cleanparam='';
foreach($property as $key => $prop) foreach($property as $key => $prop)
{ {
if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime']) if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime'])
{ {
$varprop.="print '<tr><td class=\"fieldrequired\">'.\$langs->trans(\"Field".$prop['field']."\").'</td><td><input class=\"flat\" type=\"text\" name=\"".$prop['field']."\" value=\"'.\$".$prop['field'].".'\"></td></tr>';\n"; $varprop.="print '<tr><td class=\"fieldrequired\">'.\$langs->trans(\"Field".$prop['field']."\").'</td><td><input class=\"flat\" type=\"text\" name=\"".$prop['field']."\" value=\"'.GETPOST('".$prop['field']."').'\"></td></tr>';\n";
} }
} }
$targetcontent=preg_replace('/LIST_OF_TD_LABEL_FIELDS_CREATE/', $varprop, $targetcontent); $targetcontent=preg_replace('/LIST_OF_TD_LABEL_FIELDS_CREATE/', $varprop, $targetcontent);
// LIST_OF_TD_LABEL_FIELDS_EDIT - List of td for card view
$varprop="\n";
$cleanparam='';
foreach($property as $key => $prop)
{
if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime'])
{
$varprop.="print '<tr><td class=\"fieldrequired\">'.\$langs->trans(\"Field".$prop['field']."\").'</td><td><input class=\"flat\" type=\"text\" name=\"".$prop['field']."\" value=\"'.\$object->".$prop['field'].".'\"></td></tr>';\n";
}
}
$targetcontent=preg_replace('/LIST_OF_TD_LABEL_FIELDS_EDIT/', $varprop, $targetcontent); $targetcontent=preg_replace('/LIST_OF_TD_LABEL_FIELDS_EDIT/', $varprop, $targetcontent);
// LIST_OF_TD_LABEL_FIELDS_VIEW - List of td for card view // LIST_OF_TD_LABEL_FIELDS_VIEW - List of td for card view

View File

@ -281,12 +281,17 @@ if (($id || $ref) && $action == 'edit')
// Part to show record // Part to show record
if ($id && (empty($action) || $action == 'view')) if ($id && (empty($action) || $action == 'view' || $action == 'delete'))
{ {
print load_fiche_titre($langs->trans("MyModule")); print load_fiche_titre($langs->trans("MyModule"));
dol_fiche_head(); dol_fiche_head();
if ($action == 'delete') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMyOjbect'), $langs->trans('ConfirmDeleteMyObject'), 'confirm_delete', '', 0, 1);
print $formconfirm;
}
print '<table class="border centpercent">'."\n"; print '<table class="border centpercent">'."\n";
// print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input class="flat" type="text" size="36" name="label" value="'.$label.'"></td></tr>'; // print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input class="flat" type="text" size="36" name="label" value="'.$label.'"></td></tr>';
// LIST_OF_TD_LABEL_FIELDS_VIEW // LIST_OF_TD_LABEL_FIELDS_VIEW
@ -309,17 +314,10 @@ if ($id && (empty($action) || $action == 'view'))
} }
if ($user->rights->mymodule->delete) if ($user->rights->mymodule->delete)
{
if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) // We can't use preloaded confirm form with jmobile
{
print '<div class="inline-block divButAction"><span id="action-delete" class="butActionDelete">'.$langs->trans('Delete').'</span></div>'."\n";
}
else
{ {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a></div>'."\n"; print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a></div>'."\n";
} }
} }
}
print '</div>'."\n"; print '</div>'."\n";

View File

@ -96,6 +96,23 @@ if (($id > 0 || ! empty($ref)) && $action != 'add')
if ($result < 0) dol_print_error($db); if ($result < 0) dol_print_error($db);
} }
// Definition of fields for list
$arrayfields=array(
't.field1'=>array('label'=>$langs->trans("Field1"), 'checked'=>1),
't.field2'=>array('label'=>$langs->trans("Field2"), 'checked'=>1),
//'t.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))),
't.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
't.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
//'t.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
}
}
@ -267,22 +284,6 @@ if ($resql)
print '</div>'; print '</div>';
} }
$arrayfields=array(
't.field1'=>array('label'=>$langs->trans("Field1"), 'checked'=>1),
't.field2'=>array('label'=>$langs->trans("Field2"), 'checked'=>1),
//'t.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))),
't.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
't.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
//'t.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
}
}
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields

View File

@ -162,7 +162,7 @@ foreach($dirbarcode as $reldir)
{ {
$filebis=$reg[1]; $filebis=$reg[1];
// Chargement de la classe de codage // Loading encoding class
require_once $newdir.$file; require_once $newdir.$file;
$classname = "mod".ucfirst($filebis); $classname = "mod".ucfirst($filebis);
$module = new $classname($db); $module = new $classname($db);

View File

@ -510,7 +510,7 @@ if ($id == 10)
} }
// Actions ajout ou modification d'une entree dans un dictionnaire de donnee // Actions add or modify an entry into a dictionary
if (GETPOST('actionadd') || GETPOST('actionmodify')) if (GETPOST('actionadd') || GETPOST('actionmodify'))
{ {
$listfield=explode(',',$tabfield[$id]); $listfield=explode(',',$tabfield[$id]);
@ -581,6 +581,11 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->transnoentities("Country")), null, 'errors'); setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->transnoentities("Country")), null, 'errors');
} }
} }
if ($id == 3 && ! is_numeric($_POST["code"]))
{
$ok=0;
setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric",$langs->transnoentities("Code")), null, 'errors');
}
// Clean some parameters // Clean some parameters
if (isset($_POST["localtax1"]) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0 if (isset($_POST["localtax1"]) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0

View File

@ -344,7 +344,7 @@ foreach ($dirmodels as $reldir)
$classname = preg_replace('/\-.*$/','',$classname); $classname = preg_replace('/\-.*$/','',$classname);
if (! class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/',$filebis) || preg_match('/mod_/',$classname)) && substr($filebis, dol_strlen($filebis)-3, 3) == 'php') if (! class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/',$filebis) || preg_match('/mod_/',$classname)) && substr($filebis, dol_strlen($filebis)-3, 3) == 'php')
{ {
// Chargement de la classe de numerotation // Charging the numbering class
require_once $dir.$filebis; require_once $dir.$filebis;
$module = new $classname($db); $module = new $classname($db);

View File

@ -27,6 +27,13 @@ require '../main.inc.php';
// required Class // required Class
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// 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
$langs->load("admin"); $langs->load("admin");
$langs->load("oauth"); $langs->load("oauth");
@ -36,6 +43,8 @@ if (!$user->admin)
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
// Supported OAUTH
$supportedoauth2array=array('OAUTH_GOOGLE_NAME');
// API access parameters OAUTH // API access parameters OAUTH
$list = array ( $list = array (
array( array(
@ -297,11 +306,7 @@ print '<input type="hidden" name="action" value="update">';
dol_fiche_head(array(), '', '', 0, 'technic'); dol_fiche_head(array(), '', '', 0, 'technic');
// Define $urlwithroot print $langs->trans("ListOfSupportedOauthProviders").'<br><br>';
$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
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
@ -309,12 +314,16 @@ $var = true;
foreach ($list as $key) foreach ($list as $key)
{ {
$supported=0;
if (in_array($key[0], $supportedoauth2array)) $supported=1;
if (! $supported) continue; // show only supported
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
// Api Name // Api Name
$label = $langs->trans($key[0]); $label = $langs->trans($key[0]);
print '<td colspan="2">'.$label.'</td></tr>'; print '<td colspan="2">'.$label.'</td></tr>';
if (in_array($key[0], array('OAUTH_GOOGLE_NAME'))) if ($supported)
{ {
$redirect_uri=$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php'; $redirect_uri=$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php';
$var = !$var; $var = !$var;

View File

@ -130,7 +130,7 @@ foreach ($dirmodels as $reldir)
$classname = preg_replace('/\-.*$/','',$classname); $classname = preg_replace('/\-.*$/','',$classname);
if (! class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/',$filebis) || preg_match('/mod_/',$classname)) && substr($filebis, dol_strlen($filebis)-3, 3) == 'php') if (! class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/',$filebis) || preg_match('/mod_/',$classname)) && substr($filebis, dol_strlen($filebis)-3, 3) == 'php')
{ {
// Chargement de la classe de numerotation // Charging the numbering class
require_once $dir.$filebis; require_once $dir.$filebis;
$module = new $classname($db); $module = new $classname($db);

View File

@ -221,7 +221,7 @@ if (is_resource($handle))
{ {
if (preg_match('/(modGeneratePass[a-z]+)\.class\.php/i',$file,$reg)) if (preg_match('/(modGeneratePass[a-z]+)\.class\.php/i',$file,$reg))
{ {
// Chargement de la classe de numerotation // Charging the numbering class
$classname = $reg[1]; $classname = $reg[1];
require_once $dir.'/'.$file; require_once $dir.'/'.$file;

View File

@ -101,12 +101,12 @@ if ($action == 'update' && $user->rights->categorie->creer)
} }
else else
{ {
setEventMessage($categorie->error, 'errors'); setEventMessages($categorie->error, $categorie->errors, 'errors');
} }
} }
else else
{ {
setEventMessage($categorie->error, 'errors'); setEventMessages($categorie->error, $categorie->errors, 'errors');
} }
} }

View File

@ -95,7 +95,7 @@ $cancel != $langs->trans("Cancel") &&
else else
{ {
$action = 'add'; $action = 'add';
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
@ -128,7 +128,7 @@ $cancel != $langs->trans("Cancel") &&
else else
{ {
$action = 'edit'; $action = 'edit';
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }

View File

@ -122,7 +122,7 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
@ -137,13 +137,13 @@ if ($type == Categorie::TYPE_PRODUCT && $elemid && $action == 'addintocategory'
$result=$object->add_type($newobject,$elementtype); $result=$object->add_type($newobject,$elementtype);
if ($result >= 0) if ($result >= 0)
{ {
setEventMessage($langs->trans("WasAddedSuccessfully",$newobject->ref)); setEventMessages($langs->trans("WasAddedSuccessfully",$newobject->ref), null, 'mesgs');
} }
else else
{ {
if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{ {
setEventMessage($langs->trans("ObjectAlreadyLinkedToCategory"),'warnings'); setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings');
} }
else else
{ {

View File

@ -62,7 +62,7 @@ if ($action == 'builddoc')
$result=$cat->write_file(GETPOST('id','int')); $result=$cat->write_file(GETPOST('id','int'));
if ($result < 0) if ($result < 0)
{ {
setEventMessage($cat->error, 'errors'); setEventMessages($cat->error, $cat->errors, 'errors');
} }
} }

View File

@ -106,7 +106,7 @@ if ($action == 'add' || $action == 'update')
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action='create'; $action='create';
} }
} }
@ -147,7 +147,7 @@ if ($action == 'add' || $action == 'update')
else else
{ {
$reload = 0; $reload = 0;
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action= "edit"; $action= "edit";
} }
} }

View File

@ -105,7 +105,7 @@ if (empty($reshook))
$result=$object->fetch($id); $result=$object->fetch($id);
$object->code_compta=$_POST["customeraccountancycode"]; $object->code_compta=$_POST["customeraccountancycode"];
$result=$object->update($object->id,$user,1,1,0); $result=$object->update($object->id,$user,1,1,0);
if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
} }
// conditions de reglement // conditions de reglement
@ -113,7 +113,7 @@ if (empty($reshook))
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int')); $result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
} }
// mode de reglement // mode de reglement
@ -121,7 +121,7 @@ if (empty($reshook))
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->setPaymentMethods(GETPOST('mode_reglement_id','int')); $result=$object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
} }
// assujetissement a la TVA // assujetissement a la TVA
@ -130,7 +130,7 @@ if (empty($reshook))
$object->fetch($id); $object->fetch($id);
$object->tva_assuj=$_POST['assujtva_value']; $object->tva_assuj=$_POST['assujtva_value'];
$result=$object->update($object->id); $result=$object->update($object->id);
if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
} }
// set prospect level // set prospect level
@ -139,7 +139,7 @@ if (empty($reshook))
$object->fetch($id); $object->fetch($id);
$object->fk_prospectlevel=GETPOST('prospect_level_id','alpha'); $object->fk_prospectlevel=GETPOST('prospect_level_id','alpha');
$result=$object->set_prospect_level($user); $result=$object->set_prospect_level($user);
if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
} }
// set communication status // set communication status
@ -148,7 +148,7 @@ if (empty($reshook))
$object->fetch($id); $object->fetch($id);
$object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm','alpha'), 'c_stcomm'); $object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm','alpha'), 'c_stcomm');
$result=$object->set_commnucation_level($user); $result=$object->set_commnucation_level($user);
if ($result < 0) setEventMessages($object->error,$object->errors,'errors'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
} }
// update outstandng limit // update outstandng limit
@ -157,7 +157,7 @@ if (empty($reshook))
$object->fetch($id); $object->fetch($id);
$object->outstanding_limit=GETPOST('outstanding_limit'); $object->outstanding_limit=GETPOST('outstanding_limit');
$result=$object->set_OutstandingBill($user); $result=$object->set_OutstandingBill($user);
if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
} }
} }

View File

@ -117,7 +117,7 @@ if (empty($reshook))
{ {
if (empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) if (empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"]))
{ {
setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
} }
else else
{ {
@ -129,7 +129,7 @@ if (empty($reshook))
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
$action=''; $action='';
@ -141,14 +141,14 @@ if (empty($reshook))
if (empty($conf->global->MAILING_LIMIT_SENDBYWEB)) if (empty($conf->global->MAILING_LIMIT_SENDBYWEB))
{ {
// As security measure, we don't allow send from the GUI // As security measure, we don't allow send from the GUI
setEventMessage($langs->trans("MailingNeedCommand"), 'warnings'); setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings');
setEventMessage('<textarea cols="70" rows="'.ROWS_2.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.'</textarea>', 'warnings'); setEventMessages('<textarea cols="70" rows="'.ROWS_2.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.'</textarea>', null, 'warnings');
setEventMessage($langs->trans("MailingNeedCommand2"), 'warnings'); setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings');
$action=''; $action='';
} }
else if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) else if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0)
{ {
setEventMessage($langs->trans("NotEnoughPermissions"), 'warnings'); setEventMessages($langs->trans("NotEnoughPermissions"), null, 'warnings');
$action=''; $action='';
} }
else else
@ -351,27 +351,27 @@ if (empty($reshook))
} }
else else
{ {
setEventMessage($langs->transnoentitiesnoconv("NoMoreRecipientToSendTo")); setEventMessages($langs->transnoentitiesnoconv("NoMoreRecipientToSendTo"), null, 'mesgs');
} }
// Loop finished, set global statut of mail // Loop finished, set global statut of mail
if ($nbko > 0) if ($nbko > 0)
{ {
$statut=2; // Status 'sent partially' (because at least one error) $statut=2; // Status 'sent partially' (because at least one error)
if ($nbok > 0) setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); if ($nbok > 0) setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs');
else setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); else setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs');
} }
else else
{ {
if ($nbok >= $num) if ($nbok >= $num)
{ {
$statut=3; // Send to everybody $statut=3; // Send to everybody
setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs');
} }
else else
{ {
$statut=2; // Status 'sent partially' (because not send to everybody) $statut=2; // Status 'sent partially' (because not send to everybody)
setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs');
} }
} }
@ -443,11 +443,11 @@ if (empty($reshook))
$result=$mailfile->sendfile(); $result=$mailfile->sendfile();
if ($result) if ($result)
{ {
setEventMessage($langs->trans("MailSuccessfulySent",$mailfile->getValidAddress($object->email_from,2),$mailfile->getValidAddress($object->sendto,2))); setEventMessages($langs->trans("MailSuccessfulySent",$mailfile->getValidAddress($object->email_from,2),$mailfile->getValidAddress($object->sendto,2)), null, 'mesgs');
} }
else else
{ {
setEventMessage($langs->trans("ResultKo").'<br>'.$mailfile->error.' '.$result, 'errors'); setEventMessages($langs->trans("ResultKo").'<br>'.$mailfile->error.' '.$result, null, 'errors');
} }
$action=''; $action='';
@ -488,7 +488,7 @@ if (empty($reshook))
$mesgs[] = $object->error; $mesgs[] = $object->error;
} }
setEventMessage($mesgs, 'errors'); setEventMessages($mesg, $mesgs, 'errors');
$action="create"; $action="create";
} }
@ -518,7 +518,7 @@ if (empty($reshook))
$mesg = $object->error; $mesg = $object->error;
} }
setEventMessage($mesg, 'errors'); setEventMessages($mesg, $mesgs, 'errors');
$action=""; $action="";
} }
@ -582,7 +582,7 @@ if (empty($reshook))
$mesgs[] =$object->error; $mesgs[] =$object->error;
} }
setEventMessage($mesgs, 'errors'); setEventMessages($mesg, $mesgs, 'errors');
$action="edit"; $action="edit";
} }
else else
@ -597,7 +597,7 @@ if (empty($reshook))
if ($object->id > 0) if ($object->id > 0)
{ {
$object->valid($user); $object->valid($user);
setEventMessage($langs->trans("MailingSuccessfullyValidated")); setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs');
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} }
@ -628,7 +628,7 @@ if (empty($reshook))
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$db->rollback(); $db->rollback();
} }
} }
@ -764,18 +764,18 @@ else
// You ensure that every user is using its own SMTP server. // You ensure that every user is using its own SMTP server.
$linktoadminemailbefore='<a href="'.DOL_URL_ROOT.'/admin/mails.php">'; $linktoadminemailbefore='<a href="'.DOL_URL_ROOT.'/admin/mails.php">';
$linktoadminemailend='</a>'; $linktoadminemailend='</a>';
setEventMessage($langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]), 'warnings'); setEventMessages($langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]), null, 'warnings');
setEventMessage($langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']), 'warnings'); setEventMessages($langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']), null, 'warnings');
if (! empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) setEventMessage($langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), 'warnings'); if (! empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) setEventMessages($langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), null, 'warnings');
$_GET["action"]=''; $_GET["action"]='';
} }
else if (empty($conf->global->MAILING_LIMIT_SENDBYWEB)) else if (empty($conf->global->MAILING_LIMIT_SENDBYWEB))
{ {
// Pour des raisons de securite, on ne permet pas cette fonction via l'IHM, // Pour des raisons de securite, on ne permet pas cette fonction via l'IHM,
// on affiche donc juste un message // on affiche donc juste un message
setEventMessage($langs->trans("MailingNeedCommand"), 'warnings'); setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings');
setEventMessage('<textarea cols="60" rows="'.ROWS_1.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.'</textarea>', 'warnings'); setEventMessages('<textarea cols="60" rows="'.ROWS_1.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.'</textarea>', null, 'warnings');
setEventMessage($langs->trans("MailingNeedCommand2"), 'warnings'); setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings');
$_GET["action"]=''; $_GET["action"]='';
} }
else else

View File

@ -80,7 +80,7 @@ if ($action == 'add')
//print $dir."\n<br>"; //print $dir."\n<br>";
dol_syslog("Scan directory ".$dir." for modules"); dol_syslog("Scan directory ".$dir." for modules");
// Chargement de la classe // Loading Class
$file = $dir."/".$module.".modules.php"; $file = $dir."/".$module.".modules.php";
$classname = "mailing_".$module; $classname = "mailing_".$module;
@ -100,24 +100,24 @@ if ($action == 'add')
} }
if ($result > 0) if ($result > 0)
{ {
setEventMessage($langs->trans("XTargetsAdded",$result),'mesgs'); setEventMessages($langs->trans("XTargetsAdded",$result), null, 'mesgs');
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
exit; exit;
} }
if ($result == 0) if ($result == 0)
{ {
setEventMessage($langs->trans("WarningNoEMailsAdded"),'warnings'); setEventMessages($langs->trans("WarningNoEMailsAdded"), null, 'warnings');
} }
if ($result < 0) if ($result < 0)
{ {
setEventMessage($langs->trans("Error").($obj->error?' '.$obj->error:''),'errors'); setEventMessages($langs->trans("Error").($obj->error?' '.$obj->error:''), null, 'errors');
} }
} }
if (GETPOST('clearlist')) if (GETPOST('clearlist'))
{ {
// Chargement de la classe // Loading Class
$obj = new MailingTargets($db); $obj = new MailingTargets($db);
$obj->clear_target($id); $obj->clear_target($id);
@ -267,7 +267,7 @@ if ($object->fetch($id) >= 0)
// Loop on each submodule // Loop on each submodule
foreach($modulenames as $modulename) foreach($modulenames as $modulename)
{ {
// Chargement de la classe // Loading Class
$file = $dir.$modulename.".modules.php"; $file = $dir.$modulename.".modules.php";
$classname = "mailing_".$modulename; $classname = "mailing_".$modulename;
require_once $file; require_once $file;

View File

@ -83,7 +83,7 @@ if (is_resource($handle))
$modulename=$reg[1]; $modulename=$reg[1];
if ($modulename == 'example') continue; if ($modulename == 'example') continue;
// Chargement de la classe // Loading Class
$file = $dir."/".$modulename.".modules.php"; $file = $dir."/".$modulename.".modules.php";
$classname = "mailing_".$modulename; $classname = "mailing_".$modulename;
require_once $file; require_once $file;

View File

@ -6,7 +6,7 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2010-2011 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2010-2015 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr> * Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
@ -131,7 +131,7 @@ if (empty($reshook))
{ {
if (! GETPOST('socid', 3)) if (! GETPOST('socid', 3))
{ {
setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
} }
else else
{ {
@ -141,7 +141,7 @@ if (empty($reshook))
header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result);
exit(); exit();
} else { } else {
if (count($object->errors) > 0) setEventMessage($object->errors, 'errors'); if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors');
$action = ''; $action = '';
} }
} }
@ -157,7 +157,7 @@ if (empty($reshook))
exit(); exit();
} else { } else {
$langs->load("errors"); $langs->load("errors");
setEventMessage($langs->trans($object->error), 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
@ -211,8 +211,8 @@ if (empty($reshook))
} }
} else { } else {
$langs->load("errors"); $langs->load("errors");
if (count($object->errors) > 0) setEventMessage($object->errors, 'errors'); if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors');
else setEventMessage($langs->trans($object->error), 'errors'); else setEventMessages($langs->trans($object->error), null, 'errors');
} }
} }
@ -318,7 +318,7 @@ if (empty($reshook))
$id = $object->create_from($user); $id = $object->create_from($user);
} else { } else {
setEventMessage($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), 'errors'); setEventMessages($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), null, 'errors');
} }
} else { } else {
$object->ref = GETPOST('ref'); $object->ref = GETPOST('ref');
@ -507,7 +507,7 @@ if (empty($reshook))
if ($result < 0) if ($result < 0)
{ {
$error++; $error++;
setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors'); setEventMessages($langs->trans("ErrorFailedToAddContact"), null, 'errors');
} }
} }
@ -671,7 +671,7 @@ if (empty($reshook))
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'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} }
@ -875,7 +875,7 @@ if (empty($reshook))
if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) {
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency));
setEventMessage($mesg, 'errors'); setEventMessages($mesg, null, 'errors');
} else { } else {
// Insert line // Insert line
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit); $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit);
@ -929,13 +929,13 @@ if (empty($reshook))
} else { } else {
$db->rollback(); $db->rollback();
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} }
} }
// Mise a jour d'une ligne dans la propale // Update a line within proposal
else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('save')) else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('save'))
{ {
// Define info_bits // Define info_bits
@ -991,7 +991,7 @@ if (empty($reshook))
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) {
setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors');
$error ++; $error ++;
} }
} else { } else {
@ -1040,7 +1040,7 @@ if (empty($reshook))
} else { } else {
$db->rollback(); $db->rollback();
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} }
@ -1137,9 +1137,9 @@ if (empty($reshook))
} else { } else {
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
$langs->load("errors"); $langs->load("errors");
setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors'); setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
} else { } else {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} }
@ -1636,13 +1636,13 @@ if ($action == 'create')
else if ($action == 'validate') { else if ($action == 'validate') {
$error = 0; $error = 0;
// on verifie si l'objet est en numerotation provisoire // We verifie whether the object is provisionally numbering
$ref = substr($object->ref, 1, 4); $ref = substr($object->ref, 1, 4);
if ($ref == 'PROV') { if ($ref == 'PROV') {
$numref = $object->getNextNumRef($soc); $numref = $object->getNextNumRef($soc);
if (empty($numref)) { if (empty($numref)) {
$error ++; $error ++;
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} else { } else {
$numref = $object->ref; $numref = $object->ref;

View File

@ -375,13 +375,15 @@ class Propal extends CommonObject
* @param int $date_end End date of the line * @param int $date_end End date of the line
* @param array $array_options extrafields array * @param array $array_options extrafields array
* @param string $fk_unit Code of the unit to use. Null to use the default one * @param string $fk_unit Code of the unit to use. Null to use the default one
* @param string $origin 'order', ...
* @param int $origin_id Id of origin object
* @return int >0 if OK, <0 if KO * @return int >0 if OK, <0 if KO
* *
* @see add_product * @see add_product
*/ */
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0, $fk_unit=null) function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0)
{ {
global $mysoc; global $mysoc, $conf, $langs;
dol_syslog(get_class($this)."::addline propalid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type"); dol_syslog(get_class($this)."::addline propalid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type");
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
@ -499,6 +501,9 @@ class Propal extends CommonObject
$this->line->fk_fournprice = $fk_fournprice; $this->line->fk_fournprice = $fk_fournprice;
$this->line->pa_ht = $pa_ht; $this->line->pa_ht = $pa_ht;
$this->line->origin_id = $origin_id;
$this->line->origin = $origin;
// Mise en option de la ligne // Mise en option de la ligne
if (empty($qty) && empty($special_code)) $this->line->special_code=3; if (empty($qty) && empty($special_code)) $this->line->special_code=3;
@ -570,7 +575,8 @@ class Propal extends CommonObject
{ {
global $mysoc; global $mysoc;
dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, desc=$desc, price_base_type=$price_base_type, info_bits=$info_bits, special_code=$special_code, fk_parent_line=$fk_parent_line, pa_ht=$a_ht, type=$type, date_start=$date_start, date_end=$date_end"); dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise_percent=$remise_percent,
txtva=$txtva, desc=$desc, price_base_type=$price_base_type, info_bits=$info_bits, special_code=$special_code, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, type=$type, date_start=$date_start, date_end=$date_end");
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
// Clean parameters // Clean parameters
@ -894,7 +900,9 @@ class Propal extends CommonObject
$this->lines[$i]->date_start, $this->lines[$i]->date_start,
$this->lines[$i]->date_end, $this->lines[$i]->date_end,
$this->lines[$i]->array_options, $this->lines[$i]->array_options,
$this->lines[$i]->fk_unit $this->lines[$i]->fk_unit,
$this->element,
$this->lines[$i]->id
); );
if ($result < 0) if ($result < 0)
@ -1384,7 +1392,10 @@ class Propal extends CommonObject
*/ */
function update_extrafields($user) function update_extrafields($user)
{ {
global $conf, $hookmanager;
$action='update'; $action='update';
$error = 0;
// Actions on extra fields (by external module or standard code) // Actions on extra fields (by external module or standard code)
// TODO le hook fait double emploi avec le trigger !! // TODO le hook fait double emploi avec le trigger !!
@ -2717,7 +2728,7 @@ class Propal extends CommonObject
*/ */
function getNomUrl($withpicto=0,$option='', $get_params='') function getNomUrl($withpicto=0,$option='', $get_params='')
{ {
global $langs; global $langs, $conf;
$result=''; $result='';
$label = '<u>' . $langs->trans("ShowPropal") . '</u>'; $label = '<u>' . $langs->trans("ShowPropal") . '</u>';

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net> /* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
* Copyright (C) 2005-2009 Destailleur Laurent <eldy@users.sourceforge.net> * Copyright (C) 2005-2009 Destailleur Laurent <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2011-2015 Philippe Grand <philippe.grand@atoo-net.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
@ -54,12 +54,12 @@ if ($id > 0 || ! empty($ref))
if ($ret == 0) if ($ret == 0)
{ {
$langs->load("errors"); $langs->load("errors");
setEventMessage($langs->trans('ErrorRecordNotFound'), 'errors'); setEventMessages($langs->trans('ErrorRecordNotFound'), null, 'errors');
$error++; $error++;
} }
else if ($ret < 0) else if ($ret < 0)
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$error++; $error++;
} }
} }
@ -75,7 +75,7 @@ else
/* /*
* Ajout d'un nouveau contact * Add a new contact
*/ */
if ($action == 'addcontact' && $user->rights->propale->creer) if ($action == 'addcontact' && $user->rights->propale->creer)
@ -96,16 +96,16 @@ if ($action == 'addcontact' && $user->rights->propale->creer)
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{ {
$langs->load("errors"); $langs->load("errors");
setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors'); setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} }
// Bascule du statut d'un contact // Toggle the status of a contact
else if ($action == 'swapstatut' && $user->rights->propale->creer) else if ($action == 'swapstatut' && $user->rights->propale->creer)
{ {
if ($object->id > 0) if ($object->id > 0)
@ -114,7 +114,7 @@ else if ($action == 'swapstatut' && $user->rights->propale->creer)
} }
} }
// Efface un contact // Deletes a contact
else if ($action == 'deletecontact' && $user->rights->propale->creer) else if ($action == 'deletecontact' && $user->rights->propale->creer)
{ {
$result = $object->delete_contact($lineid); $result = $object->delete_contact($lineid);

View File

@ -65,17 +65,17 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes')
if (! $res > 0) if (! $res > 0)
{ {
$error++; $error++;
setEventMessage($langs->trans("ErrorFailedToLoadDiscount"), 'errors'); setEventMessages($langs->trans("ErrorFailedToLoadDiscount"), null, 'errors');
} }
if (! $error && price2num($_POST["amount_ttc_1"]+$_POST["amount_ttc_2"]) != $discount->amount_ttc) if (! $error && price2num($_POST["amount_ttc_1"]+$_POST["amount_ttc_2"]) != $discount->amount_ttc)
{ {
$error++; $error++;
setEventMessage($langs->trans("TotalOfTwoDiscountMustEqualsOriginal"), 'errors'); setEventMessages($langs->trans("TotalOfTwoDiscountMustEqualsOriginal"), null, 'errors');
} }
if (! $error && $discount->fk_facture_line) if (! $error && $discount->fk_facture_line)
{ {
$error++; $error++;
setEventMessage($langs->trans("ErrorCantSplitAUsedDiscount"), 'errors'); setEventMessages($langs->trans("ErrorCantSplitAUsedDiscount"), null, 'errors');
} }
if (! $error) if (! $error)
{ {
@ -166,13 +166,13 @@ if ($action == 'setremise')
else else
{ {
$error++; $error++;
setEventMessage($soc->error, 'errors'); setEventMessages($soc->error, $soc->errors, 'errors');
} }
} }
} }
else else
{ {
setEventMessage($langs->trans("ErrorFieldFormat",$langs->trans("NewGlobalDiscount")), 'errors'); setEventMessages($langs->trans("ErrorFieldFormat",$langs->trans("NewGlobalDiscount")), null, 'errors');
} }
} }
@ -194,7 +194,7 @@ if (GETPOST("action") == 'confirm_remove' && GETPOST("confirm")=='yes')
} }
else else
{ {
setEventMessage($discount->error, 'errors'); setEventMessages($discount->error, $discount->errors, 'errors');
$db->rollback(); $db->rollback();
} }
} }
@ -216,7 +216,7 @@ if ($socid > 0)
$object->fetch($socid); $object->fetch($socid);
/* /*
* Affichage onglets * Display tabs
*/ */
$head = societe_prepare_head($object); $head = societe_prepare_head($object);
@ -300,7 +300,7 @@ if ($socid > 0)
} }
/* /*
* Liste remises fixes restant en cours (= liees a acune facture ni ligne de facture) * Liste remises fixes restant en cours (= liees a aucune facture ni ligne de facture)
*/ */
$sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,"; $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,";
$sql.= " rc.datec as dc, rc.description,"; $sql.= " rc.datec as dc, rc.description,";

View File

@ -5,7 +5,7 @@
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2011-2015 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr> * Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
@ -123,7 +123,7 @@ if (empty($reshook))
{ {
if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers'))
{ {
setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
} }
else else
{ {
@ -140,7 +140,7 @@ if (empty($reshook))
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$object = $orig; $object = $orig;
$action=''; $action='';
} }
@ -176,7 +176,7 @@ if (empty($reshook))
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
@ -224,7 +224,7 @@ if (empty($reshook))
$datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); $datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year'));
if ($datecommande == '') { if ($datecommande == '') {
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentities('Date')), 'errors'); setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors');
$action = 'create'; $action = 'create';
$error++; $error++;
} }
@ -373,11 +373,11 @@ if (empty($reshook))
if ($reshook < 0) if ($reshook < 0)
$error++; $error++;
} else { } else {
setEventMessage($srcobject->error, 'errors'); setEventMessages($srcobject->error, $srcobject->errors, 'errors');
$error++; $error++;
} }
} else { } else {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$error++; $error++;
} }
} else { } else {
@ -413,7 +413,7 @@ if (empty($reshook))
{ {
$result = $object->add_contact(GETPOST('contactid'), 'CUSTOMER', 'external'); $result = $object->add_contact(GETPOST('contactid'), 'CUSTOMER', 'external');
if ($result < 0) { if ($result < 0) {
setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors'); setEventMessages($langs->trans("ErrorFailedToAddContact"), null, 'errors');
$error++; $error++;
} }
} }
@ -431,7 +431,7 @@ if (empty($reshook))
} else { } else {
$db->rollback(); $db->rollback();
$action = 'create'; $action = 'create';
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} }
@ -441,7 +441,7 @@ if (empty($reshook))
$ret=$object->classifyBilled(); $ret=$object->classifyBilled();
if ($ret < 0) { if ($ret < 0) {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
@ -594,11 +594,11 @@ if (empty($reshook))
} }
if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) {
setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors');
$error++; $error++;
} }
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) {
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors'); setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
$error++; $error++;
} }
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not ''
@ -607,11 +607,11 @@ if (empty($reshook))
$error++; $error++;
} }
if ($qty == '') { if ($qty == '') {
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors'); setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
$error++; $error++;
} }
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) {
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors'); setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors');
$error++; $error++;
} }
@ -672,7 +672,7 @@ if (empty($reshook))
} }
else else
{ {
setEventMessage($prodcustprice->error,'errors'); setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
} }
} }
@ -756,7 +756,7 @@ if (empty($reshook))
if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) {
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency));
setEventMessage($mesg, 'errors'); setEventMessages($mesg, null, 'errors');
} else { } else {
// Insert line // Insert line
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit); $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit);
@ -810,7 +810,7 @@ if (empty($reshook))
unset($_POST['date_endmonth']); unset($_POST['date_endmonth']);
unset($_POST['date_endyear']); unset($_POST['date_endyear']);
} else { } else {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} }
@ -874,7 +874,7 @@ if (empty($reshook))
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) {
setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors');
$error++; $error++;
} }
} else { } else {
@ -922,7 +922,7 @@ if (empty($reshook))
unset($_POST['fournprice']); unset($_POST['fournprice']);
unset($_POST['buying_price']); unset($_POST['buying_price']);
} else { } else {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} }
@ -955,7 +955,7 @@ if (empty($reshook))
if (! $idwarehouse || $idwarehouse == -1) if (! $idwarehouse || $idwarehouse == -1)
{ {
$error++; $error++;
setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")), 'errors'); setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")), null, 'errors');
$action=''; $action='';
} }
} }
@ -1008,7 +1008,7 @@ if (empty($reshook))
if (! $idwarehouse || $idwarehouse == -1) if (! $idwarehouse || $idwarehouse == -1)
{ {
$error++; $error++;
setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")), 'errors'); setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")), null, 'errors');
$action=''; $action='';
} }
} }
@ -1040,7 +1040,7 @@ if (empty($reshook))
else if ($action == 'confirm_shipped' && $confirm == 'yes' && $user->rights->commande->cloturer) { else if ($action == 'confirm_shipped' && $confirm == 'yes' && $user->rights->commande->cloturer) {
$result = $object->cloture($user); $result = $object->cloture($user);
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors(), 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
@ -1067,7 +1067,7 @@ if (empty($reshook))
if (! $idwarehouse || $idwarehouse == -1) if (! $idwarehouse || $idwarehouse == -1)
{ {
$error++; $error++;
setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")), 'errors'); setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")), null, 'errors');
$action=''; $action='';
} }
} }
@ -1076,7 +1076,7 @@ if (empty($reshook))
$result = $object->cancel($idwarehouse); $result = $object->cancel($idwarehouse);
if ($result < 0) { if ($result < 0) {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} }
@ -1123,9 +1123,9 @@ if (empty($reshook))
$file = $upload_dir . '/' . GETPOST('file'); $file = $upload_dir . '/' . GETPOST('file');
$ret = dol_delete_file($file, 0, 0, 0, $object); $ret = dol_delete_file($file, 0, 0, 0, $object);
if ($ret) if ($ret)
setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
else else
setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
$action = ''; $action = '';
} }
} }
@ -1189,9 +1189,9 @@ if (empty($reshook))
} else { } else {
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
$langs->load("errors"); $langs->load("errors");
setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors'); setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
} else { } else {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} }

View File

@ -777,7 +777,9 @@ class Commande extends CommonOrder
$this->lines[$i]->pa_ht, $this->lines[$i]->pa_ht,
$this->lines[$i]->label, $this->lines[$i]->label,
$this->lines[$i]->array_options, $this->lines[$i]->array_options,
$this->lines[$i]->fk_unit $this->lines[$i]->fk_unit,
$this->element,
$this->lines[$i]->id
); );
if ($result < 0) if ($result < 0)
{ {
@ -2322,6 +2324,7 @@ class Commande extends CommonOrder
function classifyBilled() function classifyBilled()
{ {
global $conf, $user, $langs; global $conf, $user, $langs;
$error = 0;
$this->db->begin(); $this->db->begin();
@ -2636,6 +2639,7 @@ class Commande extends CommonOrder
global $hookmanager, $conf; global $hookmanager, $conf;
$action='create'; $action='create';
$error = 0;
// Actions on extra fields (by external module or standard code) // Actions on extra fields (by external module or standard code)
// TODO le hook fait double emploi avec le trigger !! // TODO le hook fait double emploi avec le trigger !!
@ -2872,7 +2876,7 @@ class Commande extends CommonOrder
*/ */
function LibStatut($statut,$billed,$mode) function LibStatut($statut,$billed,$mode)
{ {
global $langs; global $langs, $conf;
//print 'x'.$statut.'-'.$billed; //print 'x'.$statut.'-'.$billed;
if ($mode == 0) if ($mode == 0)
{ {

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net> /* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2011-2015 Philippe Grand <philippe.grand@atoo-net.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
@ -69,11 +69,11 @@ if ($action == 'addcontact' && $user->rights->commande->creer)
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{ {
$langs->load("errors"); $langs->load("errors");
setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors'); setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} }

View File

@ -74,7 +74,7 @@ if ($action == 'create')
if (is_array($selected) == false) if (is_array($selected) == false)
{ {
$error++; $error++;
setEventMessage($langs->trans('Error_OrderNotChecked'), 'errors'); setEventMessages($langs->trans('Error_OrderNotChecked'), null, 'errors');
} }
else else
{ {
@ -251,7 +251,7 @@ if (($action == 'create' || $action == 'add') && !$error)
} }
else else
{ {
setEventMessage($discount->error, 'errors'); setEventMessages($discount->error, $discount->errors, 'errors');
$error++; $error++;
break; break;
} }
@ -320,7 +320,7 @@ if (($action == 'create' || $action == 'add') && !$error)
} }
else else
{ {
setEventMessage($objectsrc->error, 'errors'); setEventMessages($objectsrc->error, $objectsrc->errors, 'errors');
$error++; $error++;
} }
$ii++; $ii++;
@ -328,7 +328,7 @@ if (($action == 'create' || $action == 'add') && !$error)
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$error++; $error++;
} }
} }
@ -348,7 +348,7 @@ if (($action == 'create' || $action == 'add') && !$error)
$action='create'; $action='create';
$_GET["origin"]=$_POST["origin"]; $_GET["origin"]=$_POST["origin"];
$_GET["originid"]=$_POST["originid"]; $_GET["originid"]=$_POST["originid"];
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$error++; $error++;
} }
} }

View File

@ -152,13 +152,13 @@ if ($action == 'add' && $id && ! isset($_POST["cancel"]) && $user->rights->banqu
$insertid = $object->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user); $insertid = $object->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user);
if ($insertid > 0) if ($insertid > 0)
{ {
setEventMessage($langs->trans("RecordSaved")); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id."&action=addline"); header("Location: ".$_SERVER['PHP_SELF']."?id=".$id."&action=addline");
exit; exit;
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
else else
@ -378,19 +378,6 @@ if ($id > 0 || ! empty($ref))
{ {
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($object->type != 2 && $object->rappro)
{
// If not cash account and can be reconciliate
if ($user->rights->banque->consolidate)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/rappro.php?account='.$object->id.($vline?'&amp;vline='.$vline:'').'">'.$langs->trans("Conciliate").'</a>';
}
else
{
print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("Conciliate").'</a>';
}
}
if ($action != 'addline') if ($action != 'addline')
{ {
if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT))
@ -409,6 +396,20 @@ if ($id > 0 || ! empty($ref))
print '<a class="butActionRefused" title="'.$langs->trans("FeatureDisabled").'" href="#">'.$langs->trans("AddBankRecord").'</a>'; print '<a class="butActionRefused" title="'.$langs->trans("FeatureDisabled").'" href="#">'.$langs->trans("AddBankRecord").'</a>';
} }
} }
if ($object->type != 2 && $object->rappro)
{
// If not cash account and can be reconciliate
if ($user->rights->banque->consolidate)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/rappro.php?account='.$object->id.($vline?'&amp;vline='.$vline:'').'">'.$langs->trans("Conciliate").'</a>';
}
else
{
print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("Conciliate").'</a>';
}
}
print '</div>'; print '</div>';
} }

View File

@ -291,7 +291,7 @@ if ($result < 0)
{ {
$langs->load("errors"); $langs->load("errors");
$error++; $error++;
setEventMessage($langs->trans("ErrorFailedToCreateDir"), 'errors'); setEventMessages($langs->trans("ErrorFailedToCreateDir"), null, 'errors');
} }
else else
{ {

View File

@ -102,19 +102,19 @@ if ($_POST["action"] == 'add')
if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($account->account_number)) if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($account->account_number))
{ {
setEventMessage($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), 'error'); setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'error');
$action='create'; // Force chargement page en mode creation $action='create'; // Force chargement page en mode creation
$error++; $error++;
} }
if (empty($account->ref)) if (empty($account->ref))
{ {
setEventMessage($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), 'errors'); setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors');
$action='create'; // Force chargement page en mode creation $action='create'; // Force chargement page en mode creation
$error++; $error++;
} }
if (empty($account->label)) if (empty($account->label))
{ {
setEventMessage($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("LabelBankCashAccount")), 'errors'); setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
$action='create'; // Force chargement page en mode creation $action='create'; // Force chargement page en mode creation
$error++; $error++;
} }
@ -130,7 +130,7 @@ if ($_POST["action"] == 'add')
$_GET["id"]=$id; // Force chargement page en mode visu $_GET["id"]=$id; // Force chargement page en mode visu
} }
else { else {
setEventMessage($account->error,'errors'); setEventMessages($account->error, $account->errors, 'errors');
$action='create'; // Force chargement page en mode creation $action='create'; // Force chargement page en mode creation
} }
} }
@ -177,19 +177,19 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"])
if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($account->account_number)) if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($account->account_number))
{ {
setEventMessage($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), 'error'); setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'error');
$action='edit'; // Force chargement page en mode creation $action='edit'; // Force chargement page en mode creation
$error++; $error++;
} }
if (empty($account->ref)) if (empty($account->ref))
{ {
setEventMessage($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), 'errors'); setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors');
$action='edit'; // Force chargement page en mode creation $action='edit'; // Force chargement page en mode creation
$error++; $error++;
} }
if (empty($account->label)) if (empty($account->label))
{ {
setEventMessage($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("LabelBankCashAccount")), 'errors'); setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
$action='edit'; // Force chargement page en mode creation $action='edit'; // Force chargement page en mode creation
$error++; $error++;
} }
@ -206,7 +206,7 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"])
} }
else else
{ {
setEventMessage($account->error, 'errors'); setEventMessages($account->error, $account->errors, 'errors');
$action='edit'; // Force chargement page edition $action='edit'; // Force chargement page edition
} }
} }

View File

@ -998,6 +998,11 @@ class Account extends CommonObject
$link = '<a href="'.DOL_URL_ROOT.'/compta/bank/account.php?account='.$this->id.$linkclose; $link = '<a href="'.DOL_URL_ROOT.'/compta/bank/account.php?account='.$this->id.$linkclose;
$linkend='</a>'; $linkend='</a>';
} }
else if ($mode == 'receipts')
{
$link = '<a href="'.DOL_URL_ROOT.'/compta/bank/releve.php?account='.$this->id.$linkclose;
$linkend='</a>';
}
if ($withpicto) $result.=($link.img_object($label, 'account', 'class="classfortooltip"').$linkend.' '); if ($withpicto) $result.=($link.img_object($label, 'account', 'class="classfortooltip"').$linkend.' ');
$result.=$link.$this->label.$linkend; $result.=$link.$this->label.$linkend;

View File

@ -133,9 +133,9 @@ else if ($action == 'confirm_deletefile' && $confirm == 'yes') {
$ret = dol_delete_file($file, 0, 0, 0, $object); $ret = dol_delete_file($file, 0, 0, 0, $object);
if ($ret) { if ($ret) {
setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
} else { } else {
setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
} }
Header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); Header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);

View File

@ -81,7 +81,7 @@ if ($result < 0)
{ {
$langs->load("errors"); $langs->load("errors");
$error++; $error++;
setEventMessage($langs->trans("ErrorFailedToCreateDir"), 'errors'); setEventMessages($langs->trans("ErrorFailedToCreateDir"), null, 'errors');
} }
else else
{ {
@ -113,7 +113,7 @@ else
if ($mode == 'standard') if ($mode == 'standard')
{ {
// Chargement du tableau $amounts // Loading table $amounts
$amounts = array(); $amounts = array();
$monthnext = $month+1; $monthnext = $month+1;
@ -153,7 +153,7 @@ else
dol_print_error($db); dol_print_error($db);
} }
// Calcul de $solde avant le debut du graphe // Calculation of $solde before the start of the graph
$solde = 0; $solde = 0;
$sql = "SELECT SUM(b.amount)"; $sql = "SELECT SUM(b.amount)";
@ -265,7 +265,7 @@ else
if ($mode == 'standard') if ($mode == 'standard')
{ {
// Chargement du tableau $amounts // Loading table $amounts
$amounts = array(); $amounts = array();
$sql = "SELECT date_format(b.datev,'%Y%m%d')"; $sql = "SELECT date_format(b.datev,'%Y%m%d')";
$sql.= ", SUM(b.amount)"; $sql.= ", SUM(b.amount)";
@ -296,7 +296,7 @@ else
dol_print_error($db); dol_print_error($db);
} }
// Calcul de $solde avant le debut du graphe // Calculation of $solde before the start of the graph
$solde = 0; $solde = 0;
$sql = "SELECT SUM(b.amount)"; $sql = "SELECT SUM(b.amount)";
@ -403,7 +403,7 @@ else
if ($mode == 'showalltime') if ($mode == 'showalltime')
{ {
// Chargement du tableau $amounts // Loading table $amounts
$amounts = array(); $amounts = array();
$sql = "SELECT date_format(b.datev,'%Y%m%d')"; $sql = "SELECT date_format(b.datev,'%Y%m%d')";

View File

@ -113,7 +113,7 @@ foreach ($accounts as $key=>$type)
{ {
$result=$acc->load_board($user,$acc->id); $result=$acc->load_board($user,$acc->id);
if ($result<0) { if ($result<0) {
setEventMessage($acc->error, 'errors'); setEventMessages($acc->error, $acc->errors, 'errors');
} else { } else {
print $result->nbtodo; print $result->nbtodo;
if ($result->nbtodolate) print ' ('.$result->nbtodolate.img_warning($langs->trans("Late")).')'; if ($result->nbtodolate) print ' ('.$result->nbtodolate.img_warning($langs->trans("Late")).')';
@ -229,7 +229,7 @@ foreach ($accounts as $key=>$type)
{ {
$result=$acc->load_board($user,$acc->id); $result=$acc->load_board($user,$acc->id);
if ($result<0) { if ($result<0) {
setEventMessage($acc->error, 'errors'); setEventMessages($acc->error, $acc->errors, 'errors');
} else { } else {
print $result->nbtodo; print $result->nbtodo;
if ($result->nbtodolate) print ' ('.$result->nbtodolate.img_warning($langs->trans("Late")).')'; if ($result->nbtodolate) print ' ('.$result->nbtodolate.img_warning($langs->trans("Late")).')';

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Xavier DUTOIT <doli@sydesy.com> * Copyright (C) 2003 Xavier DUTOIT <doli@sydesy.com>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr> * Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
@ -104,7 +104,7 @@ if ($user->rights->banque->modifier && $action == "update")
if ($ac->courant == 2 && $_POST['value'] != 'LIQ') if ($ac->courant == 2 && $_POST['value'] != 'LIQ')
{ {
setEventMessage($langs->trans("ErrorCashAccountAcceptsOnlyCashMoney"), 'errors'); setEventMessages($langs->trans("ErrorCashAccountAcceptsOnlyCashMoney"), null, 'errors');
$error++; $error++;
} }
@ -146,7 +146,7 @@ if ($user->rights->banque->modifier && $action == "update")
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
setEventMessage($langs->trans("RecordSaved")); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
$db->commit(); $db->commit();
} }
else else
@ -184,7 +184,7 @@ if ($user->rights->banque->consolidate && ($action == 'num_releve' || $action ==
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
setEventMessage($langs->trans("RecordSaved")); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
$db->commit(); $db->commit();
} }
else else
@ -205,7 +205,7 @@ $form = new Form($db);
llxHeader(); llxHeader();
// On initialise la liste des categories // The list of categories is initialized
$sql = "SELECT rowid, label"; $sql = "SELECT rowid, label";
$sql.= " FROM ".MAIN_DB_PREFIX."bank_categ"; $sql.= " FROM ".MAIN_DB_PREFIX."bank_categ";
$sql.= " ORDER BY label"; $sql.= " ORDER BY label";
@ -587,7 +587,7 @@ if ($result)
if ($user->rights->banque->consolidate) if ($user->rights->banque->consolidate)
{ {
print '<td colspan="3">'; print '<td colspan="3">';
print '<input type="checkbox" name="reconciled" class="flat" '.(isset($_POST["reconciled"])?($_POST["reconciled"]?' checked':''):($objp->rappro?' checked':'')).'">'; print '<input type="checkbox" name="reconciled" class="flat" '.(isset($_POST["reconciled"])?($_POST["reconciled"]?' checked="checked"':''):($objp->rappro?' checked="checked"':'')).'">';
print '</td>'; print '</td>';
} }
else else

View File

@ -71,7 +71,7 @@ if ($action == 'rappro' && $user->rights->banque->consolidate)
$result=$bankline->update_conciliation($user,$_POST["cat"]); $result=$bankline->update_conciliation($user,$_POST["cat"]);
if ($result < 0) if ($result < 0)
{ {
setEventMessage($bankline->error, 'errors'); setEventMessages($bankline->error, $bankline->errors, 'errors');
$error++; $error++;
break; break;
} }
@ -83,7 +83,7 @@ if ($action == 'rappro' && $user->rights->banque->consolidate)
{ {
$error++; $error++;
$langs->load("errors"); $langs->load("errors");
setEventMessage($langs->trans("ErrorPleaseTypeBankTransactionReportName"), 'errors'); setEventMessages($langs->trans("ErrorPleaseTypeBankTransactionReportName"), null, 'errors');
} }
if (! $error) if (! $error)
@ -186,7 +186,7 @@ if ($resql)
print '<br>'; print '<br>';
// Show last bank receipts // Show last bank receipts
$nbmax=5; $nbmax=15; // We accept to show last 15 receipts (so we can have more than one year)
$liste=""; $liste="";
$sql = "SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX."bank"; $sql = "SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX."bank";
$sql.= " WHERE fk_account=".$acct->id." AND num_releve IS NOT NULL"; $sql.= " WHERE fk_account=".$acct->id." AND num_releve IS NOT NULL";
@ -226,7 +226,7 @@ if ($resql)
print '<input type="hidden" name="account" value="'.$acct->id.'">'; print '<input type="hidden" name="account" value="'.$acct->id.'">';
print '<strong>'.$langs->trans("InputReceiptNumber").'</strong>: '; print '<strong>'.$langs->trans("InputReceiptNumber").'</strong>: ';
print '<input class="flat" name="num_releve" type="text" value="'.(GETPOST('num_releve')?GETPOST('num_releve'):$last_releve).'" size="10">'; print '<input class="flat" name="num_releve" type="text" value="'.(GETPOST('num_releve')?GETPOST('num_releve'):'').'" size="10">'; // The only default value is value we just entered
print '<br>'; print '<br>';
if ($options) if ($options)
{ {

View File

@ -157,6 +157,7 @@ if (empty($num))
} }
print '</div>'; print '</div>';
print '<br><br>';
print_barre_liste('', $page, $_SERVER["PHP_SELF"], "&account=".$object->id, $sortfield, $sortorder,'',$numrows); print_barre_liste('', $page, $_SERVER["PHP_SELF"], "&account=".$object->id, $sortfield, $sortorder,'',$numrows);
@ -282,10 +283,15 @@ else
$found=true; $found=true;
} }
$mesprevnext ="<a href=\"releve.php?rel=prev&amp;num=$num&amp;ve=$ve&amp;account=$object->id\">".img_previous()."</a> &nbsp;"; $mesprevnext='';
$mesprevnext.= $langs->trans("AccountStatement")." $num"; $mesprevnext.='<div class="pagination"><ul>';
$mesprevnext.=" &nbsp; <a href=\"releve.php?rel=next&amp;num=$num&amp;ve=$ve&amp;account=$object->id\">".img_next()."</a>"; $mesprevnext.='<li class="pagination"><a data-role="button" data-icon="arrow-l" data-iconpos="left" href="'.$_SERVER["PHP_SELF"].'?rel=prev&amp;num='.$num.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><</a></li>';
print load_fiche_titre($langs->trans("AccountStatement").' '.$num.', '.$langs->trans("BankAccount").' : '.$object->getNomUrl(0),$mesprevnext, 'title_bank.png'); //$mesprevnext.=' &nbsp; ';
$mesprevnext.='<li class="pagination"><span class="inactive">'.$langs->trans("AccountStatement")." ".$num.'</span></li>';
//$mesprevnext.=' &nbsp; ';
$mesprevnext.='<li class="pagination"><a data-role="button" data-icon="arrow-r" data-iconpos="right" href="'.$_SERVER["PHP_SELF"].'?rel=next&amp;num='.$num.'&amp;ve='.$ve.'&amp;account='.$object->id.'">></a></li>';
$mesprevnext.='</ul></div>';
print load_fiche_titre($langs->trans("AccountStatement").' '.$num.', '.$langs->trans("BankAccount").' : '.$object->getNomUrl(0, 'receipts'), $mesprevnext, 'title_bank.png');
print '<br>'; print '<br>';
print "<form method=\"post\" action=\"releve.php\">"; print "<form method=\"post\" action=\"releve.php\">";

View File

@ -113,18 +113,18 @@ if ($action == 'add')
if (! $error) if (! $error)
{ {
$mesgs = $langs->trans("TransferFromToDone","<a href=\"account.php?account=".$accountfrom->id."\">".$accountfrom->label."</a>","<a href=\"account.php?account=".$accountto->id."\">".$accountto->label."</a>",$amount,$langs->transnoentities("Currency".$conf->currency)); $mesgs = $langs->trans("TransferFromToDone","<a href=\"account.php?account=".$accountfrom->id."\">".$accountfrom->label."</a>","<a href=\"account.php?account=".$accountto->id."\">".$accountto->label."</a>",$amount,$langs->transnoentities("Currency".$conf->currency));
setEventMessage($mesgs); setEventMessages($mesgs, null, 'mesgs');
$db->commit(); $db->commit();
} }
else else
{ {
setEventMessage($accountfrom->error.' '.$accountto->error, 'errors'); setEventMessages($accountfrom->error.' '.$accountto->error, null, 'errors');
$db->rollback(); $db->rollback();
} }
} }
else else
{ {
setEventMessage($langs->trans("ErrorFromToAccountsMustDiffers"), 'errors'); setEventMessages($langs->trans("ErrorFromToAccountsMustDiffers"), null, 'errors');
} }
} }
} }
@ -132,7 +132,7 @@ if ($action == 'add')
/* /*
* Affichage * View
*/ */
llxHeader(); llxHeader();

View File

@ -63,6 +63,7 @@ class Facture extends CommonInvoice
var $author; var $author;
var $fk_user_author; var $fk_user_author;
var $fk_user_valid; var $fk_user_valid;
var $date; // Date invoice
var $date_creation; // Creation date var $date_creation; // Creation date
var $date_validation; // Validation date var $date_validation; // Validation date
var $datem; var $datem;
@ -385,6 +386,8 @@ class Facture extends CommonInvoice
{ {
$newinvoiceline=$this->lines[$i]; $newinvoiceline=$this->lines[$i];
$newinvoiceline->fk_facture=$this->id; $newinvoiceline->fk_facture=$this->id;
$newinvoiceline->origin = $this->element;
$newinvoiceline->origin_id = $this->lines[$i]->id;
if ($result >= 0 && ($newinvoiceline->info_bits & 0x01) == 0) // We keep only lines with first bit = 0 if ($result >= 0 && ($newinvoiceline->info_bits & 0x01) == 0) // We keep only lines with first bit = 0
{ {
// Reset fk_parent_line for no child products and special product // Reset fk_parent_line for no child products and special product
@ -441,8 +444,8 @@ class Facture extends CommonInvoice
$this->lines[$i]->product_type, $this->lines[$i]->product_type,
$this->lines[$i]->rang, $this->lines[$i]->rang,
$this->lines[$i]->special_code, $this->lines[$i]->special_code,
'', $this->element,
0, $this->lines[$i]->id,
$fk_parent_line, $fk_parent_line,
$this->lines[$i]->fk_fournprice, $this->lines[$i]->fk_fournprice,
$this->lines[$i]->pa_ht, $this->lines[$i]->pa_ht,
@ -873,7 +876,7 @@ class Facture extends CommonInvoice
*/ */
function getNomUrl($withpicto=0,$option='',$max=0,$short=0,$moretitle='') function getNomUrl($withpicto=0,$option='',$max=0,$short=0,$moretitle='')
{ {
global $langs; global $langs, $conf;
$result=''; $result='';

View File

@ -415,7 +415,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print '<tr><td><span class="fieldrequired">'.$langs->trans('Date').'</span></td><td>'; print '<tr><td><span class="fieldrequired">'.$langs->trans('Date').'</span></td><td>';
$datepayment = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $datepayment = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
$datepayment= ($datepayment == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE)?-1:'') : $datepayment); $datepayment= ($datepayment == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE)?-1:'') : $datepayment);
$form->select_date($datepayment,'','','',0,"add_paiement",1,1); $form->select_date($datepayment,'','','',0,"add_paiement",1,1,0,0,'','',$facture->date);
print '</td>'; print '</td>';
print '<td>'.$langs->trans('Comments').'</td></tr>'; print '<td>'.$langs->trans('Comments').'</td></tr>';

View File

@ -122,6 +122,34 @@ $fieldstosearchall = array(
's.nom'=>"ThirdParty", 's.nom'=>"ThirdParty",
); );
// Definition of fields for list
$arrayfields=array(
'p.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1),
'p.firstname'=>array('label'=>$langs->trans("Firsname"), 'checked'=>1),
'p.poste'=>array('label'=>$langs->trans("Post"), 'checked'=>1),
'p.town'=>array('label'=>$langs->trans("Town"), 'checked'=>0),
'p.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>0),
'p.phone'=>array('label'=>$langs->trans("PhonePro"), 'checked'=>1),
'p.phone_perso'=>array('label'=>$langs->trans("PhonePerso"), 'checked'=>0),
'p.phone_mobile'=>array('label'=>$langs->trans("PhoneMobile"), 'checked'=>1),
'p.fax'=>array('label'=>$langs->trans("Fax"), 'checked'=>1),
'p.email'=>array('label'=>$langs->trans("Email"), 'checked'=>1),
'p.skype'=>array('label'=>$langs->trans("Skype"), 'checked'=>1, 'enabled'=>(! empty($conf->skype->enabled))),
'p.thirdparty'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'enabled'=>empty($conf->global->SOCIETE_DISABLE_CONTACTS)),
'p.priv'=>array('label'=>$langs->trans("ContactVisibility"), 'checked'=>1, 'position'=>200),
'p.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
'p.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
}
}
/* /*
* Actions * Actions
@ -386,34 +414,9 @@ if ($result)
print '</div>'; print '</div>';
} }
$arrayfields=array(
'p.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1),
'p.firstname'=>array('label'=>$langs->trans("Firsname"), 'checked'=>1),
'p.poste'=>array('label'=>$langs->trans("Post"), 'checked'=>1),
'p.town'=>array('label'=>$langs->trans("Town"), 'checked'=>0),
'p.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>0),
'p.phone'=>array('label'=>$langs->trans("PhonePro"), 'checked'=>1),
'p.phone_perso'=>array('label'=>$langs->trans("PhonePerso"), 'checked'=>0),
'p.phone_mobile'=>array('label'=>$langs->trans("PhoneMobile"), 'checked'=>1),
'p.fax'=>array('label'=>$langs->trans("Fax"), 'checked'=>1),
'p.email'=>array('label'=>$langs->trans("Email"), 'checked'=>1),
'p.skype'=>array('label'=>$langs->trans("Skype"), 'checked'=>1, 'enabled'=>(! empty($conf->skype->enabled))),
'p.thirdparty'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'enabled'=>empty($conf->global->SOCIETE_DISABLE_CONTACTS)),
'p.priv'=>array('label'=>$langs->trans("ContactVisibility"), 'checked'=>1, 'position'=>200),
'p.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
'p.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
}
}
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
print '<table class="liste '.($moreforfilter?"listwithfilterbefore":"").'">'; print '<table class="liste '.($moreforfilter?"listwithfilterbefore":"").'">';
// Ligne des titres // Ligne des titres

View File

@ -258,7 +258,7 @@ class ExtraFields
if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname) && ! is_numeric($attrname)) if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname) && ! is_numeric($attrname))
{ {
if(is_array($param) and count($param) > 0) if(is_array($param) && count($param) > 0)
{ {
$params = $this->db->escape(serialize($param)); $params = $this->db->escape(serialize($param));
} }

View File

@ -1546,7 +1546,7 @@ class Form
print img_picto($langs->trans("Search"), 'search'); print img_picto($langs->trans("Search"), 'search');
} }
} }
print '<input type="text" size="20" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' autofocus />'; print '<input type="text" size="20" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' />';
if ($hidelabel == 3) { if ($hidelabel == 3) {
print img_picto($langs->trans("Search"), 'search'); print img_picto($langs->trans("Search"), 'search');
} }
@ -1663,7 +1663,7 @@ class Form
require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php';
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$out.='<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'" autofocus>'; $out.='<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
$out.='<option value="0" selected>&nbsp;</option>'; $out.='<option value="0" selected>&nbsp;</option>';
$i = 0; $i = 0;
@ -4057,10 +4057,11 @@ class Form
* @param int $disabled Disable input fields * @param int $disabled Disable input fields
* @param int $fullday When a checkbox with this html name is on, hour and day are set with 00:00 or 23:59 * @param int $fullday When a checkbox with this html name is on, hour and day are set with 00:00 or 23:59
* @param string $addplusone Add a link "+1 hour". Value must be name of another select_date field. * @param string $addplusone Add a link "+1 hour". Value must be name of another select_date field.
* @param datetime $adddateof Add a link "Date of invoice" using the following date.
* @return mixed Nothing or string if nooutput is 1 * @return mixed Nothing or string if nooutput is 1
* @see form_date * @see form_date
*/ */
function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowlink=0, $nooutput=0, $disabled=0, $fullday='', $addplusone='') function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowlink=0, $nooutput=0, $disabled=0, $fullday='', $addplusone='', $adddateof='')
{ {
global $conf,$langs; global $conf,$langs;
@ -4318,6 +4319,13 @@ class Form
} }
} }
// Add a "Plus one hour" link
if ($conf->use_javascript_ajax && $adddateof)
{
$tmparray=dol_getdate($adddateof);
$retstring.=' - <button class="dpInvisibleButtons datenowlink" id="dateofinvoice" type="button" name="_dateofinvoice" value="now" onclick="jQuery(\'#re\').val(\''.dol_print_date($adddateof,'day').'\');jQuery(\'#reday\').val(\''.$tmparray['mday'].'\');jQuery(\'#remonth\').val(\''.$tmparray['mon'].'\');jQuery(\'#reyear\').val(\''.$tmparray['year'].'\');">'.$langs->trans("DateInvoice").'</a>';
}
if (! empty($nooutput)) return $retstring; if (! empty($nooutput)) return $retstring;
print $retstring; print $retstring;
@ -4513,16 +4521,20 @@ class Form
* @param string $morecss Add more class to css styles * @param string $morecss Add more class to css styles
* @param int $callurlonselect If set to 1, some code is added so an url return by the ajax is called when value is selected. * @param int $callurlonselect If set to 1, some code is added so an url return by the ajax is called when value is selected.
* @param string $placeholder String to use as placeholder * @param string $placeholder String to use as placeholder
* @return string HTML select string. * @param string $acceptdelayedhtml 1 if caller request to have html delayed content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect)
* @return string HTML select string
*/ */
static function selectArrayAjax($htmlname, $url, $id='', $moreparam='', $moreparamtourl='', $disabled=0, $minimumInputLength=1, $morecss='', $callurlonselect=0, $placeholder='') static function selectArrayAjax($htmlname, $url, $id='', $moreparam='', $moreparamtourl='', $disabled=0, $minimumInputLength=1, $morecss='', $callurlonselect=0, $placeholder='', $acceptdelayedhtml=0)
{ {
global $langs; global $langs;
global $delayedhtmlcontent;
$out = '';
$tmpplugin='select2'; $tmpplugin='select2';
$out.='<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
$out='<input type="text" class="'.$htmlname.($morecss?' '.$morecss:'').'" '.($moreparam?$moreparam.' ':'').'name="'.$htmlname.'">';
// TODO Use an internal dolibarr component instead of select2
$outdelayed='<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function () { $(document).ready(function () {
@ -4587,9 +4599,14 @@ class Form
}); });
</script>'; </script>';
if ($acceptdelayedhtml)
$out.='<input type="text" class="'.$htmlname.($morecss?' '.$morecss:'').'" '.($moreparam?$moreparam.' ':'').'name="'.$htmlname.'">'; {
$delayedhtmlcontent.=$outdelayed;
}
else
{
$out.=$outdelayed;
}
return $out; return $out;
} }
@ -5157,7 +5174,7 @@ class Form
* To add a particular filter on select, you must set $object->next_prev_filter to SQL criteria. * To add a particular filter on select, you must set $object->next_prev_filter to SQL criteria.
* *
* @param object $object Object to show * @param object $object Object to show
* @param string $paramid Name of parameter to use to name the id into the URL link * @param string $paramid Name of parameter to use to name the id into the URL next/previous link
* @param string $morehtml More html content to output just before the nav bar * @param string $morehtml More html content to output just before the nav bar
* @param int $shownav Show Condition (navigation is shown if value is 1) * @param int $shownav Show Condition (navigation is shown if value is 1)
* @param string $fieldid Nom du champ en base a utiliser pour select next et previous (we make the select max and min on this field) * @param string $fieldid Nom du champ en base a utiliser pour select next et previous (we make the select max and min on this field)
@ -5192,7 +5209,7 @@ class Form
$ret.='<div class="inline-block floatleft valignmiddle refid'.(($shownav && ($previous_ref || $next_ref))?' refidpadding':'').'">'; $ret.='<div class="inline-block floatleft valignmiddle refid'.(($shownav && ($previous_ref || $next_ref))?' refidpadding':'').'">';
// For thirdparty and contact, the ref is he id, so we show something else // For thirdparty and contact, the ref is the id, so we show something else
if ($object->element == 'societe') if ($object->element == 'societe')
{ {
$ret.=dol_htmlentities($object->name); $ret.=dol_htmlentities($object->name);
@ -5360,7 +5377,7 @@ class Form
else else
{ {
$nophoto='/public/theme/common/nophoto.png'; $nophoto='/public/theme/common/nophoto.png';
if (in_array($modulepart,array('userphoto','contact'))) // For module thar are "physical" users if (in_array($modulepart,array('userphoto','contact'))) // For module that are "physical" users
{ {
$nophoto='/public/theme/common/user_anonymous.png'; $nophoto='/public/theme/common/user_anonymous.png';
if ($object->gender == 'man') $nophoto='/public/theme/common/user_man.png'; if ($object->gender == 'man') $nophoto='/public/theme/common/user_man.png';

View File

@ -52,16 +52,13 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
// Remove product id before select another product // Remove product id before select another product
// use keyup instead change to avoid loosing the product id // use keyup instead change to avoid loosing the product id
$("input#search_'.$htmlname.'").keydown(function() { $("input#search_'.$htmlname.'").keydown(function() {
//console.log(\'purge_id_after_keydown\');
$("#'.$htmlname.'").val(""); $("#'.$htmlname.'").val("");
}); });
$("input#search_'.$htmlname.'").change(function() { $("input#search_'.$htmlname.'").change(function() {
//console.log(\'change\');
$("#'.$htmlname.'").trigger("change"); $("#'.$htmlname.'").trigger("change");
}); });
// Check when keyup // Check when keyup
$("input#search_'.$htmlname.'").keyup(function() { $("input#search_'.$htmlname.'").keyup(function() {
//console.log(\'keyup\');
if ($(this).val().length == 0) if ($(this).val().length == 0)
{ {
$("#search_'.$htmlname.'").val(""); $("#search_'.$htmlname.'").val("");
@ -127,7 +124,6 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
dataType: "json", dataType: "json",
minLength: '.$minLength.', minLength: '.$minLength.',
select: function( event, ui ) { // Function ran when new value is selected into javascript combo select: function( event, ui ) { // Function ran when new value is selected into javascript combo
//console.log(\'set value of id with \'+ui.item.id);
$("#'.$htmlname.'").val(ui.item.id).trigger("change"); // Select new value $("#'.$htmlname.'").val(ui.item.id).trigger("change"); // Select new value
// Disable an element // Disable an element
if (options.option_disabled) { if (options.option_disabled) {
@ -171,8 +167,6 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
} }
}); });
} }
console.log("ajax_autocompleter new value selected, we trigger change");
$("#search_'.$htmlname.'").trigger("change"); // To tell that input text field was modified
} }
,delay: 500 ,delay: 500
}).data("ui-autocomplete")._renderItem = function( ul, item ) { }).data("ui-autocomplete")._renderItem = function( ul, item ) {

View File

@ -106,7 +106,7 @@ function doc_getlinedesc($line,$outputlangs,$hideref=0,$hidedesc=0,$issupplierli
$ref_prodserv = ""; $ref_prodserv = "";
if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this
{ {
if ($prodser->isservice()) if ($prodser->isService())
{ {
$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." "; $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." ";
} }

View File

@ -854,7 +854,7 @@ function dol_get_fiche_end($notab=0)
* Show tab footer of a card * Show tab footer of a card
* *
* @param object $object Object to show * @param object $object Object to show
* @param string $paramid Name of parameter to use to name the id into the URL link * @param string $paramid Name of parameter to use to name the id into the URL next/previous link
* @param string $morehtml More html content to output just before the nav bar * @param string $morehtml More html content to output just before the nav bar
* @param int $shownav Show Condition (navigation is shown if value is 1) * @param int $shownav Show Condition (navigation is shown if value is 1)
* @param string $fieldid Nom du champ en base a utiliser pour select next et previous (we make the select max and min on this field) * @param string $fieldid Nom du champ en base a utiliser pour select next et previous (we make the select max and min on this field)
@ -870,28 +870,67 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
{ {
global $conf, $form, $user, $langs; global $conf, $form, $user, $langs;
//$showlogo=$object->logo; $maxvisiblephotos=1;
$showlogo=1; $showimage=1;
$showbarcode=empty($conf->barcode->enabled)?0:($object->barcode?1:0); $showbarcode=empty($conf->barcode->enabled)?0:($object->barcode?1:0);
if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0;
$modulepart='societe'; $modulepart='unknown';
if ($object->element == 'societe') $modulepart='societe';
if ($object->element == 'contact') $modulepart='contact'; if ($object->element == 'contact') $modulepart='contact';
if ($object->element == 'member') $modulepart='memberphoto'; if ($object->element == 'member') $modulepart='memberphoto';
if ($object->element == 'user') $modulepart='userphoto'; if ($object->element == 'user') $modulepart='userphoto';
if ($object->element == 'product') $modulepart='product';
print '<div class="arearef heightref valignmiddle" width="100%">'; print '<div class="arearef heightref valignmiddle" width="100%">';
if ($showlogo) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showphoto($modulepart,$object,0,0,0,'photoref').'</div>'; if ($object->element == 'product')
{
$width=80; $cssclass='photoref';
$showimage=$object->is_photo_available($conf->product->multidir_output[$object->entity]);
$maxvisiblephotos=(isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO)?$conf->global->PRODUCT_MAX_VISIBLE_PHOTO:5);
if ($conf->browser->phone) $maxvisiblephotos=1;
if ($showimage) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos($conf->product->multidir_output[$object->entity],1,-$maxvisiblephotos,0,0,0,$width,0).'</div>';
else
{
$nophoto='/public/theme/common/nophoto.png';
$morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo'.$modulepart.($cssclass?' '.$cssclass:'').'" alt="No photo" border="0"'.($width?' width="'.$width.'"':'').($height?' height="'.$height.'"':'').' src="'.DOL_URL_ROOT.$nophoto.'"></div>';
}
}
else
{
if ($showimage) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showphoto($modulepart,$object,0,0,0,'photoref','',1,0,$maxvisiblephotos).'</div>';
}
if ($showbarcode) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode($object).'</div>'; if ($showbarcode) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode($object).'</div>';
if ($object->element == 'societe' && ! empty($conf->use_javascript_ajax) && $user->rights->societe->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { if ($object->element == 'societe' && ! empty($conf->use_javascript_ajax) && $user->rights->societe->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
$morehtmlright.=ajax_object_onoff($object, 'status', 'status', 'InActivity', 'ActivityCeased'); $morehtmlright.=ajax_object_onoff($object, 'status', 'status', 'InActivity', 'ActivityCeased');
}
elseif ($object->element == 'product')
{
//$morehtmlright.=$langs->trans("Status").' ('.$langs->trans("Sell").') ';
if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
$morehtmlright.=ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell');
} else { } else {
$morehtmlright.=$object->getLibStatut(2,0);
}
$morehtmlright.=' &nbsp; ';
//$morehtmlright.=$langs->trans("Status").' ('.$langs->trans("Buy").') ';
if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
$morehtmlright.=ajax_object_onoff($object, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy');
} else {
$morehtmlright.=$object->getLibStatut(2,1);
}
}
else {
$morehtmlright.=$object->getLibStatut(2); $morehtmlright.=$object->getLibStatut(2);
} }
if (! empty($object->name_alias)) $morehtmlref.='<div class="refidno">'.$object->name_alias.'</div>'; if (! empty($object->name_alias)) $morehtmlref.='<div class="refidno">'.$object->name_alias.'</div>'; // For thirdparty
if (! empty($object->label)) $morehtmlref.='<div class="refidno">'.$object->label.'</div>'; // For product
if ($object->element != 'product')
{
$morehtmlref.='<div class="refidno">'; $morehtmlref.='<div class="refidno">';
$morehtmlref.=$object->getBannerAddress('refaddress',$object); $morehtmlref.=$object->getBannerAddress('refaddress',$object);
$morehtmlref.='</div>'; $morehtmlref.='</div>';
if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && in_array($object->element, array('societe', 'contact', 'member'))) }
if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && in_array($object->element, array('societe', 'contact', 'member', 'product')))
{ {
$morehtmlref.='<div style="clear: both;"></div><div class="refidno">'; $morehtmlref.='<div style="clear: both;"></div><div class="refidno">';
$morehtmlref.=$langs->trans("TechnicalID").': '.$object->id; $morehtmlref.=$langs->trans("TechnicalID").': '.$object->id;
@ -5154,6 +5193,10 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0)
{ {
global $db,$langs; global $db,$langs;
if ($mode == 0)
{
$value=preg_replace('/\*/','%',$value); // Replace * with %
}
if ($mode == 1) if ($mode == 1)
{ {
$value=preg_replace('/([<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do $value=preg_replace('/([<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do
@ -5225,17 +5268,17 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0)
/** /**
* Return the filename of file to get the thumbs * Return the filename of file to get the thumbs
* *
* @param string $file Original filename * @param string $file Original filename (full or relative path)
* @param string $extName Extension to differenciate thumb file name ('', '_small', '_mini') * @param string $extName Extension to differenciate thumb file name ('', '_small', '_mini')
* @param string $extImgTarget Force image format for thumbs. Use '' to keep same extension than original image. * @param string $extImgTarget Force image extension for thumbs. Use '' to keep same extension than original image.
* @return string New file name * @return string New file name (full or relative path, including the thumbs/)
*/ */
function getImageFileNameForSize($file, $extName, $extImgTarget='') function getImageFileNameForSize($file, $extName, $extImgTarget='')
{ {
$dirName = dirname($file); $dirName = dirname($file);
if ($dirName == '.') $dirName=''; if ($dirName == '.') $dirName='';
$fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // On enleve extension quelquesoit la casse $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // We remove extension, whatever is its case
$fileName = basename($fileName); $fileName = basename($fileName);
if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.jpg$/i',$file)?'.jpg':''); if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.jpg$/i',$file)?'.jpg':'');
@ -5249,5 +5292,5 @@ function getImageFileNameForSize($file, $extName, $extImgTarget='')
$subdir=''; $subdir='';
if ($extName) $subdir = 'thumbs/'; if ($extName) $subdir = 'thumbs/';
return $dirName.$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb return ($dirName?$dirName.'/':'').$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb
} }

View File

@ -101,7 +101,7 @@ function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addhea
curl_setopt($ch, CURLOPT_POST, 0); // GET curl_setopt($ch, CURLOPT_POST, 0); // GET
} }
//if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled. //if USE_PROXY constant set at begin of this method.
if ($USE_PROXY) if ($USE_PROXY)
{ {
dol_syslog("getURLContent set proxy to ".$PROXY_HOST. ":" . $PROXY_PORT." - ".$PROXY_USER. ":" . $PROXY_PASS); dol_syslog("getURLContent set proxy to ".$PROXY_HOST. ":" . $PROXY_PORT." - ".$PROXY_USER. ":" . $PROXY_PASS);

View File

@ -512,7 +512,9 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $
$fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // On enleve extension quelquesoit la casse $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // On enleve extension quelquesoit la casse
$fileName = basename($fileName); $fileName = basename($fileName);
$imgThumbName = $dirthumb.'/'.getImageFileNameForSize($file, $extName, $extImgTarget); // Chemin complet du fichier de la vignette //$imgThumbName = $dirthumb.'/'.getImageFileNameForSize(basename($file), $extName, $extImgTarget); // Full path of thumb file
$imgThumbName = getImageFileNameForSize($file, $extName, $extImgTarget); // Full path of thumb file
// Check if permission are ok // Check if permission are ok
//$fp = fopen($imgThumbName, "w"); //$fp = fopen($imgThumbName, "w");

View File

@ -1166,7 +1166,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
$ref_prodserv = ""; $ref_prodserv = "";
if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this
{ {
if ($prodser->isservice()) if ($prodser->isService())
{ {
$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." "; $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." ";
} }

View File

@ -98,7 +98,7 @@ function product_prepare_head($object)
$head[$h][2] = 'referers'; $head[$h][2] = 'referers';
$h++; $h++;
if ($object->isproduct() || ($object->isservice() && ! empty($conf->global->STOCK_SUPPORTS_SERVICES))) // If physical product we can stock (or service with option) if ($object->isProduct() || ($object->isService() && ! empty($conf->global->STOCK_SUPPORTS_SERVICES))) // If physical product we can stock (or service with option)
{ {
if (! empty($conf->stock->enabled) && $user->rights->stock->lire) if (! empty($conf->stock->enabled) && $user->rights->stock->lire)
{ {

View File

@ -98,12 +98,12 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->product->enabled', __HANDLER__, 'left', 2802__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/list.php?leftmenu=product&amp;type=0', 'List', 1, 'products', '$user->rights->produit->lire', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->product->enabled', __HANDLER__, 'left', 2802__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/list.php?leftmenu=product&amp;type=0', 'List', 1, 'products', '$user->rights->produit->lire', '', 2, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->product->enabled', __HANDLER__, 'left', 2803__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/reassort.php?type=0', 'Stocks', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 4, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->product->enabled', __HANDLER__, 'left', 2803__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/reassort.php?type=0', 'Stocks', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 4, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->productbatch->enabled', __HANDLER__, 'left', 2805__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/reassortlot.php?type=0', 'StocksByLotSerial', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 5, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->productbatch->enabled', __HANDLER__, 'left', 2805__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/reassortlot.php?type=0', 'StocksByLotSerial', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 5, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2804__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/popuprop.php?leftmenu=stats&amp;type=0', 'Statistics', 1, 'main', '$user->rights->produit->lire', '', 2, 6, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2804__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/stats/card.php?id=all&amp;leftmenu=stats&amp;type=0', 'Statistics', 1, 'main', '$user->rights->produit->lire', '', 2, 6, __ENTITY__);
-- Product - Services -- Product - Services
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2900__+MAX_llx_menu__, 'products', 'service', 3__+MAX_llx_menu__, '/product/index.php?leftmenu=service&amp;type=1', 'Services', 0, 'products', '$user->rights->service->lire', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2900__+MAX_llx_menu__, 'products', 'service', 3__+MAX_llx_menu__, '/product/index.php?leftmenu=service&amp;type=1', 'Services', 0, 'products', '$user->rights->service->lire', '', 2, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2901__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/card.php?leftmenu=service&amp;action=create&amp;type=1', 'NewService', 1, 'products', '$user->rights->service->creer', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2901__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/card.php?leftmenu=service&amp;action=create&amp;type=1', 'NewService', 1, 'products', '$user->rights->service->creer', '', 2, 0, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2902__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/list.php?leftmenu=service&amp;type=1', 'List', 1, 'products', '$user->rights->service->lire', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2902__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/list.php?leftmenu=service&amp;type=1', 'List', 1, 'products', '$user->rights->service->lire', '', 2, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2903__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/popuprop.php?leftmenu=stats&amp;type=1', 'Statistics', 1, 'main', '$user->rights->service->lire', '', 2, 5, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2903__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/stats/card.php?id=all&amp;leftmenu=stats&amp;type=1', 'Statistics', 1, 'main', '$user->rights->service->lire', '', 2, 5, __ENTITY__);
-- Product - Stocks -- Product - Stocks
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->stock->enabled', __HANDLER__, 'left', 3100__+MAX_llx_menu__, 'products', 'stock', 3__+MAX_llx_menu__, '/product/stock/index.php?leftmenu=stock', 'Stock', 0, 'stocks', '$user->rights->stock->lire', '', 2, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->stock->enabled', __HANDLER__, 'left', 3100__+MAX_llx_menu__, 'products', 'stock', 3__+MAX_llx_menu__, '/product/stock/index.php?leftmenu=stock', 'Stock', 0, 'stocks', '$user->rights->stock->lire', '', 2, 3, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->stock->enabled', __HANDLER__, 'left', 3101__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/card.php?action=create', 'MenuNewWarehouse', 1, 'stocks', '$user->rights->stock->creer', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->stock->enabled', __HANDLER__, 'left', 3101__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/card.php?action=create', 'MenuNewWarehouse', 1, 'stocks', '$user->rights->stock->creer', '', 2, 0, __ENTITY__);

View File

@ -1088,7 +1088,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
} }
if (! empty($conf->propal->enabled)) if (! empty($conf->propal->enabled))
{ {
$newmenu->add("/product/popuprop.php?leftmenu=stats&amp;type=0", $langs->trans("Statistics"), 1, $user->rights->produit->lire && $user->rights->propale->lire); $newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=0", $langs->trans("Statistics"), 1, $user->rights->produit->lire && $user->rights->propale->lire);
} }
} }
@ -1100,7 +1100,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
$newmenu->add("/product/list.php?leftmenu=service&amp;type=1", $langs->trans("List"), 1, $user->rights->service->lire); $newmenu->add("/product/list.php?leftmenu=service&amp;type=1", $langs->trans("List"), 1, $user->rights->service->lire);
if (! empty($conf->propal->enabled)) if (! empty($conf->propal->enabled))
{ {
$newmenu->add("/product/popuprop.php?leftmenu=stats&amp;type=1", $langs->trans("Statistics"), 1, $user->rights->service->lire && $user->rights->propale->lire); $newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=1", $langs->trans("Statistics"), 1, $user->rights->service->lire && $user->rights->propale->lire);
} }
} }

View File

@ -64,7 +64,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac
{ {
$moduleid=$reg[1]; $moduleid=$reg[1];
// Chargement de la classe // Loading Class
$file = $dir."/export_".$moduleid.".modules.php"; $file = $dir."/export_".$moduleid.".modules.php";
$classname = "Export".ucfirst($moduleid); $classname = "Export".ucfirst($moduleid);

View File

@ -84,7 +84,7 @@ class ModeleImports
{ {
$moduleid=$reg[1]; $moduleid=$reg[1];
// Chargement de la classe // Loading Class
$file = $dir."/import_".$moduleid.".modules.php"; $file = $dir."/import_".$moduleid.".modules.php";
$classname = "Import".ucfirst($moduleid); $classname = "Import".ucfirst($moduleid);

View File

@ -51,7 +51,7 @@ class modOauth extends DolibarrModules
$this->name = preg_replace('/^mod/i','',get_class($this)); $this->name = preg_replace('/^mod/i','',get_class($this));
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
$this->description = "Enable OAuth authentication"; $this->description = "Enable OAuth authentication";
$this->version = 'development'; // 'development' or 'experimental' or 'dolibarr' or version $this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
$this->special = 1; $this->special = 1;

View File

@ -30,14 +30,25 @@ use OAuth\Common\Consumer\Credentials;
use OAuth\Common\Token\TokenInterface; use OAuth\Common\Token\TokenInterface;
use OAuth\OAuth2\Service\Google; use OAuth\OAuth2\Service\Google;
// 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
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$backtourl = GETPOST('backtourl', 'alpha');
/** /**
* Create a new instance of the URI class with the current URI, stripping the query string * Create a new instance of the URI class with the current URI, stripping the query string
*/ */
$uriFactory = new \OAuth\Common\Http\Uri\UriFactory(); $uriFactory = new \OAuth\Common\Http\Uri\UriFactory();
$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER); //$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER);
$currentUri->setQuery(''); //$currentUri->setQuery('');
$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php');
/** /**
* Load the credential for the service * Load the credential for the service
@ -45,8 +56,15 @@ $currentUri->setQuery('');
/** @var $serviceFactory \OAuth\ServiceFactory An OAuth service factory. */ /** @var $serviceFactory \OAuth\ServiceFactory An OAuth service factory. */
$serviceFactory = new \OAuth\ServiceFactory(); $serviceFactory = new \OAuth\ServiceFactory();
$httpClient = new \OAuth\Common\Http\Client\CurlClient();
// TODO Set options for proxy and timeout
// $params=array('CURLXXX'=>value, ...)
//$httpClient->setCurlParameters($params);
$serviceFactory->setHttpClient($httpClient);
// Dolibarr storage // Dolibarr storage
$storage = new DoliStorage($db, $conf); $storage = new DoliStorage($db, $conf);
// Setup the credentials for the requests // Setup the credentials for the requests
$credentials = new Credentials( $credentials = new Credentials(
$conf->global->OAUTH_GOOGLE_ID, $conf->global->OAUTH_GOOGLE_ID,
@ -54,6 +72,7 @@ $credentials = new Credentials(
$currentUri->getAbsoluteUri() $currentUri->getAbsoluteUri()
); );
// Instantiate the Api service using the credentials, http client and storage mechanism for the token // Instantiate the Api service using the credentials, http client and storage mechanism for the token
/** @var $apiService Service */ /** @var $apiService Service */
// TODO remove hardcoded array // TODO remove hardcoded array
@ -61,80 +80,71 @@ $apiService = $serviceFactory->createService('Google', $credentials, $storage, a
// access type needed for google refresh token // access type needed for google refresh token
$apiService->setAccessType('offline'); $apiService->setAccessType('offline');
if ($action == 'delete') {
// delete token
llxHeader('',$langs->trans("OAuthSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; $langs->load("oauth");
print load_fiche_titre($langs->trans("OAuthSetup"),$linkback,'title_setup');
dol_fiche_head();
/*
* Actions
*/
if ($action == 'delete')
{
$storage->clearToken('Google'); $storage->clearToken('Google');
dol_fiche_end();
setEventMessages($langs->trans('TokenDeleted'), null, 'mesgs');
} elseif (! empty($_GET['code'])) { header('Location: ' . $backtourl);
llxHeader('',$langs->trans("OAuthSetup")); exit();
}
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; if (! empty($_GET['code'])) // We are coming from Google oauth page
print load_fiche_titre($langs->trans("OAuthSetup"),$linkback,'title_setup'); {
//llxHeader('',$langs->trans("OAuthSetup"));
dol_fiche_head(); //$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
//print load_fiche_titre($langs->trans("OAuthSetup"),$linkback,'title_setup');
//dol_fiche_head();
// retrieve the CSRF state parameter // retrieve the CSRF state parameter
$state = isset($_GET['state']) ? $_GET['state'] : null; $state = isset($_GET['state']) ? $_GET['state'] : null;
print '<table>'; //print '<table>';
// looking for a token already stored in db
//try {
// $token = $storage->retrieveAccessToken('Google');
// $old_token=1;
//} catch (Exception $e) {
// $old_token=0;
//}
//if ($old_token==1) {
// print '<tr><td>'.$langs->trans('OldTokenStored').'</td><td></td></tr>';
// print '<tr><td><pre>'.print_r($token,true).'</pre></td></tr>';
//}
//$refreshtoken = $token->getRefreshToken();
// This was a callback request from service, get the token // This was a callback request from service, get the token
try { try {
$apiService->requestAccessToken($_GET['code'], $state); //var_dump($_GET['code']);
//var_dump($state);
//var_dump($apiService); // OAuth\OAuth2\Service\Google
$token = $apiService->requestAccessToken($_GET['code'], $state);
setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs');
} catch (Exception $e) { } catch (Exception $e) {
print $e->getMessage(); print $e->getMessage();
} }
//print '<pre>'.print_r($apiService,true).'</pre>';
// retrieve new token in db $backtourl = $_SESSION["backtourlsavedbeforeoauthjump"];
try { unset($_SESSION["backtourlsavedbeforeoauthjump"]);
$token = $storage->retrieveAccessToken('Google');
$new_token=1; header('Location: ' . $backtourl);
} catch (Exception $e) { exit();
$new_token=0; }
} else
$newrefreshtoken = $token->getRefreshToken(); {
if (empty($newrefreshtoken) && ! empty($refreshtoken)) { $_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl;
$token->setRefreshToken($refreshtoken);
$storage->storeAccessToken('Google', $token);
}
if ($new_token==1) {
print '<tr><td>'.$langs->trans('NewTokenStored').'</td><td></td></tr>';
print '<tr><td><pre>'.print_r($token,true).'</pre></td></tr>';
}
//print '<td><pre>'.print_r($token,true).'</pre></td>';
//$apiService->refreshAccessToken($token);
//print '<pre>'.print_r($apiService,true).'</pre>';
//$token = $storage->retrieveAccessToken('Google');
//print '<td><pre>'.print_r($token,true).'</pre></td>';
print '<td><a href="https://security.google.com/settings/security/permissions" target="_blank">Applications associées à votre compte</a></td>';
print '</table>';
dol_fiche_end();
} else {
$url = $apiService->getAuthorizationUri(); $url = $apiService->getAuthorizationUri();
// we go on google authorization page // we go on google authorization page
header('Location: ' . $url); header('Location: ' . $url);
exit(); exit();
} }
llxFooter();
/*
* View
*/
// No view at all, just actions
$db->close(); $db->close();

View File

@ -87,6 +87,8 @@ class printing_printgcp extends PrintingDriver
$this->errors[] = $e->getMessage(); $this->errors[] = $e->getMessage();
$token_ok = false; $token_ok = false;
} }
//var_dump($this->errors);exit;
$expire = false; $expire = false;
// Is token expired or will token expire in the next 30 seconds // Is token expired or will token expire in the next 30 seconds
if ($token_ok) { if ($token_ok) {
@ -116,12 +118,12 @@ class printing_printgcp extends PrintingDriver
$refreshtoken = $token->getRefreshToken(); $refreshtoken = $token->getRefreshToken();
$this->conf[] = array('varname'=>'PRINTGCP_TOKEN_REFRESH', 'info'=>((! empty($refreshtoken))?'Yes':'No'), 'type'=>'info'); $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_REFRESH', 'info'=>((! empty($refreshtoken))?'Yes':'No'), 'type'=>'info');
$this->conf[] = array('varname'=>'PRINTGCP_TOKEN_EXPIRED', 'info'=>($expire?'Yes':'No'), 'type'=>'info'); $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_EXPIRED', 'info'=>($expire?'Yes':'No'), 'type'=>'info');
$this->conf[] = array('varname'=>'PRINTGCP_TOKEN_EXPIRE_AT', 'info'=>(date("Y-m-d H:i:s", $token->getEndOfLife())), 'type'=>'info'); $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_EXPIRE_AT', 'info'=>(dol_print_date($token->getEndOfLife(), "dayhour")), 'type'=>'info');
} }
if (!$storage->hasAccessToken('Google')) { if (!$storage->hasAccessToken('Google')) {
$this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php', 'type'=>'authlink'); $this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'authlink');
} else { } else {
$this->conf[] = array('varname'=>'PRINTGCP_DELETE_TOKEN', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?action=delete', 'type'=>'delete'); $this->conf[] = array('varname'=>'PRINTGCP_DELETE_TOKEN', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'delete');
} }
} else { } else {
$this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthNotConfigured', 'type'=>'info'); $this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthNotConfigured', 'type'=>'info');

View File

@ -94,8 +94,8 @@ class pdf_beluga extends ModelePDFProjects
$this->posxref=$this->marge_gauche+1; $this->posxref=$this->marge_gauche+1;
$this->posxdate=$this->marge_gauche+25; $this->posxdate=$this->marge_gauche+25;
$this->posxsociety=$this->marge_gauche+45; $this->posxsociety=$this->marge_gauche+45;
$this->posxamountht=$this->marge_gauche+115; $this->posxamountht=$this->marge_gauche+110;
$this->posxamountttc=$this->marge_gauche+140; $this->posxamountttc=$this->marge_gauche+135;
$this->posxstatut=$this->marge_gauche+165; $this->posxstatut=$this->marge_gauche+165;
} }
@ -231,14 +231,16 @@ class pdf_beluga extends ModelePDFProjects
'class'=>'Propal', 'class'=>'Propal',
'table'=>'propal', 'table'=>'propal',
'datefieldname'=>'datep', 'datefieldname'=>'datep',
'test'=>$conf->propal->enabled && $user->rights->propale->lire), 'test'=>$conf->propal->enabled && $user->rights->propale->lire,
'lang'=>'propal'),
'order'=>array( 'order'=>array(
'name'=>"CustomersOrders", 'name'=>"CustomersOrders",
'title'=>"ListOrdersAssociatedProject", 'title'=>"ListOrdersAssociatedProject",
'class'=>'Commande', 'class'=>'Commande',
'table'=>'commande', 'table'=>'commande',
'datefieldname'=>'date_commande', 'datefieldname'=>'date_commande',
'test'=>$conf->commande->enabled && $user->rights->commande->lire), 'test'=>$conf->commande->enabled && $user->rights->commande->lire,
'lang'=>'order'),
'invoice'=>array( 'invoice'=>array(
'name'=>"CustomersInvoices", 'name'=>"CustomersInvoices",
'title'=>"ListInvoicesAssociatedProject", 'title'=>"ListInvoicesAssociatedProject",
@ -246,21 +248,24 @@ class pdf_beluga extends ModelePDFProjects
'margin'=>'add', 'margin'=>'add',
'table'=>'facture', 'table'=>'facture',
'datefieldname'=>'datef', 'datefieldname'=>'datef',
'test'=>$conf->facture->enabled && $user->rights->facture->lire), 'test'=>$conf->facture->enabled && $user->rights->facture->lire,
'lang'=>'bills'),
'invoice_predefined'=>array( 'invoice_predefined'=>array(
'name'=>"PredefinedInvoices", 'name'=>"PredefinedInvoices",
'title'=>"ListPredefinedInvoicesAssociatedProject", 'title'=>"ListPredefinedInvoicesAssociatedProject",
'class'=>'FactureRec', 'class'=>'FactureRec',
'table'=>'facture_rec', 'table'=>'facture_rec',
'datefieldname'=>'datec', 'datefieldname'=>'datec',
'test'=>$conf->facture->enabled && $user->rights->facture->lire), 'test'=>$conf->facture->enabled && $user->rights->facture->lire,
'lang'=>'bills'),
'order_supplier'=>array( 'order_supplier'=>array(
'name'=>"SuppliersOrders", 'name'=>"SuppliersOrders",
'title'=>"ListSupplierOrdersAssociatedProject", 'title'=>"ListSupplierOrdersAssociatedProject",
'class'=>'CommandeFournisseur', 'class'=>'CommandeFournisseur',
'table'=>'commande_fournisseur', 'table'=>'commande_fournisseur',
'datefieldname'=>'date_commande', 'datefieldname'=>'date_commande',
'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire), 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire,
'lang'=>'orders'),
'invoice_supplier'=>array( 'invoice_supplier'=>array(
'name'=>"BillsSuppliers", 'name'=>"BillsSuppliers",
'title'=>"ListSupplierInvoicesAssociatedProject", 'title'=>"ListSupplierInvoicesAssociatedProject",
@ -268,14 +273,16 @@ class pdf_beluga extends ModelePDFProjects
'margin'=>'minus', 'margin'=>'minus',
'table'=>'facture_fourn', 'table'=>'facture_fourn',
'datefieldname'=>'datef', 'datefieldname'=>'datef',
'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire), 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire,
'lang'=>'bills'),
'contract'=>array( 'contract'=>array(
'name'=>"Contracts", 'name'=>"Contracts",
'title'=>"ListContractAssociatedProject", 'title'=>"ListContractAssociatedProject",
'class'=>'Contrat', 'class'=>'Contrat',
'table'=>'contrat', 'table'=>'contrat',
'datefieldname'=>'date_contrat', 'datefieldname'=>'date_contrat',
'test'=>$conf->contrat->enabled && $user->rights->contrat->lire), 'test'=>$conf->contrat->enabled && $user->rights->contrat->lire,
'lang'=>'contract'),
'intervention'=>array( 'intervention'=>array(
'name'=>"Interventions", 'name'=>"Interventions",
'title'=>"ListFichinterAssociatedProject", 'title'=>"ListFichinterAssociatedProject",
@ -283,7 +290,8 @@ class pdf_beluga extends ModelePDFProjects
'table'=>'fichinter', 'table'=>'fichinter',
'datefieldname'=>'date_valid', 'datefieldname'=>'date_valid',
'disableamount'=>1, 'disableamount'=>1,
'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire), 'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire,
'lang'=>'interventions'),
'trip'=>array( 'trip'=>array(
'name'=>"TripsAndExpenses", 'name'=>"TripsAndExpenses",
'title'=>"ListTripAssociatedProject", 'title'=>"ListTripAssociatedProject",
@ -292,7 +300,18 @@ class pdf_beluga extends ModelePDFProjects
'datefieldname'=>'dated', 'datefieldname'=>'dated',
'margin'=>'minus', 'margin'=>'minus',
'disableamount'=>1, 'disableamount'=>1,
'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire), 'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire,
'lang'=>'trip'),
'expensereport'=>array(
'name'=>"ExpensesReports",
'title'=>"ListTripAssociatedProject",
'class'=>'ExpenseReport',
'table'=>'expensereport',
'datefieldname'=>'dated',
'margin'=>'minus',
'disableamount'=>1,
'test'=>$conf->expensereport->enabled && $user->rights->expensereport->lire,
'lang'=>'trip'),
'agenda'=>array( 'agenda'=>array(
'name'=>"Agenda", 'name'=>"Agenda",
'title'=>"ListActionsAssociatedProject", 'title'=>"ListActionsAssociatedProject",
@ -300,7 +319,8 @@ class pdf_beluga extends ModelePDFProjects
'table'=>'actioncomm', 'table'=>'actioncomm',
'datefieldname'=>'datep', 'datefieldname'=>'datep',
'disableamount'=>1, 'disableamount'=>1,
'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->lire) 'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->read,
'lang'=>'agenda')
); );
@ -311,12 +331,17 @@ class pdf_beluga extends ModelePDFProjects
$tablename=$value['table']; $tablename=$value['table'];
$datefieldname=$value['datefieldname']; $datefieldname=$value['datefieldname'];
$qualified=$value['test']; $qualified=$value['test'];
$langstoload=$value['lang'];
$langs->load($langstoload);
if ($qualified) if ($qualified)
{ {
//var_dump("$key, $tablename, $datefieldname, $dates, $datee");
$elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee); $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee);
//var_dump($elementarray);
$num = count($elementarray); $num = count($elementarray);
if ($num > 0) if ($num >= 0)
{ {
$nexY = $pdf->GetY() + 5; $nexY = $pdf->GetY() + 5;
$curY = $nexY; $curY = $nexY;
@ -334,9 +359,9 @@ class pdf_beluga extends ModelePDFProjects
$pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $outputlangs->transnoentities("ThirdParty"), 1, 'L'); $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $outputlangs->transnoentities("ThirdParty"), 1, 'L');
if (empty($value['disableamount'])) { if (empty($value['disableamount'])) {
$pdf->SetXY($this->posxamountht, $curY); $pdf->SetXY($this->posxamountht, $curY);
$pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, $outputlangs->transnoentities("AmountHT"), 1, 'R'); $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, $outputlangs->transnoentities("AmountHTShort"), 1, 'R');
$pdf->SetXY($this->posxamountttc, $curY); $pdf->SetXY($this->posxamountttc, $curY);
$pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, $outputlangs->transnoentities("AmountTTC"), 1, 'R'); $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, $outputlangs->transnoentities("AmountTTCShort"), 1, 'R');
} else { } else {
$pdf->SetXY($this->posxamountht, $curY); $pdf->SetXY($this->posxamountht, $curY);
$pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R'); $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R');
@ -434,8 +459,6 @@ class pdf_beluga extends ModelePDFProjects
} }
} }
/* /*
* Pied de page * Pied de page
*/ */

View File

@ -5,6 +5,7 @@
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@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
@ -315,14 +316,39 @@ else {
<?php <?php
if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required
{ {
if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10; $colspan = 6;
else $colspan = 9;
if($this->situation_cycle_ref) $colspan++; if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc $colspan++;
if (in_array($object->element,array('propal','askpricesupplier','facture','invoice','commande','order','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button }
if ($this->situation_cycle_ref) {
$colspan++;
}
// We add 1 if col total ttc
if (!empty($inputalsopricewithtax)) {
$colspan++;
}
if ($conf->global->PRODUCT_USE_UNITS) { if ($conf->global->PRODUCT_USE_UNITS) {
$colspan++; $colspan++;
} }
if (count($object->lines)) {
//There will be an edit and a delete button
$colspan += 2;
// With this, there is a column move button ONLY if lines > 1
if (in_array($object->element, array(
'propal',
'askpricesupplier',
'facture',
'invoice',
'commande',
'order',
'order_supplier',
'invoice_supplier'
))) {
$colspan++;
}
}
if (! empty($usemargins)) if (! empty($usemargins))
{ {
@ -497,7 +523,6 @@ jQuery(document).ready(function() {
/* When changing predefined product, we reload list of supplier prices */ /* When changing predefined product, we reload list of supplier prices */
$("#idprod, #idprodfournprice").change(function() $("#idprod, #idprodfournprice").change(function()
{ {
console.log("change #idprod, #idprodfournprice, conf->global->MARGIN_TYPE=<?php echo $conf->global->MARGIN_TYPE ?>");
setforpredef(); setforpredef();
jQuery('#trlinefordates').show(); jQuery('#trlinefordates').show();

View File

@ -107,7 +107,7 @@ class Export
if ($enabled) if ($enabled)
{ {
// Chargement de la classe // Loading Class
$file = $dir.$modulename.".class.php"; $file = $dir.$modulename.".class.php";
$classname = $modulename; $classname = $modulename;
require_once $file; require_once $file;

View File

@ -273,7 +273,7 @@ if ($resql)
if ($search_all) if ($search_all)
{ {
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
print $langs->trans("FilterOnInto", $search_all, join(', ',$fieldstosearchall)); print $langs->transnoentities("FilterOnInto", $search_all, join(', ',$fieldstosearchall));
} }
print '<table class="liste" width="100%">'; print '<table class="liste" width="100%">';

View File

@ -257,7 +257,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
$dateinvoice=($datefacture==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datefacture); $dateinvoice=($datefacture==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datefacture);
$sql = 'SELECT s.nom as name, s.rowid as socid,'; $sql = 'SELECT s.nom as name, s.rowid as socid,';
$sql.= ' f.rowid, f.ref, f.ref_supplier, f.amount, f.total_ttc as total'; $sql.= ' f.rowid, f.ref, f.ref_supplier, f.amount, f.total_ttc as total, fk_mode_reglement, fk_account';
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn as f'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn as f';
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@ -292,11 +292,11 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print $supplierstatic->getNomUrl(1,'supplier'); print $supplierstatic->getNomUrl(1,'supplier');
print '</td></tr>'; print '</td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td>'; print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td>';
$form->select_date($dateinvoice,'','','','',"addpaiement",1,1); $form->select_date($dateinvoice,'','','','',"addpaiement",1,1,0,0,'','',$object->date);
print '</td>'; print '</td>';
print '<td>'.$langs->trans('Comments').'</td></tr>'; print '<td>'.$langs->trans('Comments').'</td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans('PaymentMode').'</td><td>'; print '<tr><td class="fieldrequired">'.$langs->trans('PaymentMode').'</td><td>';
$form->select_types_paiements(empty($_POST['paiementid'])?'':$_POST['paiementid'],'paiementid'); $form->select_types_paiements(empty($_POST['paiementid'])?$obj->fk_mode_reglement:$_POST['paiementid'],'paiementid');
print '</td>'; print '</td>';
print '<td rowspan="3" valign="top">'; print '<td rowspan="3" valign="top">';
print '<textarea name="comment" wrap="soft" cols="60" rows="'.ROWS_3.'">'.(empty($_POST['comment'])?'':$_POST['comment']).'</textarea></td></tr>'; print '<textarea name="comment" wrap="soft" cols="60" rows="'.ROWS_3.'">'.(empty($_POST['comment'])?'':$_POST['comment']).'</textarea></td></tr>';
@ -304,7 +304,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
if (! empty($conf->banque->enabled)) if (! empty($conf->banque->enabled))
{ {
print '<tr><td class="fieldrequired">'.$langs->trans('Account').'</td><td>'; print '<tr><td class="fieldrequired">'.$langs->trans('Account').'</td><td>';
$form->select_comptes(empty($accountid)?'':$accountid,'accountid',0,'',2); $form->select_comptes(empty($accountid)?$obj->fk_account:$accountid,'accountid',0,'',2);
print '</td></tr>'; print '</td></tr>';
} }
else else

View File

@ -33,9 +33,13 @@ if (! $user->admin)
$error=0; $error=0;
$action = GETPOST('action', 'alpha'); // List of statut
static $tmpstatus2label=array(
$object = new Establishment($db); '0'=>'OpenEtablishment',
'1'=>'CloseEtablishment'
);
$status2label=array('');
foreach ($tmpstatus2label as $key => $val) $status2label[$key]=$langs->trans($val);
/* /*
* Actions * Actions
@ -44,10 +48,24 @@ $object = new Establishment($db);
/* /*
* View * View
*/ */
$page_name = "Establishments"; llxHeader('', $langs->trans("Establishments"));
llxHeader('', $langs->trans($page_name));
$sortorder = GETPOST("sortorder");
$sortfield = GETPOST("sortfield");
if (!$sortorder) $sortorder="DESC";
if (!$sortfield) $sortfield="e.rowid";
if ($page == -1) {
$page = 0 ;
}
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
$limit = $conf->liste_limit;
$form = new Form($db); $form = new Form($db);
$establishmenttmp=new Establishment($db);
dol_htmloutput_mesg($mesg); dol_htmloutput_mesg($mesg);
@ -62,43 +80,50 @@ dol_fiche_head($head, 'establishments', $langs->trans("HRM"), 0, "user");
$sql = "SELECT e.rowid, e.name, e.address, e.zip, e.town, e.status"; $sql = "SELECT e.rowid, e.name, e.address, e.zip, e.town, e.status";
$sql.= " FROM ".MAIN_DB_PREFIX."establishment as e"; $sql.= " FROM ".MAIN_DB_PREFIX."establishment as e";
$sql.= " WHERE e.entity = ".$conf->entity; $sql.= " WHERE e.entity = ".$conf->entity;
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($limit+1, $offset);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
$var=false;
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
// Load attribute_label // Load attribute_label
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print "<tr class=\"liste_titre\">";
print '<td>'.$langs->trans("Ref").'</td>'; print_liste_field_titre($langs->trans("Name"),$_SERVER["PHP_SELF"],"e.name","","","",$sortfield,$sortorder);
print '<td>'.$langs->trans("Name").'</td>'; print_liste_field_titre($langs->trans("Address"),$_SERVER["PHP_SELF"],"e.address","","","",$sortfield,$sortorder);
print '<td>'.$langs->trans("Address").'</td>'; print_liste_field_titre($langs->trans("Zipcode"),$_SERVER["PHP_SELF"],"e.zip","","","",$sortfield,$sortorder);
print '<td>'.$langs->trans("Zipcode").'</td>'; print_liste_field_titre($langs->trans("Town"),$_SERVER["PHP_SELF"],"e.town","","","",$sortfield,$sortorder);
print '<td>'.$langs->trans("Town").'</td>'; print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"e.status","","",'align="right"',$sortfield,$sortorder);
print '<td align="right">'.$langs->trans("Status").'</td>'; print "</tr>\n";
print '</tr>';
if ($num) $var=true;
if ($num > 0)
{ {
$establishmentstatic=new Establishment($db); $establishmentstatic=new Establishment($db);
while ($i < $num && $i < $max) while ($i < min($num,$limit))
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$fiscalyearstatic->id=$obj->rowid;
$establishmentstatic->id=$obj->rowid;
$establishmentstatic->name=$obj->name;
$var=!$var;
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
print '<td><a href="admin_establishment_card.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowEstablishment"),"building").' '.$obj->rowid.'</a></td>'; print '<td>'.$establishmentstatic->getNomUrl(1).'</td>';
print '<td align="left">'.$obj->name.'</td>';
print '<td align="left">'.$obj->address.'</td>'; print '<td align="left">'.$obj->address.'</td>';
print '<td align="left">'.$obj->zip.'</td>'; print '<td align="left">'.$obj->zip.'</td>';
print '<td align="left">'.$obj->town.'</td>'; print '<td align="left">'.$obj->town.'</td>';
print '<td align="right">'.$establishmentstatic->LibStatut($obj->status,5).'</td>';
print '</tr>'; print '<td align="right">';
$var=!$var; print $establishmenttmp->getLibStatus(5);
print '</td>';
print "</tr>\n";
$i++; $i++;
} }

View File

@ -67,26 +67,41 @@ class Employee extends CommonObject
* @param int $id Id of record to load * @param int $id Id of record to load
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function fetch($id) function fetch($id='')
{ {
$sql = "SELECT rowid, firstname, lastname, status, fk_user"; global $conf, $user;
$sql.= " FROM ".MAIN_DB_PREFIX."user";
$sql = "SELECT e.rowid, e.firstname, e.lastname, e.gender, e.email, e.statut, e.entity, e.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."user as e";
$sql.= " WHERE rowid = ".$id; $sql.= " WHERE rowid = ".$id;
dol_syslog(get_class($this)."::fetch", LOG_DEBUG); dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ( $result ) if ($result)
{ {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
if ($obj)
{
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->name = $obj->name; $this->lastname = $obj->lastname;
$this->firstname = $obj->firstname;
$this->gender = $obj->gender;
$this->address = $obj->address; $this->address = $obj->address;
$this->zip = $obj->zip; $this->zip = $obj->zip;
$this->town = $obj->town; $this->town = $obj->town;
$this->status = $obj->status; $this->statut = $obj->statut;
$this->photo = $obj->photo;
return 1; $this->db->free($result);
}
else
{
$this->error="EMPLOYEENOTFOUND";
dol_syslog(get_class($this)."::fetch user not found", LOG_DEBUG);
$this->db->free($result);
return 0;
}
} }
else else
{ {

View File

@ -34,6 +34,7 @@ class Establishment extends CommonObject
public $fk_element = 'fk_establishment'; public $fk_element = 'fk_establishment';
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
var $id;
var $rowid; var $rowid;
var $name; var $name;
@ -43,6 +44,8 @@ class Establishment extends CommonObject
var $status; // 0=open, 1=closed var $status; // 0=open, 1=closed
var $entity; var $entity;
var $country_id;
var $statuts=array(); var $statuts=array();
var $statuts_short=array(); var $statuts_short=array();
@ -69,12 +72,18 @@ class Establishment extends CommonObject
*/ */
function create($user) function create($user)
{ {
global $conf; global $conf, $langs;
$error = 0; $error = 0;
$ret = 0;
$now=dol_now(); $now=dol_now();
// Clean parameters
$this->address=($this->address>0?$this->address:$this->address);
$this->zip=($this->zip>0?$this->zip:$this->zip);
$this->town=($this->town>0?$this->town:$this->town);
$this->country_id=($this->country_id>0?$this->country_id:$this->country_id);
$this->db->begin(); $this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."establishment ("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."establishment (";
@ -83,22 +92,22 @@ class Establishment extends CommonObject
$sql.= ", zip"; $sql.= ", zip";
$sql.= ", town"; $sql.= ", town";
$sql.= ", status"; $sql.= ", status";
$sql.= ", fk_country";
$sql.= ", entity"; $sql.= ", entity";
$sql.= ", datec"; $sql.= ", datec";
$sql.= ", fk_user_author"; $sql.= ", fk_user_author";
$sql.= ") VALUES ("; $sql.= ") VALUES (";
$sql.= " '".$this->name."'"; $sql.= " '".$this->db->escape($this->name)."'";
$sql.= ", '".$this->address."'"; $sql.= ", '".$this->db->escape($this->address)."'";
$sql.= ", '".$this->zip."'"; $sql.= ", '".$this->db->escape($this->zip)."'";
$sql.= ", '".$this->town."'"; $sql.= ", '".$this->db->escape($this->town)."'";
$sql.= ", ".$this->country_id;
$sql.= ", ".$this->status; $sql.= ", ".$this->status;
$sql.= ", ".$conf->entity; $sql.= ", ".$conf->entity;
$sql.= ", '".$this->db->idate($now)."'"; $sql.= ", '".$this->db->idate($now)."'";
$sql.= ", ". $user->id; $sql.= ", ". $user->id;
$sql.= ")"; $sql.= ")";
$this->db->begin();
dol_syslog(get_class($this)."::create", LOG_DEBUG); dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { if (! $resql) {
@ -148,6 +157,7 @@ class Establishment extends CommonObject
$sql .= ", address = '".$this->address."'"; $sql .= ", address = '".$this->address."'";
$sql .= ", zip = '".$this->zip."'"; $sql .= ", zip = '".$this->zip."'";
$sql .= ", town = '".$this->town."'"; $sql .= ", town = '".$this->town."'";
$sql .= ", status = '".$this->status."'"; $sql .= ", status = '".$this->status."'";
$sql .= ", fk_user_mod = " . $user->id; $sql .= ", fk_user_mod = " . $user->id;
$sql .= " WHERE rowid = ".$this->id; $sql .= " WHERE rowid = ".$this->id;
@ -172,9 +182,11 @@ class Establishment extends CommonObject
*/ */
function fetch($id) function fetch($id)
{ {
$sql = "SELECT rowid, name, address, zip, town, status"; $sql = "SELECT e.rowid, e.name, e.address, e.zip, e.town, e.status, e.fk_country as country_id,";
$sql.= " FROM ".MAIN_DB_PREFIX."establishment"; $sql.= ' c.code as country_code, c.label as country';
$sql.= " WHERE rowid = ".$id; $sql.= " FROM ".MAIN_DB_PREFIX."establishment as e";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON e.fk_country = c.rowid';
$sql.= " WHERE e.rowid = ".$id;
dol_syslog(get_class($this)."::fetch", LOG_DEBUG); dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -189,6 +201,10 @@ class Establishment extends CommonObject
$this->town = $obj->town; $this->town = $obj->town;
$this->status = $obj->status; $this->status = $obj->status;
$this->country_id = $obj->country_id;
$this->country_code = $obj->country_code;
$this->country = $obj->country;
return 1; return 1;
} }
else else
@ -257,23 +273,23 @@ class Establishment extends CommonObject
} }
if ($mode == 2) if ($mode == 2)
{ {
if ($status==0) return img_picto($langs->trans($this->statuts_short[$status]),'status4').' '.$langs->trans($this->statuts_short[$status]); if ($status==0) return img_picto($langs->trans($this->statuts_short[$status]),'statut4').' '.$langs->trans($this->statuts_short[$status]);
if ($status==1) return img_picto($langs->trans($this->statuts_short[$status]),'status8').' '.$langs->trans($this->statuts_short[$status]); if ($status==1) return img_picto($langs->trans($this->statuts_short[$status]),'statut8').' '.$langs->trans($this->statuts_short[$status]);
} }
if ($mode == 3) if ($mode == 3)
{ {
if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'status4'); if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'statut4');
if ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'status8'); if ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'statut8');
} }
if ($mode == 4) if ($mode == 4)
{ {
if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'status4').' '.$langs->trans($this->statuts[$status]); if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'statut4').' '.$langs->trans($this->statuts[$status]);
if ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'status8').' '.$langs->trans($this->statuts[$status]); if ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'statut8').' '.$langs->trans($this->statuts[$status]);
} }
if ($mode == 5) if ($mode == 5)
{ {
if ($status==0 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'status4'); if ($status==0 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut4');
if ($status==1 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'status8'); if ($status==1 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut8');
} }
} }
@ -298,21 +314,23 @@ class Establishment extends CommonObject
{ {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->date_creation = $this->db->jdate($obj->datec);
if ($obj->fk_user_author) if ($obj->fk_user_author)
{ {
$cuser = new User($this->db); $cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author); $cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser; $this->user_creation = $cuser;
} }
if ($obj->fk_user_modif) if ($obj->fk_user_mod)
{ {
$muser = new User($this->db); $muser = new User($this->db);
$muser->fetch($obj->fk_user_mod); $muser->fetch($obj->fk_user_mod);
$this->user_modification = $muser; $this->user_modification = $muser;
}
$this->date_creation = $this->db->jdate($obj->datec);
$this->date_modification = $this->db->jdate($obj->tms); $this->date_modification = $this->db->jdate($obj->tms);
} }
}
$this->db->free($result); $this->db->free($result);
} }
else else
@ -321,4 +339,46 @@ class Establishment extends CommonObject
} }
} }
/**
* Return clicable name (with picto eventually)
*
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @return string String with URL
*/
function getNomUrl($withpicto=0)
{
global $langs;
$result='';
$link = '<a href="'.DOL_URL_ROOT.'/hrm/establishment/card.php?id='.$this->id.'">';
$linkend='</a>';
$picto='building';
$label=$langs->trans("Show").': '.$this->name;
if ($withpicto) $result.=($link.img_object($label,$picto).$linkend);
if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto != 2) $result.=$link.$this->name.$linkend;
return $result;
}
/**
* Return account country code
*
* @return string country code
*/
function getCountryCode()
{
global $mysoc;
// We return country code of bank account
if (! empty($this->country_code)) return $this->country_code;
// We return country code of managed company
if (! empty($mysoc->country_code)) return $mysoc->country_code;
return '';
}
} }

View File

@ -169,8 +169,8 @@ if ($result)
$employeestatic->email=$obj->email; $employeestatic->email=$obj->email;
$employeestatic->gender=$obj->gender; $employeestatic->gender=$obj->gender;
$employeestatic->societe_id=$obj->fk_soc; $employeestatic->societe_id=$obj->fk_soc;
$employeestatic->firstname=''; $userstatic->firstname=$obj->firstname;
$employeestatic->lastname=$obj->login; $userstatic->lastname=$obj->lastname;
$li=$employeestatic->getNomUrl(1,'',0,0,24,1); $li=$employeestatic->getNomUrl(1,'',0,0,24,1);

View File

@ -81,22 +81,16 @@ else if ($action == 'add')
if (empty($error)) if (empty($error))
{ {
$tmparray=getCountry(GETPOST('country_id','int'),'all',$db,$langs,0);
if (! empty($tmparray['id']))
{
$object->country_id =$tmparray['id'];
$object->country_code =$tmparray['code'];
$object->country_label=$tmparray['label'];
}
$object->address = GETPOST('address', 'alpha'); $object->address = GETPOST('address', 'alpha');
$object->zip = GETPOST('zipcode', 'alpha'); $object->zip = GETPOST('zipcode', 'alpha');
$object->town = GETPOST('town', 'alpha'); $object->town = GETPOST('town', 'alpha');
$object->fk_pays = $object->country_id; $object->country_id = $_POST["country_id"];
$object->status = GETPOST('status','int'); $object->status = GETPOST('status','int');
$object->fk_user_author = $user->id; $object->fk_user_author = $user->id;
$object->datec = dol_now(); $object->datec = dol_now();
$id = $object->create($user); $id = $object->create($user);
if ($id > 0) if ($id > 0)
@ -106,8 +100,7 @@ else if ($action == 'add')
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action='create';
} }
} }
else else
@ -131,12 +124,7 @@ else if ($action == 'update')
$name = GETPOST('name', 'alpha'); $name = GETPOST('name', 'alpha');
if (empty($name)) { if (empty($name)) {
setEventMessage($langs->trans('ErrorFieldRequired', $langs->trans('NameProperty')), 'errors'); setEventMessage($langs->trans('ErrorFieldRequired', $langs->trans('Name')), 'errors');
$error ++;
}
$typeid = GETPOST('typeid', 'int');
if (empty($typeid)) {
setEventMessage($langs->trans('ErrorFieldRequired', $langs->trans('TypeProperty')), 'errors');
$error ++; $error ++;
} }
@ -145,25 +133,23 @@ else if ($action == 'update')
$object->address = GETPOST('address', 'alpha'); $object->address = GETPOST('address', 'alpha');
$object->zip = GETPOST('zipcode', 'alpha'); $object->zip = GETPOST('zipcode', 'alpha');
$object->town = GETPOST('town', 'alpha'); $object->town = GETPOST('town', 'alpha');
$object->fk_pays = GETPOST('country_id', 'int'); $object->country_id = $_POST["country_id"];
$object->rowid = GETPOST('id');
$object->fk_user_mod = $user->id; $object->fk_user_mod = $user->id;
$id = $object->update(); $result = $object->update();
if ($id > 0) if ($result > 0)
{ {
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $_POST['id']);
exit; exit;
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action='create';
} }
} }
} else { } else {
header("Location: card.php?id=" . $id); header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $_POST['id']);
exit; exit;
} }
} }
@ -193,11 +179,11 @@ if ($action == 'create')
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Name // Name
print '<tr><td class="fieldrequired"><label for="name">'.$langs->trans("Name").'</label></td><td><input name="name" id="name" size="32" value="' . GETPOST("name") . '"></td></tr>'; print '<tr><td>'. fieldLabel('Name','name',1).'</td><td><input name="name" id="name" size="32" value="' . GETPOST("name") . '"></td></tr>';
// Address // Address
print '<tr>'; print '<tr>';
print '<td><label for="address">' . $langs->trans("Address") . '</label></td>'; print '<td>'.fieldLabel('Address','address',0).'</td>';
print '<td>'; print '<td>';
print '<input name="address" id="address" size="32" value="' . $object->address . '">'; print '<input name="address" id="address" size="32" value="' . $object->address . '">';
print '</td>'; print '</td>';
@ -205,7 +191,7 @@ if ($action == 'create')
// Zipcode // Zipcode
print '<tr>'; print '<tr>';
print '<td><label for="zipcode">' . $langs->trans('Zip') . '</label></td>'; print '<td>'.fieldLabel('Zip','zipcode',0).'</td>';
print '<td>'; print '<td>';
print $formcompany->select_ziptown(GETPOST('zipcode', 'alpha'), 'zipcode', array ( print $formcompany->select_ziptown(GETPOST('zipcode', 'alpha'), 'zipcode', array (
'town', 'town',
@ -216,7 +202,7 @@ if ($action == 'create')
// Town // Town
print '<tr>'; print '<tr>';
print '<td><label for="town">' . $langs->trans('Town') . '</label></td>'; print '<td>'.fieldLabel('Town','town',0).'</td>';
print '<td>'; print '<td>';
print $formcompany->select_ziptown(GETPOST('town', 'alpha'), 'town', array ( print $formcompany->select_ziptown(GETPOST('town', 'alpha'), 'town', array (
'zipcode', 'zipcode',
@ -227,7 +213,7 @@ if ($action == 'create')
// Country // Country
print '<tr>'; print '<tr>';
print '<td><label for="selectcountry_id">' . $langs->trans("Country") . '</label></td>'; print '<td>'.fieldLabel('Country','selectcountry_id',0).'</td>';
print '<td class="maxwidthonsmartphone">'; print '<td class="maxwidthonsmartphone">';
print $form->select_country($mysoc->country_id,'country_id'); print $form->select_country($mysoc->country_id,'country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
@ -236,7 +222,7 @@ if ($action == 'create')
// Status // Status
print '<tr>'; print '<tr>';
print '<td class="fieldrequired"><label for="status">'.$langs->trans("Status").'</label></td>'; print '<td>'.fieldLabel('Status','status',1).'</td>';
print '<td>'; print '<td>';
print $form->selectarray('status',$status2label,GETPOST('status')); print $form->selectarray('status',$status2label,GETPOST('status'));
print '</td></tr>'; print '</td></tr>';
@ -273,46 +259,43 @@ else if ($id)
// Ref // Ref
print "<tr>"; print "<tr>";
print '<td width="20%">'.$langs->trans("Ref").'</td><td>'; print '<td width="25%">'.$langs->trans("Ref").'</td><td>';
print $object->rowid; print $object->id;
print '</td></tr>'; print '</td></tr>';
// Name // Name
print '<tr><td class="fieldrequired"><label for="name">'.$langs->trans("Name").'</label></td><td>'; print '<tr><td>'.fieldLabel('Name','name',1).'</td><td>';
print '<input name="name" id="name" class="flat" size="32" value="'.$object->name.'">'; print '<input name="name" id="name" class="flat" size="32" value="'.$object->name.'">';
print '</td></tr>'; print '</td></tr>';
// Address // Address
print '<tr>'; print '<tr><td>'.fieldLabel('Address','address',0).'</td>';
print '<td><label for="address">' . $langs->trans("Address") . '</label></td>';
print '<td>'; print '<td>';
print '<input name="address" id="address" size="32" value="' . $object->address . '">'; print '<input name="address" id="address" size="32" value="' . $object->address . '">';
print '</td>'; print '</td></tr>';
print '</tr>';
// Zipcode / Town // Zipcode / Town
print '<tr><td><label for="zipcode">' . $langs->trans('Zip') . '</label></td><td>'; print '<tr><td>'.fieldLabel('Zip','zipcode',0).'</td><td>';
print $formcompany->select_ziptown($object->zip, 'zipcode', array ( print $formcompany->select_ziptown($object->zip, 'zipcode', array (
'town', 'town',
'selectcountry_id' 'selectcountry_id'
), 6) . '</tr>'; ), 6) . '</tr>';
print '<tr><td><label for="town">' . $langs->trans('Town') . '</label></td><td>'; print '<tr><td>'.fieldLabel('Town','town',0).'</td><td>';
print $formcompany->select_ziptown($object->town, 'town', array ( print $formcompany->select_ziptown($object->town, 'town', array (
'zipcode', 'zipcode',
'selectcountry_id' 'selectcountry_id'
)) . '</td></tr>'; )) . '</td></tr>';
// Country // Country
print '<tr>'; print '<tr><td>'.fieldLabel('Country','selectcountry_id',0).'</td>';
print '<td><label for="selectcountry_id">' . $langs->trans("Country") . '</label></td>';
print '<td class="maxwidthonsmartphone">'; print '<td class="maxwidthonsmartphone">';
print $form->select_country($object->fk_pays,'country_id'); print $form->select_country($object->fk_country,'country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Status // Status
print '<tr><td><label for="status">'.$langs->trans("Status").'</label></td><td>'; print '<tr><td>'.fieldLabel('Status','status',1).'</td><td>';
print $form->selectarray('status',$status2label,$object->status); print $form->selectarray('status',$status2label,$object->status);
print '</td></tr>'; print '</td></tr>';
@ -347,7 +330,7 @@ else if ($id)
// Ref // Ref
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td width="50%">'; print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td width="50%">';
print $object->rowid; print $object->id;
print '</td><td width="25%">'; print '</td><td width="25%">';
print $linkback; print $linkback;
print '</td></tr>'; print '</td></tr>';
@ -379,7 +362,14 @@ else if ($id)
// Country // Country
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("Country").'</td>'; print '<td>'.$langs->trans("Country").'</td>';
print '<td colspan="2">'.getCountry($object->fk_pays,1).'</td>'; print '<td colspan="2">';
if ($object->country_id > 0)
{
$img=picto_from_langcode($object->country_code);
print $img?$img.' ':'';
print getCountry($object->getCountryCode(),0,$db);
}
print '</td>';
print '</tr>'; print '</tr>';
// Status // Status

View File

@ -22,6 +22,7 @@
require('../../main.inc.php'); require('../../main.inc.php');
require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php'; require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php';
$langs->load("admin"); $langs->load("admin");

View File

@ -86,6 +86,10 @@ class DoliStorage implements TokenStorageInterface
*/ */
public function storeAccessToken($service, TokenInterface $token) public function storeAccessToken($service, TokenInterface $token)
{ {
//var_dump("storeAccessToken");
//var_dump($token);
dol_syslog("storeAccessToken");
$serializedToken = serialize($token); $serializedToken = serialize($token);
$this->tokens[$service] = $token; $this->tokens[$service] = $token;
@ -95,6 +99,10 @@ class DoliStorage implements TokenStorageInterface
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."oauth_token"; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."oauth_token";
$sql.= " WHERE service='".$service."' AND entity=1"; $sql.= " WHERE service='".$service."' AND entity=1";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql)
{
dol_print_error($this->db);
}
$obj = $this->db->fetch_array($resql); $obj = $this->db->fetch_array($resql);
if ($obj) { if ($obj) {
// update // update
@ -108,6 +116,7 @@ class DoliStorage implements TokenStorageInterface
$sql.= " VALUES ('".$service."', '".$this->db->escape($serializedToken)."', 1)"; $sql.= " VALUES ('".$service."', '".$this->db->escape($serializedToken)."', 1)";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
} }
//print $sql;
// allow chaining // allow chaining
return $this; return $this;
@ -122,8 +131,13 @@ class DoliStorage implements TokenStorageInterface
$sql = "SELECT token FROM ".MAIN_DB_PREFIX."oauth_token"; $sql = "SELECT token FROM ".MAIN_DB_PREFIX."oauth_token";
$sql.= " WHERE service='".$service."'"; $sql.= " WHERE service='".$service."'";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql)
{
dol_print_error($this->db);
}
$result = $this->db->fetch_array($resql); $result = $this->db->fetch_array($resql);
$token = unserialize($result[token]); $token = unserialize($result['token']);
$this->tokens[$service] = $token; $this->tokens[$service] = $token;
return is_array($this->tokens) return is_array($this->tokens)
@ -194,6 +208,10 @@ class DoliStorage implements TokenStorageInterface
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."oauth_state"; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."oauth_state";
$sql.= " WHERE service='".$service."' AND entity=1"; $sql.= " WHERE service='".$service."' AND entity=1";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql)
{
dol_print_error($this->db);
}
$obj = $this->db->fetch_array($resql); $obj = $this->db->fetch_array($resql);
if ($obj) { if ($obj) {
// update // update

View File

@ -18,6 +18,11 @@
-- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user); -- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user);
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
-- Was done into a 3.8 fix, so we must do it also in 3.9
ALTER TABLE llx_don ADD COLUMN fk_country integer NOT NULL DEFAULT 0 after country;
-- Fix bad data -- Fix bad data
update llx_opensurvey_sondage set format = 'D' where format = 'D+'; update llx_opensurvey_sondage set format = 'D' where format = 'D+';
update llx_opensurvey_sondage set format = 'A' where format = 'A+'; update llx_opensurvey_sondage set format = 'A' where format = 'A+';
@ -51,16 +56,17 @@ create table llx_overwrite_trans
transvalue text transvalue text
)ENGINE=innodb; )ENGINE=innodb;
ALTER TABLE llx_payment_salary ADD COLUMN datec datetime after tms; ALTER TABLE llx_payment_salary ADD COLUMN datec datetime AFTER tms;
ALTER TABLE llx_payment_salary CHANGE COLUMN fk_user_creat fk_user_author integer; ALTER TABLE llx_payment_salary CHANGE COLUMN fk_user_creat fk_user_author integer;
ALTER TABLE llx_adherent ADD COLUMN pass_crypted varchar(128) after pass; ALTER TABLE llx_adherent ADD COLUMN pass_crypted varchar(128) AFTER pass;
ALTER TABLE llx_paiement ADD COLUMN ref varchar(30) NOT NULL AFTER rowid; ALTER TABLE llx_paiement ADD COLUMN ref varchar(30) NOT NULL DEFAULT '' AFTER rowid;
ALTER TABLE llx_socpeople ADD COLUMN photo varchar(255) AFTER skype; ALTER TABLE llx_socpeople ADD COLUMN photo varchar(255) AFTER skype;
ALTER TABLE llx_user_param MODIFY COLUMN value text NOT NULL; ALTER TABLE llx_user_param MODIFY COLUMN param varchar(255) NOT NULL DEFAULT '';
ALTER TABLE llx_user_param MODIFY COLUMN value text NOT NULL DEFAULT '';
ALTER TABLE llx_expedition ADD COLUMN import_key varchar(14); ALTER TABLE llx_expedition ADD COLUMN import_key varchar(14);
ALTER TABLE llx_expedition ADD COLUMN extraparams varchar(255); ALTER TABLE llx_expedition ADD COLUMN extraparams varchar(255);
@ -71,7 +77,7 @@ ALTER TABLE llx_prelevement_lignes MODIFY COLUMN code_banque varchar(128);
ALTER TABLE llx_societe_rib MODIFY COLUMN code_banque varchar(128); ALTER TABLE llx_societe_rib MODIFY COLUMN code_banque varchar(128);
ALTER TABLE llx_contrat ADD COLUMN ref_customer varchar(30); ALTER TABLE llx_contrat ADD COLUMN ref_customer varchar(30);
ALTER TABLE llx_commande ADD COLUMN fk_warehouse integer DEFAULT NULL after fk_shipping_method; ALTER TABLE llx_commande ADD COLUMN fk_warehouse integer DEFAULT NULL AFTER fk_shipping_method;
ALTER TABLE llx_ecm_directories MODIFY COLUMN fullpath varchar(750); ALTER TABLE llx_ecm_directories MODIFY COLUMN fullpath varchar(750);
ALTER TABLE llx_ecm_directories DROP INDEX idx_ecm_directories; ALTER TABLE llx_ecm_directories DROP INDEX idx_ecm_directories;
@ -102,20 +108,21 @@ ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files (label, entity);
--ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files_fullpath(fullpath); --ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files_fullpath(fullpath);
ALTER TABLE llx_product ADD COLUMN onportal tinyint DEFAULT 0 after tobuy; ALTER TABLE llx_product ADD COLUMN onportal smallint DEFAULT 0 AFTER tobuy;
ALTER TABLE llx_user ADD COLUMN employee tinyint DEFAULT 1; ALTER TABLE llx_user ADD COLUMN employee smallint DEFAULT 1 AFTER ref_int;
ALTER TABLE llx_user ADD COLUMN fk_establishment integer DEFAULT 0 AFTER employee;
CREATE TABLE IF NOT EXISTS llx_c_hrm_function CREATE TABLE IF NOT EXISTS llx_c_hrm_function
( (
rowid integer PRIMARY KEY, rowid integer PRIMARY KEY,
pos tinyint DEFAULT 0 NOT NULL, pos smallint DEFAULT 0 NOT NULL,
code varchar(16) NOT NULL, code varchar(16) NOT NULL,
label varchar(50), label varchar(50),
c_level tinyint DEFAULT 0 NOT NULL, c_level smallint DEFAULT 0 NOT NULL,
active tinyint DEFAULT 1 NOT NULL active smallint DEFAULT 1 NOT NULL
)ENGINE=innodb; )ENGINE=innodb;
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(1, 5, 'EXECBOARD', 'Executive board', 0, 1); INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(1, 5, 'EXECBOARD', 'Executive board', 0, 1);
@ -131,10 +138,10 @@ INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES
CREATE TABLE IF NOT EXISTS llx_c_hrm_department CREATE TABLE IF NOT EXISTS llx_c_hrm_department
( (
rowid integer PRIMARY KEY, rowid integer PRIMARY KEY,
pos tinyint DEFAULT 0 NOT NULL, pos smallint DEFAULT 0 NOT NULL,
code varchar(16) NOT NULL, code varchar(16) NOT NULL,
label varchar(50), label varchar(50),
active tinyint DEFAULT 1 NOT NULL active smallint DEFAULT 1 NOT NULL
)ENGINE=innodb; )ENGINE=innodb;
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(1, 5,'MANAGEMENT', 'Management', 1); INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(1, 5,'MANAGEMENT', 'Management', 1);
@ -173,7 +180,7 @@ CREATE TABLE IF NOT EXISTS llx_establishment (
fk_user_mod integer NOT NULL, fk_user_mod integer NOT NULL,
datec datetime NOT NULL, datec datetime NOT NULL,
tms timestamp NOT NULL, tms timestamp NOT NULL,
status tinyint DEFAULT 1 status smallint DEFAULT 1
) ENGINE=InnoDB; ) ENGINE=InnoDB;
@ -221,7 +228,7 @@ create table llx_budget_lines
( (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_budget integer NOT NULL, fk_budget integer NOT NULL,
fk_project integer NOT NULL, fk_project_ids varchar(255) NOT NULL, -- List of project ids related to this budget. If budget is dedicated to projects not yet started, we recommand to create a project "Projects to come".
amount double(24,8) NOT NULL, amount double(24,8) NOT NULL,
datec datetime, datec datetime,
tms timestamp, tms timestamp,
@ -230,13 +237,12 @@ create table llx_budget_lines
import_key integer import_key integer
)ENGINE=innodb; )ENGINE=innodb;
ALTER TABLE llx_budget_lines ADD UNIQUE INDEX uk_budget_lines (fk_budget, fk_project); ALTER TABLE llx_budget_lines ADD UNIQUE INDEX uk_budget_lines (fk_budget, fk_project_ids);
-- Supprime orphelins pour permettre montee de la cle -- Supprime orphelins pour permettre montee de la cle
-- MYSQL V4 DELETE llx_budget_lines FROM llx_budget_lines LEFT JOIN llx_budget ON llx_budget.rowid = llx_budget_lines.fk_budget WHERE llx_budget_lines.rowid IS NULL; -- MYSQL V4 DELETE llx_budget_lines FROM llx_budget_lines LEFT JOIN llx_budget ON llx_budget.rowid = llx_budget_lines.fk_budget WHERE llx_budget_lines.rowid IS NULL;
-- POSTGRESQL V8 DELETE FROM llx_budget_lines USING llx_budget WHERE llx_budget_lines.fk_budget NOT IN (SELECT llx_budget.rowid FROM llx_budget); -- POSTGRESQL V8 DELETE FROM llx_budget_lines USING llx_budget WHERE llx_budget_lines.fk_budget NOT IN (SELECT llx_budget.rowid FROM llx_budget);
ALTER TABLE llx_budget_lines ADD INDEX idx_budget_lines (fk_project);
ALTER TABLE llx_budget_lines ADD CONSTRAINT fk_budget_lines_budget FOREIGN KEY (fk_budget) REFERENCES llx_budget (rowid); ALTER TABLE llx_budget_lines ADD CONSTRAINT fk_budget_lines_budget FOREIGN KEY (fk_budget) REFERENCES llx_budget (rowid);
@ -255,7 +261,7 @@ CREATE TABLE llx_product_pricerules
var_percent FLOAT NOT NULL, -- Price variation over based price var_percent FLOAT NOT NULL, -- Price variation over based price
var_min_percent FLOAT NOT NULL -- Min price discount over general price var_min_percent FLOAT NOT NULL -- Min price discount over general price
); );
ALTER TABLE llx_product ADD COLUMN price_autogen TINYINT(1) DEFAULT 0; ALTER TABLE llx_product ADD COLUMN price_autogen smallint DEFAULT 0;
ALTER TABLE llx_product_pricerules ADD CONSTRAINT unique_level UNIQUE (level); ALTER TABLE llx_product_pricerules ADD CONSTRAINT unique_level UNIQUE (level);
@ -282,3 +288,23 @@ CREATE TABLE llx_opensurvey_user_formanswers (
) ENGINE=InnoDB; ) ENGINE=InnoDB;
create table llx_categorie_project
(
fk_categorie integer NOT NULL,
fk_project integer NOT NULL,
import_key varchar(14)
)ENGINE=innodb;
ALTER TABLE llx_categorie_project ADD PRIMARY KEY pk_categorie_project (fk_categorie, fk_project);
ALTER TABLE llx_categorie_project ADD INDEX idx_categorie_project_fk_categorie (fk_categorie);
ALTER TABLE llx_categorie_project ADD INDEX idx_categorie_project_fk_project (fk_project);
ALTER TABLE llx_categorie_project ADD CONSTRAINT fk_categorie_project_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid);
ALTER TABLE llx_categorie_project ADD CONSTRAINT fk_categorie_project_fk_project FOREIGN KEY (fk_project) REFERENCES llx_projet (rowid);

View File

@ -20,7 +20,7 @@ create table llx_budget
( (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
entity integer NOT NULL DEFAULT 1, entity integer NOT NULL DEFAULT 1,
label varchar(255) NOT NULL, label varchar(255) NOT NULL, -- For example 'Global budget for year' or 'Budget for each project'
status integer, status integer,
note text, note text,
date_start date, date_start date,

View File

@ -17,11 +17,10 @@
-- =================================================================== -- ===================================================================
ALTER TABLE llx_budget_lines ADD UNIQUE INDEX uk_budget_lines (fk_budget, fk_project); ALTER TABLE llx_budget_lines ADD UNIQUE INDEX uk_budget_lines (fk_budget, fk_project_ids);
-- Supprime orphelins pour permettre montee de la cle -- Supprime orphelins pour permettre montee de la cle
-- MYSQL V4 DELETE llx_budget_lines FROM llx_budget_lines LEFT JOIN llx_budget ON llx_budget.rowid = llx_budget_lines.fk_budget WHERE llx_budget_lines.rowid IS NULL; -- MYSQL V4 DELETE llx_budget_lines FROM llx_budget_lines LEFT JOIN llx_budget ON llx_budget.rowid = llx_budget_lines.fk_budget WHERE llx_budget_lines.rowid IS NULL;
-- POSTGRESQL V8 DELETE FROM llx_budget_lines USING llx_budget WHERE llx_budget_lines.fk_budget NOT IN (SELECT llx_budget.rowid FROM llx_budget); -- POSTGRESQL V8 DELETE FROM llx_budget_lines USING llx_budget WHERE llx_budget_lines.fk_budget NOT IN (SELECT llx_budget.rowid FROM llx_budget);
ALTER TABLE llx_budget_lines ADD INDEX idx_budget_lines (fk_project);
ALTER TABLE llx_budget_lines ADD CONSTRAINT fk_budget_lines_budget FOREIGN KEY (fk_budget) REFERENCES llx_budget (rowid); ALTER TABLE llx_budget_lines ADD CONSTRAINT fk_budget_lines_budget FOREIGN KEY (fk_budget) REFERENCES llx_budget (rowid);

View File

@ -20,7 +20,7 @@ create table llx_budget_lines
( (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_budget integer NOT NULL, fk_budget integer NOT NULL,
fk_project integer NOT NULL, fk_project_ids varchar(255) NOT NULL, -- 'IDS:x,y' = List of project ids related to this budget. If budget is dedicated to projects not yet started, we recommand to create a project "Projects to come". 'FILTER:ref=*ABC' = Can also be a dynamic rule to select projects.
amount double(24,8) NOT NULL, amount double(24,8) NOT NULL,
datec datetime, datec datetime,
tms timestamp, tms timestamp,

View File

@ -0,0 +1,24 @@
-- ============================================================================
-- Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
--
-- 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/>.
--
-- ============================================================================
ALTER TABLE llx_categorie_project ADD PRIMARY KEY pk_categorie_project (fk_categorie, fk_project);
ALTER TABLE llx_categorie_project ADD INDEX idx_categorie_project_fk_categorie (fk_categorie);
ALTER TABLE llx_categorie_project ADD INDEX idx_categorie_project_fk_project (fk_project);
ALTER TABLE llx_categorie_project ADD CONSTRAINT fk_categorie_project_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid);
ALTER TABLE llx_categorie_project ADD CONSTRAINT fk_categorie_project_fk_project_rowid FOREIGN KEY (fk_project) REFERENCES llx_projet (rowid);

View File

@ -0,0 +1,25 @@
-- ============================================================================
-- Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
-- Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
--
-- 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/>.
--
-- ============================================================================
create table llx_categorie_project
(
fk_categorie integer NOT NULL,
fk_project integer NOT NULL,
import_key varchar(14)
)ENGINE=innodb;

View File

@ -29,5 +29,5 @@ CREATE TABLE llx_opensurvey_sondage (
allow_comments tinyint NOT NULL DEFAULT 1, allow_comments tinyint NOT NULL DEFAULT 1,
allow_spy tinyint NOT NULL DEFAULT 1, allow_spy tinyint NOT NULL DEFAULT 1,
tms TIMESTAMP, tms TIMESTAMP,
sujet TEXT, -- Not filled if format = 'F'. Question are into table llx_opensurvey_formquestions sujet TEXT -- Not filled if format = 'F'. Question are into table llx_opensurvey_formquestions
) ENGINE=InnoDB; ) ENGINE=InnoDB;

View File

@ -27,6 +27,7 @@ create table llx_user
ref_int varchar(50), -- reference into an internal system (deprecated) ref_int varchar(50), -- reference into an internal system (deprecated)
employee tinyint DEFAULT 1, -- 1 if user is an employee employee tinyint DEFAULT 1, -- 1 if user is an employee
fk_establishment integer DEFAULT 0,
datec datetime, datec datetime,
tms timestamp, tms timestamp,

View File

@ -22,7 +22,7 @@ create table llx_user_param
( (
fk_user integer NOT NULL, fk_user integer NOT NULL,
entity integer DEFAULT 1 NOT NULL, -- multi company id entity integer DEFAULT 1 NOT NULL, -- multi company id
param varchar(64) NOT NULL, param varchar(255) NOT NULL,
value text NOT NULL value text NOT NULL
)ENGINE=innodb; )ENGINE=innodb;

View File

@ -1,7 +1,11 @@
# Dolibarr language file - Source file is en_US - oauth # Dolibarr language file - Source file is en_US - oauth
ConfigOAuth=Oauth Configuration ConfigOAuth=Oauth Configuration
NoAccessToken=No token access saved. NoAccessToken=No token access saved.
HasAccessToken=A token was generated and saved into database
NewTokenStored=Token received ans saved
TokenDeleted=Token deleted
UseTheFollowingUrlAsRedirectURI=Use the following URL as the Redirect URI when creating your credential on your OAuth provider: UseTheFollowingUrlAsRedirectURI=Use the following URL as the Redirect URI when creating your credential on your OAuth provider:
ListOfSupportedOauthProviders=Enter here credential provided by your OAuth2 provider. Only supported OAuth2 providers are visible here. This setup may be used by other modules than need OAuth2 authentication.
OAUTH_AMAZON_NAME=Api Amazon OAUTH_AMAZON_NAME=Api Amazon
OAUTH_AMAZON_ID=Api Amazon Id OAUTH_AMAZON_ID=Api Amazon Id
OAUTH_AMAZON_SECRET=Api Amazon Secret OAUTH_AMAZON_SECRET=Api Amazon Secret

View File

@ -3,7 +3,7 @@ Module64000Name=Direct Printing
Module64000Desc=Enable Direct Printing System Module64000Desc=Enable Direct Printing System
PrintingSetup=Setup of Direct Printing System PrintingSetup=Setup of Direct Printing System
PrintingDesc=This module adds a Print button to send documents directly to a printer (without opening document into an application) with various module. PrintingDesc=This module adds a Print button to send documents directly to a printer (without opening document into an application) with various module.
MenuDirectPrinting=Direct Printing MenuDirectPrinting=Direct Printing jobs
DirectPrint=Direct print DirectPrint=Direct print
ModuleDriverSetup=Setup Module Driver ModuleDriverSetup=Setup Module Driver
PrintingDriverDesc=Configuration variables for printing driver. PrintingDriverDesc=Configuration variables for printing driver.
@ -20,11 +20,13 @@ UserConf=Setup per user
PRINTGCP=Google Cloud Print PRINTGCP=Google Cloud Print
PRINTGCP_INFO=Google Api State PRINTGCP_INFO=Google Api State
PRINTGCP_AUTHLINK=Authentication PRINTGCP_AUTHLINK=Authentication
PRINTGCP_TOKEN_ACCESS=Google Cloud Print Token PRINTGCP_TOKEN_ACCESS=Google Cloud Print OAuth Token
PRINTGCP_TOKEN_REFRESH=Token Refresh Present PRINTGCP_TOKEN_REFRESH=Token Refresh Present
PRINTGCP_TOKEN_EXPIRED=Token Expired PRINTGCP_TOKEN_EXPIRED=Token Expired
PRINTGCP_TOKEN_EXPIRE_AT=Token expire at PRINTGCP_TOKEN_EXPIRE_AT=Token expire at
RequestAccess=Request Access PRINTGCP_DELETE_TOKEN=Delete saved token
RequestAccess=Click here to request access and receive a token to save
DeleteAccess=Click here to delete token
PrintGCPDesc=This driver allow to send documents directly to a printer with Google Cloud Print. PrintGCPDesc=This driver allow to send documents directly to a printer with Google Cloud Print.
PrintingDriverDescprintgcp=Configuration variables for printing driver Google Cloud Print. PrintingDriverDescprintgcp=Configuration variables for printing driver Google Cloud Print.
PrintTestDescprintgcp=List of Printers for Google Cloud Print. PrintTestDescprintgcp=List of Printers for Google Cloud Print.
@ -83,4 +85,4 @@ MEDIA_IPP_thermal=Thermal
IPP_COLOR_print-black=BW Printer IPP_COLOR_print-black=BW Printer
DirectPrintingJobsDesc=This page lists printing jobs found for available printers. DirectPrintingJobsDesc=This page lists printing jobs found for available printers.
GoogleAuthNotConfigured=Google OAuth setup not done. Enable module OAuth and set a Google ID/Secret. GoogleAuthNotConfigured=Google OAuth setup not done. Enable module OAuth and set a Google ID/Secret.
GoogleAuthConfigured=Google OAuth credentials found. GoogleAuthConfigured=Google OAuth credentials found into setup of module OAuth.

View File

@ -176,6 +176,7 @@ ProjectOpenedProjectByOppStatus=Opened project/lead by opportunity status
ProjectsStatistics=Statistics on projects/leads ProjectsStatistics=Statistics on projects/leads
TaskAssignedToEnterTime=Task assigned. Entering time on this task should be possible. TaskAssignedToEnterTime=Task assigned. Entering time on this task should be possible.
IdTaskTime=Id task time IdTaskTime=Id task time
YouCanCompleteRef=If you want to complete the ref with some information (to use it as search filters), it is recommanded to add a - character to separate it, so the automatic numbering will still work correctly for next projects. For example %s-ABC. You may also prefer to add search keys into label.
OpenedProjectsByThirdparties=Opened projects by thirdparties OpenedProjectsByThirdparties=Opened projects by thirdparties
OpportunityTotalAmount=Opportunities total amount OpportunityTotalAmount=Opportunities total amount
OpportunityPonderatedAmount=Opportunities weighted amount OpportunityPonderatedAmount=Opportunities weighted amount

View File

@ -931,7 +931,7 @@ if (! function_exists("llxHeader"))
} }
if (empty($conf->dol_hide_leftmenu)) if (empty($conf->dol_hide_leftmenu))
{ {
left_menu('', $help_url, '', '', 1, $title); left_menu('', $help_url, '', '', 1, $title, 1);
} }
// main area // main area
@ -1401,13 +1401,6 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
</script>' . "\n"; </script>' . "\n";
} }
// Wrapper to show tooltips
print '<script type="text/javascript">
jQuery(document).ready(function () {
jQuery(".classfortooltip").tipTip({maxWidth: "'.dol_size(600,'width').'px", edgeOffset: 10, delay: 50, fadeIn: 50, fadeOut: 50});
});
</script>' . "\n";
// Raven.js for client-side Sentry logging support // Raven.js for client-side Sentry logging support
if (array_key_exists('mod_syslog_sentry', $conf->loghandlers) && ! empty($conf->global->SYSLOG_SENTRY_DSN)) if (array_key_exists('mod_syslog_sentry', $conf->loghandlers) && ! empty($conf->global->SYSLOG_SENTRY_DSN))
{ {
@ -1539,9 +1532,10 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
* @param array $menu_array_after Table of menu entries to show after entries of menu handler * @param array $menu_array_after Table of menu entries to show after entries of menu handler
* @param int $leftmenuwithoutmainarea Must be set to 1. 0 by default for backward compatibility with old modules. * @param int $leftmenuwithoutmainarea Must be set to 1. 0 by default for backward compatibility with old modules.
* @param string $title Title of web page * @param string $title Title of web page
* @param string $acceptdelayedhtml 1 if caller request to have html delayed content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect)
* @return void * @return void
*/ */
function left_menu($menu_array_before, $helppagename='', $notused='', $menu_array_after='', $leftmenuwithoutmainarea=0, $title='') function left_menu($menu_array_before, $helppagename='', $notused='', $menu_array_after='', $leftmenuwithoutmainarea=0, $title='', $acceptdelayedhtml=0)
{ {
global $user, $conf, $langs, $db, $form; global $user, $conf, $langs, $db, $form;
global $hookmanager, $menumanager; global $hookmanager, $menumanager;
@ -1563,7 +1557,7 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra
{ {
if (! is_object($form)) $form=new Form($db); if (! is_object($form)) $form=new Form($db);
$selected=-1; $selected=-1;
$searchform.=$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'vmenusearchselectcombo', 1, $langs->trans("Search")); $searchform.=$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'vmenusearchselectcombo', 1, $langs->trans("Search"), 1);
} }
else else
{ {
@ -1770,7 +1764,6 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra
print "\n"; print "\n";
print '<!-- Begin right area -->'."\n"; print '<!-- Begin right area -->'."\n";
if (empty($leftmenuwithoutmainarea)) main_area($title); if (empty($leftmenuwithoutmainarea)) main_area($title);
} }
@ -1892,6 +1885,7 @@ if (! function_exists("llxFooter"))
/** /**
* Show HTML footer * Show HTML footer
* Close div /DIV data-role=page + /DIV class=fiche + /DIV /DIV main layout + /BODY + /HTML. * Close div /DIV data-role=page + /DIV class=fiche + /DIV /DIV main layout + /BODY + /HTML.
* If global var $delayedhtmlcontent was filled, we output it just before closing the body.
* *
* @param string $comment A text to add as HTML comment into HTML generated page * @param string $comment A text to add as HTML comment into HTML generated page
* @param string $zone 'private' (for private pages) or 'public' (for public pages) * @param string $zone 'private' (for private pages) or 'public' (for public pages)
@ -1900,6 +1894,7 @@ if (! function_exists("llxFooter"))
function llxFooter($comment='',$zone='private') function llxFooter($comment='',$zone='private')
{ {
global $conf, $langs; global $conf, $langs;
global $delayedhtmlcontent;
// Global html output events ($mesgs, $errors, $warnings) // Global html output events ($mesgs, $errors, $warnings)
dol_htmloutput_events(); dol_htmloutput_events();
@ -1937,6 +1932,18 @@ if (! function_exists("llxFooter"))
//var_dump($langs); // Uncommment to see the property _tab_loaded to see which language file were loaded //var_dump($langs); // Uncommment to see the property _tab_loaded to see which language file were loaded
if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile) && empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '</div> <!-- End div id-container -->'."\n"; // End div container if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile) && empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '</div> <!-- End div id-container -->'."\n"; // End div container
if (! empty($delayedhtmlcontent)) print $delayedhtmlcontent;
// Wrapper to show tooltips
print "\n<!-- JS CODE TO ENABLE tipTip on all object with class classfortooltip -->\n";
print '<script type="text/javascript">
jQuery(document).ready(function () {
jQuery(".classfortooltip").tipTip({maxWidth: "'.dol_size(600,'width').'px", edgeOffset: 10, delay: 50, fadeIn: 50, fadeOut: 50});
});
</script>' . "\n";
print "</body>\n"; print "</body>\n";
print "</html>\n"; print "</html>\n";
} }

View File

@ -82,31 +82,16 @@ if ($id > 0 || ! empty($ref))
$picto=($object->type== Product::TYPE_SERVICE?'service':'product'); $picto=($object->type== Product::TYPE_SERVICE?'service':'product');
dol_fiche_head($head, 'margin', $titre, 0, $picto); dol_fiche_head($head, 'margin', $titre, 0, $picto);
print '<table class="border" width="100%">'; dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref');
// Reference
print '<tr>';
print '<td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">';
print $form->showrefnav($object,'ref','',1,'ref');
print '</td>';
print '</tr>';
// Libelle print '<div class="fichecenter">';
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$object->label.'</td>';
print '</tr>';
// Status (to sell) print '<div class="underbanner clearboth"></div>';
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td colspan="3">'; print '<table class="border tableforfield" width="100%">';
print $object->getLibStatut(2,0);
print '</td></tr>';
// Status (to buy)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td colspan="3">';
print $object->getLibStatut(2,1);
print '</td></tr>';
// Total Margin // Total Margin
print '<tr><td>'.$langs->trans("TotalMargin").'</td><td colspan="3">'; print '<tr><td class="titlefield">'.$langs->trans("TotalMargin").'</td><td colspan="3">';
print '<span id="totalMargin"></span>'; // set by jquery (see below) print '<span id="totalMargin"></span>'; // set by jquery (see below)
print '</td></tr>'; print '</td></tr>';
@ -125,7 +110,11 @@ if ($id > 0 || ! empty($ref))
} }
print "</table>"; print "</table>";
print '</div>'; print '</div>';
print '<div style="clear:both"></div>';
dol_fiche_end();
if ($user->rights->facture->lire) { if ($user->rights->facture->lire) {

View File

@ -73,21 +73,21 @@ if ($socid > 0)
dol_fiche_head($head, 'margin', $langs->trans("ThirdParty"),0,'company'); dol_fiche_head($head, 'margin', $langs->trans("ThirdParty"),0,'company');
print '<table class="border" width="100%">'; dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
print '<tr><td width="20%">'.$langs->trans('ThirdPartyName').'</td>'; print '<div class="fichecenter">';
print '<td colspan="3">';
print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom');
print '</td></tr>';
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field print '<div class="underbanner clearboth"></div>';
{ print '<table class="border tableforfield" width="100%">';
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
} // Alias names (commercial, trademark or alias names)
print '<tr><td class="titlefield">'.$langs->trans('AliasNames').'</td><td>';
print $object->name_alias;
print "</td></tr>";
if ($object->client) if ($object->client)
{ {
print '<tr><td>'; print '<tr><td class="titlefield">';
print $langs->trans('CustomerCode').'</td><td colspan="3">'; print $langs->trans('CustomerCode').'</td><td colspan="3">';
print $object->code_client; print $object->code_client;
if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
@ -96,7 +96,7 @@ if ($socid > 0)
if ($object->fournisseur) if ($object->fournisseur)
{ {
print '<tr><td>'; print '<tr><td class="titlefield">';
print $langs->trans('SupplierCode').'</td><td colspan="3">'; print $langs->trans('SupplierCode').'</td><td colspan="3">';
print $object->code_fournisseur; print $object->code_fournisseur;
if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
@ -104,7 +104,7 @@ if ($socid > 0)
} }
// Total Margin // Total Margin
print '<tr><td>'.$langs->trans("TotalMargin").'</td><td colspan="3">'; print '<tr><td class="titlefield">'.$langs->trans("TotalMargin").'</td><td colspan="3">';
print '<span id="totalMargin"></span>'; // set by jquery (see below) print '<span id="totalMargin"></span>'; // set by jquery (see below)
print '</td></tr>'; print '</td></tr>';
@ -123,7 +123,11 @@ if ($socid > 0)
} }
print "</table>"; print "</table>";
dol_fiche_end();
print '</div>'; print '</div>';
print '<div style="clear:both"></div>';
$sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client,"; $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client,";

View File

@ -137,7 +137,8 @@ if ($mode == 'setup' && $user->admin)
$classname = 'printing_'.$driver; $classname = 'printing_'.$driver;
$langs->load($driver); $langs->load($driver);
$printer = new $classname($db); $printer = new $classname($db);
//print '<pre>'.print_r($printer, true).'</pre>'; //var_dump($printer);
$i=0; $i=0;
$submit_enabled=0; $submit_enabled=0;
foreach ($printer->conf as $key) foreach ($printer->conf as $key)
@ -157,14 +158,14 @@ if ($mode == 'setup' && $user->admin)
case "authlink": case "authlink":
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans($key['varname']).'</td>'; print '<td>'.$langs->trans($key['varname']).'</td>';
print '<td class="button"><a href="'.$key['link'].'">'.$langs->trans('RequestAccess').'</a></td>'; print '<td><a class="button" href="'.$key['link'].'">'.$langs->trans('RequestAccess').'</a></td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '</tr>'."\n"; print '</tr>'."\n";
break; break;
case "delete": case "delete":
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans($key['varname']).'</td>'; print '<td>'.$langs->trans($key['varname']).'</td>';
print '<td class="button"><a href="'.$key['link'].'">'.$langs->trans('DeleteAccess').'</a></td>'; print '<td><a class="button" href="'.$key['link'].'">'.$langs->trans('DeleteAccess').'</a></td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '</tr>'."\n"; print '</tr>'."\n";
break; break;

View File

@ -27,7 +27,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php';
llxHeader("",$langs->trans("Printing")); llxHeader("",$langs->trans("Printing"));
print load_fiche_titre($langs->trans("Printing")); print_barre_liste($langs->trans("Printing"), 0, $_SERVER["PHP_SELF"], '', '', '', '<a class="button" href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("Refresh").'</a>', 0);
print $langs->trans("DirectPrintingJobsDesc").'<br><br>'; print $langs->trans("DirectPrintingJobsDesc").'<br><br>';

View File

@ -90,9 +90,6 @@ $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSe
<?php echo $object->volume_units; ?> <?php echo $object->volume_units; ?>
</td></tr> </td></tr>
<tr><td><?php echo $langs->trans("Hidden"); ?></td>
<td><?php echo $object->hidden; ?></td></tr>
<tr><td valign="top"><?php echo $langs->trans("NoteNotVisibleOnBill"); ?></td><td> <tr><td valign="top"><?php echo $langs->trans("NoteNotVisibleOnBill"); ?></td><td>
<?php echo $object->textarea_note; ?> <?php echo $object->textarea_note; ?>
</td></tr> </td></tr>

View File

@ -63,9 +63,6 @@ $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSe
<?php echo $object->duration_unit; ?> <?php echo $object->duration_unit; ?>
</td></tr> </td></tr>
<tr><td><?php echo $langs->trans("Hidden"); ?></td>
<td><?php echo $object->hidden; ?></td></tr>
<tr><td valign="top"><?php echo $langs->trans("NoteNotVisibleOnBill"); ?></td><td> <tr><td valign="top"><?php echo $langs->trans("NoteNotVisibleOnBill"); ?></td><td>
<?php echo $object->textarea_note; ?> <?php echo $object->textarea_note; ?>
</td></tr> </td></tr>

View File

@ -249,7 +249,6 @@ if (empty($reshook))
$object->volume = GETPOST('volume'); $object->volume = GETPOST('volume');
$object->volume_units = GETPOST('volume_units'); $object->volume_units = GETPOST('volume_units');
$object->finished = GETPOST('finished'); $object->finished = GETPOST('finished');
$object->hidden = GETPOST('hidden')=='yes'?1:0;
$object->fk_unit = GETPOST('units'); $object->fk_unit = GETPOST('units');
$object->accountancy_code_sell = GETPOST('accountancy_code_sell'); $object->accountancy_code_sell = GETPOST('accountancy_code_sell');
$object->accountancy_code_buy = GETPOST('accountancy_code_buy'); $object->accountancy_code_buy = GETPOST('accountancy_code_buy');
@ -335,7 +334,6 @@ if (empty($reshook))
$object->volume = GETPOST('volume'); $object->volume = GETPOST('volume');
$object->volume_units = GETPOST('volume_units'); $object->volume_units = GETPOST('volume_units');
$object->finished = GETPOST('finished'); $object->finished = GETPOST('finished');
$object->hidden = GETPOST('hidden')=='yes'?1:0;
$units = GETPOST('units', 'int'); $units = GETPOST('units', 'int');
@ -1040,7 +1038,7 @@ else
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$type = $langs->trans('Product'); $type = $langs->trans('Product');
if ($object->isservice()) $type = $langs->trans('Service'); if ($object->isService()) $type = $langs->trans('Service');
//print load_fiche_titre($langs->trans('Modify').' '.$type.' : '.(is_object($object->oldcopy)?$object->oldcopy->ref:$object->ref), ""); //print load_fiche_titre($langs->trans('Modify').' '.$type.' : '.(is_object($object->oldcopy)?$object->oldcopy->ref:$object->ref), "");
// Main official, simple, and not duplicated code // Main official, simple, and not duplicated code
@ -1146,7 +1144,7 @@ else
// Stock // Stock
/* /*
if ($object->isproduct() && ! empty($conf->stock->enabled)) if ($object->isProduct() && ! empty($conf->stock->enabled))
{ {
print "<tr>".'<td>'.$langs->trans("StockLimit").'</td><td>'; print "<tr>".'<td>'.$langs->trans("StockLimit").'</td><td>';
print '<input name="seuil_stock_alerte" size="4" value="'.$object->seuil_stock_alerte.'">'; print '<input name="seuil_stock_alerte" size="4" value="'.$object->seuil_stock_alerte.'">';
@ -1171,7 +1169,7 @@ else
print '</td></tr>'; print '</td></tr>';
} }
if ($object->isservice()) if ($object->isService())
{ {
// Duration // Duration
print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="3"><input name="duration_value" size="3" maxlength="5" value="'.$object->duration_value.'">'; print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="3"><input name="duration_value" size="3" maxlength="5" value="'.$object->duration_value.'">';
@ -1239,16 +1237,9 @@ else
print $object->showOptionals($extrafields,'edit'); print $object->showOptionals($extrafields,'edit');
} }
// Note // Tags-Categories
print '<tr><td class="tdtop">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="3">'; if ($conf->categorie->enabled)
{
$doleditor = new DolEditor('note', $object->note, '', 140, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, 80);
$doleditor->Create();
print "</td></tr>";
if($conf->categorie->enabled) {
// Categories
print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td colspan="3">'; print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td colspan="3">';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1); $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1);
$c = new Categorie($db); $c = new Categorie($db);
@ -1260,6 +1251,14 @@ else
print "</td></tr>"; print "</td></tr>";
} }
// Note
print '<tr><td class="tdtop">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="3">';
$doleditor = new DolEditor('note', $object->note, '', 140, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, 80);
$doleditor->Create();
print "</td></tr>";
print '</table>'; print '</table>';
print '<br>'; print '<br>';
@ -1298,58 +1297,29 @@ else
// Fiche en mode visu // Fiche en mode visu
else else
{ {
$showbarcode=empty($conf->barcode->enabled)?0:1;
if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0;
$head=product_prepare_head($object); $head=product_prepare_head($object);
$titre=$langs->trans("CardProduct".$object->type); $titre=$langs->trans("CardProduct".$object->type);
$picto=($object->type== Product::TYPE_SERVICE?'service':'product'); $picto=($object->type== Product::TYPE_SERVICE?'service':'product');
dol_fiche_head($head, 'card', $titre, 0, $picto); dol_fiche_head($head, 'card', $titre, 0, $picto);
$showphoto=$object->is_photo_available($conf->product->multidir_output[$object->entity]); dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref');
$showbarcode=empty($conf->barcode->enabled)?0:1;
if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0;
// En mode visu
print '<table class="border" width="100%"><tr>';
// Ref print '<div class="fichecenter">';
print '<td width="15%">'.$langs->trans("Ref").'</td><td colspan="'.(2+(($showphoto||$showbarcode)?1:0)).'">'; print '<div class="fichehalfleft">';
print $form->showrefnav($object,'ref','',1,'ref');
print '</td>';
print '</tr>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$object->label.'</td>';
$nblignes=7;
if (! empty($conf->produit->enabled) && ! empty($conf->service->enabled)) $nblignes++;
if ($showbarcode) $nblignes+=2;
if ($object->type!= Product::TYPE_SERVICE) $nblignes++;
if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) $nblignes+=2;
if ($object->isservice()) $nblignes++;
else $nblignes+=4;
// Photo
if ($showphoto || $showbarcode)
{
print '<td valign="middle" align="center" width="25%" rowspan="'.$nblignes.'">';
print '<div class="photolist">';
$maxvisiblephotos=(isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO)?$conf->global->PRODUCT_MAX_VISIBLE_PHOTO:5);
if ($conf->browser->phone) $maxvisiblephotos=1;
if ($showphoto) print $object->show_photos($conf->product->multidir_output[$object->entity],1,$maxvisiblephotos,0,0,0,80);
if ($showphoto && $showbarcode) print '<br><br>';
if ($showbarcode) print $form->showbarcode($object);
print '</div>';
print '</td>';
}
print '</tr>';
// Type // Type
if (! empty($conf->produit->enabled) && ! empty($conf->service->enabled)) if (! empty($conf->produit->enabled) && ! empty($conf->service->enabled))
{ {
// TODO change for compatibility with edit in place // TODO change for compatibility with edit in place
$typeformat='select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); $typeformat='select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service");
print '<tr><td>'.$form->editfieldkey("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat).'</td><td colspan="2">'; print '<tr><td class="titlefield">'.$form->editfieldkey("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat).'</td><td colspan="2">';
print $form->editfieldval("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat); print $form->editfieldval("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat);
print '</td></tr>'; print '</td></tr>';
} }
@ -1412,6 +1382,7 @@ else
print '</td></tr>'; print '</td></tr>';
// Status (to sell) // Status (to sell)
/*
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td colspan="2">'; print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td colspan="2">';
if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
print ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); print ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell');
@ -1428,6 +1399,7 @@ else
print $object->getLibStatut(2,1); print $object->getLibStatut(2,1);
} }
print '</td></tr>'; print '</td></tr>';
*/
// Batch number management (to batch) // Batch number management (to batch)
if (! empty($conf->productbatch->enabled)) { if (! empty($conf->productbatch->enabled)) {
@ -1448,18 +1420,25 @@ else
print dol_print_url($object->url); print dol_print_url($object->url);
print '</td></tr>'; print '</td></tr>';
print '</table>';
print '</div>';
print '<div class="fichehalfright"><div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">';
// Nature // Nature
if($object->type!= Product::TYPE_SERVICE) if($object->type!= Product::TYPE_SERVICE)
{ {
print '<tr><td>'.$langs->trans("Nature").'</td><td colspan="2">'; print '<tr><td class="titlefield">'.$langs->trans("Nature").'</td><td colspan="2">';
print $object->getLibFinished(); print $object->getLibFinished();
print '</td></tr>'; print '</td></tr>';
} }
if ($object->isservice()) if ($object->isService())
{ {
// Duration // Duration
print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="2">'.$object->duration_value.'&nbsp;'; print '<tr><td class="titlefield">'.$langs->trans("Duration").'</td><td colspan="2">'.$object->duration_value.'&nbsp;';
if ($object->duration_value > 1) if ($object->duration_value > 1)
{ {
$dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); $dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years"));
@ -1475,7 +1454,7 @@ else
else else
{ {
// Weight // Weight
print '<tr><td>'.$langs->trans("Weight").'</td><td colspan="2">'; print '<tr><td class="titlefield">'.$langs->trans("Weight").'</td><td colspan="2">';
if ($object->weight != '') if ($object->weight != '')
{ {
print $object->weight." ".measuring_units_string($object->weight_units,"weight"); print $object->weight." ".measuring_units_string($object->weight_units,"weight");
@ -1549,11 +1528,6 @@ else
print $object->showOptionals($extrafields); print $object->showOptionals($extrafields);
} }
// Note
print '<!-- show Note --> '."\n";
print '<tr><td class="tdtop">'.$langs->trans("Note").'</td><td colspan="'.(2+(($showphoto||$showbarcode)?1:0)).'">'.(dol_textishtml($object->note)?$object->note:dol_nl2br($object->note,1,true)).'</td></tr>'."\n";
print '<!-- End show Note --> '."\n";
// Categories // Categories
if($conf->categorie->enabled) { if($conf->categorie->enabled) {
print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td colspan="3">'; print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td colspan="3">';
@ -1561,7 +1535,16 @@ else
print "</td></tr>"; print "</td></tr>";
} }
// Note
print '<!-- show Note --> '."\n";
print '<tr><td class="tdtop">'.$langs->trans("Note").'</td><td colspan="'.(2+(($showphoto||$showbarcode)?1:0)).'">'.(dol_textishtml($object->note)?$object->note:dol_nl2br($object->note,1,true)).'</td></tr>'."\n";
print '<!-- End show Note --> '."\n";
print "</table>\n"; print "</table>\n";
print '</div>';
print '</div></div>';
print '<div style="clear:both"></div>';
dol_fiche_end(); dol_fiche_end();
} }

View File

@ -84,11 +84,13 @@ class Product extends CommonObject
//! Base price ('TTC' for price including tax or 'HT' for net price) //! Base price ('TTC' for price including tax or 'HT' for net price)
var $price_base_type; var $price_base_type;
//! Arrays for multiprices //! Arrays for multiprices
var $multiprices=array(); public $multiprices=array();
var $multiprices_ttc=array(); public $multiprices_ttc=array();
var $multiprices_base_type=array(); public $multiprices_base_type=array();
var $multiprices_tva_tx=array(); public $multiprices_min=array();
var $multiprices_recuperableonly=array(); public $multiprices_min_ttc=array();
public $multiprices_tva_tx=array();
public $multiprices_recuperableonly=array();
//! Price by quantity arrays //! Price by quantity arrays
var $price_by_qty; var $price_by_qty;
var $prices_by_qty=array(); var $prices_by_qty=array();
@ -125,6 +127,12 @@ class Product extends CommonObject
var $customcode; // Customs code var $customcode; // Customs code
/**
* Product URL
* @var string
*/
public $url;
//! Unites de mesure //! Unites de mesure
var $weight; var $weight;
var $weight_units; var $weight_units;
@ -717,6 +725,7 @@ class Product extends CommonObject
$sql.= ", desiredstock = " . ((isset($this->desiredstock) && $this->desiredstock != '') ? $this->desiredstock : "null"); $sql.= ", desiredstock = " . ((isset($this->desiredstock) && $this->desiredstock != '') ? $this->desiredstock : "null");
$sql.= ", fk_unit= " . (!$this->fk_unit ? 'NULL' : $this->fk_unit); $sql.= ", fk_unit= " . (!$this->fk_unit ? 'NULL' : $this->fk_unit);
$sql.= ", price_autogen = " . (!$this->price_autogen ? 0 : 1); $sql.= ", price_autogen = " . (!$this->price_autogen ? 0 : 1);
$sql.= ", fk_price_expression = ".($this->fk_price_expression != 0 ? $this->fk_price_expression : 'NULL');
$sql.= " WHERE rowid = " . $id; $sql.= " WHERE rowid = " . $id;
dol_syslog(get_class($this)."::update", LOG_DEBUG); dol_syslog(get_class($this)."::update", LOG_DEBUG);
@ -1443,6 +1452,14 @@ class Product extends CommonObject
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$this->multiprices[$level] = $price;
$this->multiprices_ttc[$level] = $price_ttc;
$this->multiprices_min[$level]= $price_min;
$this->multiprices_min_ttc[$level]= $price_min_ttc;
$this->multiprices_base_type[$level]= $newpricebase;
$this->multiprices_tva_tx[$level]= $newvat;
$this->multiprices_recuperableonly[$level]= $newnpr;
$this->price = $price; $this->price = $price;
$this->price_ttc = $price_ttc; $this->price_ttc = $price_ttc;
$this->price_min = $price_min; $this->price_min = $price_min;
@ -1487,33 +1504,15 @@ class Product extends CommonObject
* *
* @param int $expression_id Expression * @param int $expression_id Expression
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
* @deprecated Use Product::update instead
*/ */
function setPriceExpression($expression_id) function setPriceExpression($expression_id)
{ {
global $conf; global $user;
// Clean parameters $this->fk_price_expression = $expression_id;
$this->db->begin();
$expression_id = $expression_id != 0 ? $expression_id : 'NULL';
$sql = "UPDATE ".MAIN_DB_PREFIX."product"; return $this->update($this->id, $user);
$sql.= " SET fk_price_expression = ".$expression_id;
$sql.= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::setPriceExpression", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
$this->db->commit();
return 1;
}
else
{
$this->error=$this->db->error()." sql=".$sql;
$this->db->rollback();
return -1;
}
} }
/** /**
@ -2196,9 +2195,10 @@ class Product extends CommonObject
* *
* @param int $socid Limit count on a particular third party id * @param int $socid Limit count on a particular third party id
* @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities
* @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only
* @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11
*/ */
function get_nb_vente($socid,$mode) function get_nb_vente($socid, $mode, $filteronproducttype=-1)
{ {
global $conf; global $conf;
global $user; global $user;
@ -2206,9 +2206,11 @@ class Product extends CommonObject
$sql = "SELECT sum(d.qty), date_format(f.datef, '%Y%m')"; $sql = "SELECT sum(d.qty), date_format(f.datef, '%Y%m')";
if ($mode == 'bynumber') $sql.= ", count(DISTINCT f.rowid)"; if ($mode == 'bynumber') $sql.= ", count(DISTINCT f.rowid)";
$sql.= " FROM ".MAIN_DB_PREFIX."facturedet as d, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX."facturedet as d, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE f.rowid = d.fk_facture"; $sql.= " WHERE f.rowid = d.fk_facture";
$sql.= " AND d.fk_product =".$this->id; if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id;
if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype;
$sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND f.fk_soc = s.rowid";
$sql.= " AND f.entity IN (".getEntity('facture', 1).")"; $sql.= " AND f.entity IN (".getEntity('facture', 1).")";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
@ -2225,9 +2227,10 @@ class Product extends CommonObject
* *
* @param int $socid Limit count on a particular third party id * @param int $socid Limit count on a particular third party id
* @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities
* @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only
* @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11
*/ */
function get_nb_achat($socid,$mode) function get_nb_achat($socid, $mode, $filteronproducttype=-1)
{ {
global $conf; global $conf;
global $user; global $user;
@ -2235,9 +2238,11 @@ class Product extends CommonObject
$sql = "SELECT sum(d.qty), date_format(f.datef, '%Y%m')"; $sql = "SELECT sum(d.qty), date_format(f.datef, '%Y%m')";
if ($mode == 'bynumber') $sql.= ", count(DISTINCT f.rowid)"; if ($mode == 'bynumber') $sql.= ", count(DISTINCT f.rowid)";
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as d, ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as d, ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s";
if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE f.rowid = d.fk_facture_fourn"; $sql.= " WHERE f.rowid = d.fk_facture_fourn";
$sql.= " AND d.fk_product =".$this->id; if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id;
if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype;
$sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND f.fk_soc = s.rowid";
$sql.= " AND f.entity IN (".getEntity('facture_fourn', 1).")"; $sql.= " AND f.entity IN (".getEntity('facture_fourn', 1).")";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
@ -2254,9 +2259,10 @@ class Product extends CommonObject
* *
* @param int $socid Limit count on a particular third party id * @param int $socid Limit count on a particular third party id
* @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities
* @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only
* @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11
*/ */
function get_nb_propal($socid,$mode) function get_nb_propal($socid, $mode, $filteronproducttype=-1)
{ {
global $conf; global $conf;
global $user; global $user;
@ -2264,9 +2270,11 @@ class Product extends CommonObject
$sql = "SELECT sum(d.qty), date_format(p.datep, '%Y%m')"; $sql = "SELECT sum(d.qty), date_format(p.datep, '%Y%m')";
if ($mode == 'bynumber') $sql.= ", count(DISTINCT p.rowid)"; if ($mode == 'bynumber') $sql.= ", count(DISTINCT p.rowid)";
$sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."societe as s";
if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as prod";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE p.rowid = d.fk_propal"; $sql.= " WHERE p.rowid = d.fk_propal";
$sql.= " AND d.fk_product =".$this->id; if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id;
if ($filteronproducttype >= 0) $sql.= " AND prod.rowid = d.fk_product AND prod.fk_product_type =".$filteronproducttype;
$sql.= " AND p.fk_soc = s.rowid"; $sql.= " AND p.fk_soc = s.rowid";
$sql.= " AND p.entity IN (".getEntity('propal', 1).")"; $sql.= " AND p.entity IN (".getEntity('propal', 1).")";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
@ -2282,18 +2290,21 @@ class Product extends CommonObject
* *
* @param int $socid Limit count on a particular third party id * @param int $socid Limit count on a particular third party id
* @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities
* @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only
* @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11
*/ */
function get_nb_order($socid,$mode) function get_nb_order($socid, $mode, $filteronproducttype=-1)
{ {
global $conf, $user; global $conf, $user;
$sql = "SELECT sum(d.qty), date_format(c.date_commande, '%Y%m')"; $sql = "SELECT sum(d.qty), date_format(c.date_commande, '%Y%m')";
if ($mode == 'bynumber') $sql.= ", count(DISTINCT c.rowid)"; if ($mode == 'bynumber') $sql.= ", count(DISTINCT c.rowid)";
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as d, ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as d, ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s";
if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.rowid = d.fk_commande"; $sql.= " WHERE c.rowid = d.fk_commande";
$sql.= " AND d.fk_product =".$this->id; if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id;
if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype;
$sql.= " AND c.fk_soc = s.rowid"; $sql.= " AND c.fk_soc = s.rowid";
$sql.= " AND c.entity IN (".getEntity('commande', 1).")"; $sql.= " AND c.entity IN (".getEntity('commande', 1).")";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
@ -2309,18 +2320,21 @@ class Product extends CommonObject
* *
* @param int $socid Limit count on a particular third party id * @param int $socid Limit count on a particular third party id
* @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities
* @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only
* @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11
*/ */
function get_nb_ordersupplier($socid,$mode) function get_nb_ordersupplier($socid, $mode, $filteronproducttype=-1)
{ {
global $conf, $user; global $conf, $user;
$sql = "SELECT sum(d.qty), date_format(c.date_commande, '%Y%m')"; $sql = "SELECT sum(d.qty), date_format(c.date_commande, '%Y%m')";
if ($mode == 'bynumber') $sql.= ", count(DISTINCT c.rowid)"; if ($mode == 'bynumber') $sql.= ", count(DISTINCT c.rowid)";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as d, ".MAIN_DB_PREFIX."commande_fournisseur as c, ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as d, ".MAIN_DB_PREFIX."commande_fournisseur as c, ".MAIN_DB_PREFIX."societe as s";
if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.rowid = d.fk_commande"; $sql.= " WHERE c.rowid = d.fk_commande";
$sql.= " AND d.fk_product =".$this->id; if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id;
if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype;
$sql.= " AND c.fk_soc = s.rowid"; $sql.= " AND c.fk_soc = s.rowid";
$sql.= " AND c.entity IN (".getEntity('commande_fournisseur', 1).")"; $sql.= " AND c.entity IN (".getEntity('commande_fournisseur', 1).")";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
@ -3485,9 +3499,10 @@ class Product extends CommonObject
* @param int $showaction 1=Show icon with action links (resize, delete) * @param int $showaction 1=Show icon with action links (resize, delete)
* @param int $maxHeight Max height of image when size=1 * @param int $maxHeight Max height of image when size=1
* @param int $maxWidth Max width of image when size=1 * @param int $maxWidth Max width of image when size=1
* @param int $nolink Do not add a href link to view enlarged imaged into a new tab
* @return string Html code to show photo. Number of photos shown is saved in this->nbphoto * @return string Html code to show photo. Number of photos shown is saved in this->nbphoto
*/ */
function show_photos($sdir,$size=0,$nbmax=0,$nbbyrow=5,$showfilename=0,$showaction=0,$maxHeight=120,$maxWidth=160) function show_photos($sdir,$size=0,$nbmax=0,$nbbyrow=5,$showfilename=0,$showaction=0,$maxHeight=120,$maxWidth=160,$nolink=0)
{ {
global $conf,$user,$langs; global $conf,$user,$langs;
@ -3552,7 +3567,7 @@ class Product extends CommonObject
else if ($nbbyrow < 0) $return .= '<div class="inline-block">'; else if ($nbbyrow < 0) $return .= '<div class="inline-block">';
$return.= "\n"; $return.= "\n";
$return.= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" class="aphoto" target="_blank">'; if (empty($nolink)) $return.= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" class="aphoto" target="_blank">';
// Show image (width height=$maxHeight) // Show image (width height=$maxHeight)
// Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine // Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine
@ -3568,7 +3583,8 @@ class Product extends CommonObject
$return.= '<img class="photo photowithmargin" border="0" '.($conf->dol_use_jmobile?'max-height':'height').'="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">'; $return.= '<img class="photo photowithmargin" border="0" '.($conf->dol_use_jmobile?'max-height':'height').'="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">';
} }
$return.= '</a>'."\n"; if (empty($nolink)) $return.= '</a>';
$return.="\n";
if ($showfilename) $return.= '<br>'.$viewfilename; if ($showfilename) $return.= '<br>'.$viewfilename;
if ($showaction) if ($showaction)
@ -3788,7 +3804,7 @@ class Product extends CommonObject
* *
* @return boolean True if it's a product * @return boolean True if it's a product
*/ */
function isproduct() function isProduct()
{ {
return ($this->type == Product::TYPE_PRODUCT ? true : false); return ($this->type == Product::TYPE_PRODUCT ? true : false);
} }
@ -3798,7 +3814,7 @@ class Product extends CommonObject
* *
* @return boolean True if it's a service * @return boolean True if it's a service
*/ */
function isservice() function isService()
{ {
return ($this->type == Product::TYPE_SERVICE ? true : false); return ($this->type == Product::TYPE_SERVICE ? true : false);
} }
@ -4072,4 +4088,19 @@ class Product extends CommonObject
return 1; return 1;
} }
/**
* Returns the rights used for this class
* @return stdClass
*/
public function getRights()
{
global $user;
if ($this->isProduct()) {
return $user->rights->produit;
} else {
return $user->rights->service;
}
}
} }

View File

@ -193,8 +193,8 @@ if ($id > 0 || ! empty($ref))
print "<tr>"; print "<tr>";
$nblignes=6; $nblignes=6;
if ($object->isproduct() && ! empty($conf->stock->enabled)) $nblignes++; if ($object->isProduct() && ! empty($conf->stock->enabled)) $nblignes++;
if ($object->isservice()) $nblignes++; if ($object->isService()) $nblignes++;
// Reference // Reference
print '<td width="25%">'.$langs->trans("Ref").'</td><td>'; print '<td width="25%">'.$langs->trans("Ref").'</td><td>';

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