Merge remote-tracking branch 'Upstream/develop' into develop-hrm

This commit is contained in:
aspangaro 2015-11-11 08:20:12 +01:00
commit ca0c68a8e2
160 changed files with 4532 additions and 15168 deletions

View File

@ -290,6 +290,12 @@ source_file = htdocs/langs/en_US/propal.lang
source_lang = en_US
type = MOZILLAPROPERTIES
[dolibarr.receiptprinter]
file_filter = htdocs/langs/<lang>/receiptprinter.lang
source_file = htdocs/langs/en_US/receiptprinter.lang
source_lang = en_US
type = MOZILLAPROPERTIES
[dolibarr.resource]
file_filter = htdocs/langs/<lang>/resource.lang
source_file = htdocs/langs/en_US/resource.lang

View File

@ -16,6 +16,7 @@ AdoDb-Date 0.33 Modified BSD License Yes
ChromePHP 4.1.0 Apache Software License 2.0 Yes Return server log to chrome browser console
CKEditor 4.3.3 LGPL-2.1+ Yes Editor WYSIWYG
EvalMath 1.0 BSD Yes Safe math expressions evaluation
Escpos-php MIT License Yes Thermal receipt printer library, for use with ESC/POS compatible printers
FirePHPCore 0.4.0 MIT License Yes Send logs to Firefox Firebug console
FPDI 1.5.2 Apache Software License 2.0 Yes PDF templates management
GeoIP 1.4 LGPL-2.1+ Yes Sample code to make geoip convert (not into deb package)

View File

@ -239,7 +239,7 @@ http://packages.qa.debian.org/t/tcpdf.html
##### 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
> 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).
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.
* 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:

View File

@ -17,6 +17,7 @@
"ext-curl": "*",
"ccampbell/chromephp": "^4.1",
"ckeditor/ckeditor": "4.3.3",
"mike42/escpos-php": "dev-master",
"mobiledetect/mobiledetectlib": "2.8.3",
"phpoffice/phpexcel": "1.8.0",
"restler/framework": "^3.0",

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",
"This file is @generated automatically"
],
"hash": "f441e6348ae7862942693cab10810418",
"hash": "d88b5c84a9ea1af354d867ba2e2ab251",
"content-hash": "85e60ec7f8ab593387c7bd10d8db860d",
"packages": [
{
"name": "ccampbell/chromephp",
@ -126,6 +127,64 @@
"homepage": "https://github.com/firephp/firephp-core",
"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",
"version": "2.8.3",
@ -424,13 +483,16 @@
"pdf417",
"qrcode"
],
"abandoned": "tecnickcom/tcpdf",
"time": "2015-01-28 18:51:40"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"stability-flags": {
"mike42/escpos-php": 20
},
"prefer-stable": false,
"prefer-lowest": false,
"platform": {

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

@ -15,6 +15,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*
* Get a distant dump file and load it into a mysql database
*/
$sapi_type = php_sapi_name();
@ -32,9 +34,10 @@ $error=0;
$sourceserver=isset($argv[1])?$argv[1]:''; // user@server:/src/file
$password=isset($argv[2])?$argv[2]:'';
$database=isset($argv[3])?$argv[3]:'';
$loginbase=isset($argv[4])?$argv[4]:'';
$passwordbase=isset($argv[5])?$argv[5]:'';
$dataserver=isset($argv[3])?$argv[3]:'';
$database=isset($argv[4])?$argv[4]:'';
$loginbase=isset($argv[5])?$argv[5]:'';
$passwordbase=isset($argv[6])?$argv[6]:'';
// Include Dolibarr environment
$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))
{
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 "Warning, this script may take a long time.\n";
exit(-1);
@ -108,14 +111,14 @@ if ($connection)
print 'Get file '.$sourcefile.' into '.$targetdir.$targetfile."\n";
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))
{
$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))
{
$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";
$output=array();

View File

@ -450,186 +450,225 @@ else $error++;
//--------------------------------
// Build skeleton_script.php
//--------------------------------
//--------------------------------------------------------------------
// Build skeleton_script.php, skeleton_list.php and skeleton_card.php
//--------------------------------------------------------------------
// Read skeleton_script.php file
$skeletonfile=$path.'skeleton_script.php';
$sourcecontent=file_get_contents($skeletonfile);
if (! $sourcecontent)
$skeletonfiles=array(
$path.'skeleton_script.php' => 'out.'.$classmin.'_script.php',
$path.'skeleton_list.php' => 'out.'.$classmin.'_list.php',
$path.'skeleton_card.php' => 'out.'.$classmin.'_card.php'
);
foreach ($skeletonfiles as $skeletonfile => $outfile)
{
print "\n";
print "Error: Failed to read skeleton sample '".$skeletonfile."'\n";
print "Try to run script from skeletons directory.\n";
exit;
$sourcecontent=file_get_contents($skeletonfile);
if (! $sourcecontent)
{
print "\n";
print "Error: Failed to read skeleton sample '".$skeletonfile."'\n";
print "Try to run script from skeletons directory.\n";
exit;
}
// Define output variables
$targetcontent=$sourcecontent;
// Substitute module name
$targetcontent=preg_replace('/dev\/skeletons/', $module, $targetcontent);
$targetcontent=preg_replace('/mymodule othermodule1 othermodule2/', $module, $targetcontent);
$targetcontent=preg_replace('/mymodule/', $module, $targetcontent);
// Substitute class name
$targetcontent=preg_replace('/skeleton_class\.class\.php/', $classmin.'.class.php', $targetcontent);
$targetcontent=preg_replace('/skeleton_script\.php/', $classmin.'_script.php', $targetcontent);
$targetcontent=preg_replace('/\$element = \'skeleton\'/', '\$element=\''.$classmin.'\'', $targetcontent);
$targetcontent=preg_replace('/\$table_element = \'skeleton\'/', '\$table_element=\''.$classmin.'\'', $targetcontent);
$targetcontent=preg_replace('/Skeleton_Class/', $classname, $targetcontent);
$targetcontent=preg_replace('/skeletons/', $classmin, $targetcontent);
$targetcontent=preg_replace('/skeleton/', $classmin, $targetcontent);
// Substitute comments
$targetcontent=preg_replace('/This file is an example to create a new class file/', 'Put here description of this class', $targetcontent);
$targetcontent=preg_replace('/\s*\/\/\.\.\./', '', $targetcontent);
$targetcontent=preg_replace('/Put here some comments/','Initialy built by build_class_from_table on '.strftime('%Y-%m-%d %H:%M',mktime()), $targetcontent);
// Substitute table name
$targetcontent=preg_replace('/MAIN_DB_PREFIX."mytable/', 'MAIN_DB_PREFIX."'.$tablenoprefix, $targetcontent);
// Substitute GETPOST search_fieldx
$varprop="\n";
$cleanparam='';
foreach($property as $key => $prop)
{
if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime'])
{
if ($prop['isint']) $varprop.='$search_'.$prop['field']."=GETPOST('search_".$prop['field']."','int');\n";
else $varprop.='$search_'.$prop['field']."=GETPOST('search_".$prop['field']."','alpha');\n";
}
}
$targetcontent=preg_replace('/'.preg_quote('$search_field1=GETPOST("search_field1");','/').'/', $varprop, $targetcontent);
$targetcontent=preg_replace('/'.preg_quote('$search_field2=GETPOST("search_field2");','/').'/', '', $targetcontent);
// Substitute GETPOST fieldx
$varprop="\n";
$cleanparam='';
foreach($property as $key => $prop)
{
if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime'])
{
if ($prop['isint']) $varprop.="\t\$object->".$prop['field']."=GETPOST('".$prop['field']."','int');\n";
else $varprop.="\t\$object->".$prop['field']."=GETPOST('".$prop['field']."','alpha');\n";
}
}
$targetcontent=preg_replace('/'.preg_quote('$object->prop1=GETPOST("field1");','/').'/', $varprop, $targetcontent);
$targetcontent=preg_replace('/'.preg_quote('$object->prop2=GETPOST("field2");','/').'/', '', $targetcontent);
// Substitute reset search_field = '';
$varprop="\n";
$cleanparam='';
foreach($property as $key => $prop)
{
if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime'])
{
$varprop.='$search_'.$prop['field']."='';\n";
}
}
$targetcontent=preg_replace('/'.preg_quote('$search_field1=\'\';','/').'/', $varprop, $targetcontent);
$targetcontent=preg_replace('/'.preg_quote('$search_field2=\'\';','/').'/', '', $targetcontent);
// Substitute fetch/select parameters
$targetcontent=preg_replace('/\$sql\s*\.= " t\.field1,";/', $varpropselect, $targetcontent);
$targetcontent=preg_replace('/\$sql\s*\.= " t\.field2";/', '', $targetcontent);
// Substitute where for search
$varprop="\n";
$cleanparam='';
foreach($property as $key => $prop)
{
if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime'])
{
$varprop.='if ($search_'.$prop['field'].') $sql.= natural_search("'.$prop['field'].'",$search_'.$prop['field'].');'."\n";
}
}
$targetcontent=preg_replace('/'.preg_quote('if ($search_field1) $sql.= natural_search("field1",$search_field1);','/').'/', $varprop, $targetcontent);
$targetcontent=preg_replace('/'.preg_quote('if ($search_field2) $sql.= natural_search("field2",$search_field2);','/').'/', '', $targetcontent);
// substitute $params.=
$varprop="\n";
$cleanparam='';
foreach($property as $key => $prop)
{
if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime'])
{
$varprop.="if (\$search_".$prop['field']." != '') \$params.= '&amp;search_".$prop['field']."='.urlencode(\$search_".$prop['field'].");\n";
}
}
$targetcontent=preg_replace('/'.preg_quote("if (\$search_field1 != '') \$params.= '&amp;search_field1='.urlencode(\$search_field1);",'/').'/', $varprop, $targetcontent);
$targetcontent=preg_replace('/'.preg_quote("if (\$search_field2 != '') \$params.= '&amp;search_field2='.urlencode(\$search_field2);",'/').'/', '', $targetcontent);
// Substitute arrayfields
$varprop="\n";
$cleanparam='';
foreach($property as $key => $prop)
{
if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime'])
{
$varprop.="'t.".$prop['field']."'=>array('label'=>\$langs->trans(\"Field".$prop['field']."\"), 'checked'=>1),\n";
}
}
$targetcontent=preg_replace('/'.preg_quote("'t.field1'=>array('label'=>\$langs->trans(\"Field1\"), 'checked'=>1),",'/').'/', $varprop, $targetcontent);
$targetcontent=preg_replace('/'.preg_quote("'t.field2'=>array('label'=>\$langs->trans(\"Field2\"), 'checked'=>1),",'/').'/', '', $targetcontent);
// Substitute print_liste_field_titre
$varprop="\n";
$cleanparam='';
foreach($property as $key => $prop)
{
if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime'])
{
$varprop.="if (! empty(\$arrayfields['t.".$prop['field']."']['checked'])) print_liste_field_titre(\$arrayfields['t.".$prop['field']."']['label'],\$_SERVER['PHP_SELF'],'t.".$prop['field']."','',\$param,'',\$sortfield,\$sortorder);\n";
}
}
$targetcontent=preg_replace('/'.preg_quote("if (! empty(\$arrayfields['t.field1']['checked'])) print_liste_field_titre(\$langs->trans('field1'),\$_SERVER['PHP_SELF'],'t.field1','',\$param,'',\$sortfield,\$sortorder);",'/').'/', $varprop, $targetcontent);
$targetcontent=preg_replace('/'.preg_quote("if (! empty(\$arrayfields['t.field2']['checked'])) print_liste_field_titre(\$langs->trans('field2'),\$_SERVER['PHP_SELF'],'t.field2','',\$param,'',\$sortfield,\$sortorder);",'/').'/', '', $targetcontent);
// Substitute fields title search
$varprop="\n";
$cleanparam='';
foreach($property as $key => $prop)
{
if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime'])
{
$varprop.="if (! empty(\$arrayfields['t.".$prop['field']."']['checked'])) print '<td class=\"liste_titre\"><input type=\"text\" class=\"flat\" name=\"search_".$prop['field']."\" value=\"'.\$search_".$prop['field'].".'\" size=\"10\"></td>';\n";
}
}
$targetcontent=preg_replace('/'.preg_quote("if (! empty(\$arrayfields['t.field1']['checked'])) print '<td class=\"liste_titre\"><input type=\"text\" class=\"flat\" name=\"search_field1\" value=\"'.\$search_field1.'\" size=\"10\"></td>';",'/').'/', $varprop, $targetcontent);
$targetcontent=preg_replace('/'.preg_quote("if (! empty(\$arrayfields['t.field2']['checked'])) print '<td class=\"liste_titre\"><input type=\"text\" class=\"flat\" name=\"search_field2\" value=\"'.\$search_field2.'\" size=\"10\"></td>';",'/').'/', '', $targetcontent);
// Substitute where for <td>.fieldx.</td>
$varprop="\n";
$cleanparam='';
foreach($property as $key => $prop)
{
if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime'])
{
$varprop.="if (! empty(\$arrayfields['t.".$prop['field']."']['checked'])) print '<td>'.\$obj->".$prop['field'].".'</td>';\n";
}
}
$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);
// LIST_OF_TD_LABEL_FIELDS_CREATE - 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=\"'.GETPOST('".$prop['field']."').'\"></td></tr>';\n";
}
}
$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);
// LIST_OF_TD_LABEL_FIELDS_VIEW - 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>\$object->".$prop['field']."</td></tr>';\n";
}
}
$targetcontent=preg_replace('/LIST_OF_TD_LABEL_FIELDS_VIEW/', $varprop, $targetcontent);
// Build file
$fp=fopen($outfile,"w");
if ($fp)
{
fputs($fp, $targetcontent);
fclose($fp);
print "File '".$outfile."' has been built in current directory.\n";
}
else $error++;
}
// Define output variables
$outfile='out.'.$classmin.'_script.php';
$targetcontent=$sourcecontent;
// Substitute module name
$targetcontent=preg_replace('/dev\/skeletons/', $module, $targetcontent);
$targetcontent=preg_replace('/mymodule othermodule1 othermodule2/', $module, $targetcontent);
$targetcontent=preg_replace('/mymodule/', $module, $targetcontent);
// Substitute class name
$targetcontent=preg_replace('/skeleton_class\.class\.php/', $classmin.'.class.php', $targetcontent);
$targetcontent=preg_replace('/skeleton_script\.php/', $classmin.'_script.php', $targetcontent);
$targetcontent=preg_replace('/\$element = \'skeleton\'/', '\$element=\''.$classmin.'\'', $targetcontent);
$targetcontent=preg_replace('/\$table_element = \'skeleton\'/', '\$table_element=\''.$classmin.'\'', $targetcontent);
$targetcontent=preg_replace('/Skeleton_Class/', $classname, $targetcontent);
$targetcontent=preg_replace('/skeletons/', $classmin, $targetcontent);
$targetcontent=preg_replace('/skeleton/', $classmin, $targetcontent);
// Substitute comments
$targetcontent=preg_replace('/This file is an example to create a new class file/', 'Put here description of this class', $targetcontent);
$targetcontent=preg_replace('/\s*\/\/\.\.\./', '', $targetcontent);
$targetcontent=preg_replace('/Put here some comments/','Initialy built by build_class_from_table on '.strftime('%Y-%m-%d %H:%M',mktime()), $targetcontent);
// Substitute table name
$targetcontent=preg_replace('/MAIN_DB_PREFIX."mytable/', 'MAIN_DB_PREFIX."'.$tablenoprefix, $targetcontent);
// Build file
$fp=fopen($outfile,"w");
if ($fp)
{
fputs($fp, $targetcontent);
fclose($fp);
print "File '".$outfile."' has been built in current directory.\n";
}
else $error++;
//--------------------------------
// Build skeleton_page.php
//--------------------------------
// Read skeleton_page.php file
$skeletonfile=$path.'skeleton_page.php';
$sourcecontent=file_get_contents($skeletonfile);
if (! $sourcecontent)
{
print "\n";
print "Error: Failed to read skeleton sample '".$skeletonfile."'\n";
print "Try to run script from skeletons directory.\n";
exit;
}
// Define output variables
$outfile='out.'.$classmin.'_page.php';
$targetcontent=$sourcecontent;
// Substitute module name
$targetcontent=preg_replace('/dev\/skeletons/', $module, $targetcontent);
$targetcontent=preg_replace('/mymodule othermodule1 othermodule2/', $module, $targetcontent);
$targetcontent=preg_replace('/mymodule/', $module, $targetcontent);
// Substitute class name
$targetcontent=preg_replace('/skeleton_class\.class\.php/', $classmin.'.class.php', $targetcontent);
$targetcontent=preg_replace('/skeleton_script\.php/', $classmin.'_script.php', $targetcontent);
$targetcontent=preg_replace('/\$element = \'skeleton\'/', '\$element=\''.$classmin.'\'', $targetcontent);
$targetcontent=preg_replace('/\$table_element = \'skeleton\'/', '\$table_element=\''.$classmin.'\'', $targetcontent);
$targetcontent=preg_replace('/Skeleton_Class/', $classname, $targetcontent);
$targetcontent=preg_replace('/skeletons/', $classmin, $targetcontent);
$targetcontent=preg_replace('/skeleton/', $classmin, $targetcontent);
// Substitute comments
$targetcontent=preg_replace('/This file is an example to create a new class file/', 'Put here description of this class', $targetcontent);
$targetcontent=preg_replace('/\s*\/\/\.\.\./', '', $targetcontent);
$targetcontent=preg_replace('/Put here some comments/','Initialy built by build_class_from_table on '.strftime('%Y-%m-%d %H:%M',mktime()), $targetcontent);
// Substitute table name
$targetcontent=preg_replace('/MAIN_DB_PREFIX."mytable/', 'MAIN_DB_PREFIX."'.$tablenoprefix, $targetcontent);
// Substitute GETPOST search_fieldx
$varprop="\n";
$cleanparam='';
foreach($property as $key => $prop)
{
if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime'])
{
if ($prop['isint']) $varprop.='$search_'.$prop['field']."=GETPOST('search_".$prop['field']."','int');\n";
else $varprop.='$search_'.$prop['field']."=GETPOST('search_".$prop['field']."','alpha');\n";
}
}
$targetcontent=preg_replace('/'.preg_quote('$search_field1=GETPOST("search_field1");','/').'/', $varprop, $targetcontent);
$targetcontent=preg_replace('/'.preg_quote('$search_field2=GETPOST("search_field2");','/').'/', '', $targetcontent);
// Substitute GETPOST fieldx
$varprop="\n";
$cleanparam='';
foreach($property as $key => $prop)
{
if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime'])
{
if ($prop['isint']) $varprop.="\t\$object->".$prop['field']."=GETPOST('".$prop['field']."','int');\n";
else $varprop.="\t\$object->".$prop['field']."=GETPOST('".$prop['field']."','alpha');\n";
}
}
$targetcontent=preg_replace('/'.preg_quote('$object->prop1=GETPOST("field1");','/').'/', $varprop, $targetcontent);
$targetcontent=preg_replace('/'.preg_quote('$object->prop2=GETPOST("field2");','/').'/', '', $targetcontent);
// Substitute fetch/select parameters
$targetcontent=preg_replace('/\$sql\s*\.= " t\.field1,";/', $varpropselect, $targetcontent);
$targetcontent=preg_replace('/\$sql\s*\.= " t\.field2";/', '', $targetcontent);
// Substitute where for search
$varprop="\n";
$cleanparam='';
foreach($property as $key => $prop)
{
if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime'])
{
$varprop.='if ($search_'.$prop['field'].') $sql.= natural_search("'.$prop['field'].'",$search_'.$prop['field'].');'."\n";
}
}
$targetcontent=preg_replace('/'.preg_quote('if ($search_field1) $sql.= natural_search("field1",$search_field1);','/').'/', $varprop, $targetcontent);
$targetcontent=preg_replace('/'.preg_quote('if ($search_field2) $sql.= natural_search("field2",$search_field2);','/').'/', '', $targetcontent);
// Substitute print_liste_field_titre
$varprop="\n";
$cleanparam='';
foreach($property as $key => $prop)
{
if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime'])
{
$varprop.="print_liste_field_titre(\$langs->trans('".$prop['field']."'),\$_SERVER['PHP_SELF'],'t.".$prop['field']."','',\$param,'',\$sortfield,\$sortorder);\n";
}
}
$targetcontent=preg_replace('/'.preg_quote("print_liste_field_titre(\$langs->trans('field1'),\$_SERVER['PHP_SELF'],'t.field1','',\$param,'',\$sortfield,\$sortorder);",'/').'/', $varprop, $targetcontent);
$targetcontent=preg_replace('/'.preg_quote("print_liste_field_titre(\$langs->trans('field2'),\$_SERVER['PHP_SELF'],'t.field1','',\$param,'',\$sortfield,\$sortorder);",'/').'/', '', $targetcontent);
// Substitute where for <td>.fieldx.</td>
$varprop="\n";
$cleanparam='';
foreach($property as $key => $prop)
{
if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime'])
{
$varprop.="print '<td>'.\$obj->".$prop['field'].".'</td>';\n";
}
}
$targetcontent=preg_replace('/'.preg_quote("print '<td>'.\$obj->field1.'</td>';",'/').'/', $varprop, $targetcontent);
$targetcontent=preg_replace('/'.preg_quote("print '<td>'.\$obj->field2.'</td>';",'/').'/', '', $targetcontent);
// Build file
$fp=fopen($outfile,"w");
if ($fp)
{
fputs($fp, $targetcontent);
fclose($fp);
print "File '".$outfile."' has been built in current directory.\n";
}
else $error++;
// -------------------- END OF BUILD_CLASS_FROM_TABLE SCRIPT --------------------
print "You can now rename generated files by removing the 'out.' prefix in their name and store them into directory /yourmodule/class.\n";
print "You can now rename generated files by removing the 'out.' prefix in their name and store them into directory /yourmodule/class (for .class.php file) or /yourmodule.\n";
return $error;

View File

@ -17,7 +17,7 @@
*/
/**
* \file dev/skeletons/skeleton_page.php
* \file dev/skeletons/skeleton_card.php
* \ingroup mymodule othermodule1 othermodule2
* \brief This file is an example of a php page
* Put here some comments
@ -47,7 +47,7 @@ include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
dol_include_once('/mymodule/class/skeleton_class.class.php');
// Load traductions files requiredby by page
$langs->load("companies");
$langs->load("mymodule");
$langs->load("other");
// Get parameters
@ -184,7 +184,7 @@ if (empty($reshook))
{
// Delete OK
setEventMessages("RecordDeleted", null, 'mesgs');
header("Location: ".dol_buildpath('/buildingmanagement/list.php',1));
header("Location: ".dol_buildpath('/mymodule/list.php',1));
exit;
}
else
@ -227,131 +227,10 @@ jQuery(document).ready(function() {
</script>';
// Part to show a list
if ($action == 'list' || (empty($id) && $action != 'create'))
{
// Put here content of your page
print load_fiche_titre('PageTitle');
$sql = "SELECT";
$sql.= " t.rowid,";
$sql.= " t.field1,";
$sql.= " t.field2";
// Add fields for extrafields
foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key;
// Add fields from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql.= " FROM ".MAIN_DB_PREFIX."mytable as t";
$sql.= " WHERE 1 = 1";
if ($search_field1) $sql.= natural_search("field1",$search_field1);
if ($search_field2) $sql.= natural_search("field2",$search_field2);
// Add where from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
// Count total nb of records
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
$sql.= $db->order($sortfield, $sortorder);
$sql.= $db->plimit($conf->liste_limit+1, $offset);
dol_syslog($script_file, LOG_DEBUG);
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$params='';
$params.= '&amp;search_field1='.urlencode($search_field1);
$params.= '&amp;search_field2='.urlencode($search_field2);
print_barre_liste($title, $page, $_SERVER["PHP_SELF"],$params,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_companies');
print '<form method="GET" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if (! empty($moreforfilter))
{
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '</div>';
}
print '<table class="liste">'."\n";
// Fields title
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans('field1'),$_SERVER['PHP_SELF'],'t.field1','',$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('field2'),$_SERVER['PHP_SELF'],'t.field2','',$param,'',$sortfield,$sortorder);
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '</tr>'."\n";
// Fields title search
print '<tr class="liste_titre">';
print '<td class="liste_titre"><input type="text" class="flat" name="search_field1" value="'.$search_field1.'" size="10"></td>';
print '<td class="liste_titre"><input type="text" class="flat" name="search_field2" value="'.$search_field2.'" size="10"></td>';
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '</tr>'."\n";
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
if ($obj)
{
// You can use here results
print '<tr>';
print '<td>'.$obj->field1.'</td>';
print '<td>'.$obj->field2.'</td>';
$parameters=array('obj' => $obj);
$reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '</tr>';
}
$i++;
}
$db->free($resql);
$parameters=array('sql' => $sql);
$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print "</table>\n";
print "</form>\n";
}
else
{
$error++;
dol_print_error($db);
}
}
// Part to create
if ($action == 'create')
{
print load_fiche_titre($langs->trans("NewSkeleton"));
print load_fiche_titre($langs->trans("NewMyModule"));
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="action" value="add">';
@ -360,10 +239,8 @@ if ($action == 'create')
dol_fiche_head();
print '<table class="border centpercent">'."\n";
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td>';
print '<input class="flat" type="text" size="36" name="label" value="'.$label.'">';
print '</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_CREATE
print '</table>'."\n";
dol_fiche_end();
@ -378,17 +255,25 @@ if ($action == 'create')
// Part to edit record
if (($id || $ref) && $action == 'edit')
{
print load_fiche_titre($langs->trans("MyModule"));
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
dol_fiche_head();
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
dol_fiche_head();
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>';
// LIST_OF_TD_LABEL_FIELDS_EDIT
print '</table>';
dol_fiche_end();
print '<div class="center"><input type="submit" class="button" name="add" value="'.$langs->trans("Create").'"></div>';
print '<div class="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print ' &nbsp; <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>';
}
@ -396,12 +281,22 @@ if (($id || $ref) && $action == 'edit')
// 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"));
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 '<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
print '</table>';
dol_fiche_end();
@ -420,14 +315,7 @@ if ($id && (empty($action) || $action == 'view'))
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";

View File

@ -426,6 +426,101 @@ class Skeleton_Class extends CommonObject
}
}
/**
* Return a link to the user card (with optionaly the picto)
* Use this->id,this->lastname, this->firstname
*
* @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
* @param string $option On what the link point to
* @param integer $notooltip 1=Disable tooltip
* @param int $maxlen Max length of visible user name
* @param string $morecss Add more css on link
* @return string String with URL
*/
function getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='')
{
global $langs, $conf, $db;
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
$result = '';
$companylink = '';
$label = '<u>' . $langs->trans("MyModule") . '</u>';
$label.= '<div width="100%">';
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
$link = '<a href="'.DOL_URL_ROOT.'/mymodule/card.php?id='.$this->id.'"';
$link.= ($notooltip?'':' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip'.($morecss?' '.$morecss:'').'"');
$link.= '>';
$linkend='</a>';
if ($withpicto)
{
$result.=($link.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend);
if ($withpicto != 2) $result.=' ';
}
$result.= $link . $this->ref . $linkend;
return $result;
}
/**
* Retourne le libelle du status d'un user (actif, inactif)
*
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Label of status
*/
function getLibStatut($mode=0)
{
return $this->LibStatut($this->status,$mode);
}
/**
* Renvoi le libelle d'un status donne
*
* @param int $status Id status
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Label of status
*/
function LibStatut($status,$mode=0)
{
global $langs;
if ($mode == 0)
{
$prefix='';
if ($status == 1) return $langs->trans('Enabled');
if ($status == 0) return $langs->trans('Disabled');
}
if ($mode == 1)
{
if ($status == 1) return $langs->trans('Enabled');
if ($status == 0) return $langs->trans('Disabled');
}
if ($mode == 2)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
}
if ($mode == 3)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
}
if ($mode == 4)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
}
if ($mode == 5)
{
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
}
}
/**
* Initialise object with example values
* Id must be 0 if object instance is a specimen

View File

@ -0,0 +1,439 @@
<?php
/* Copyright (C) 2007-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) ---Put here your own copyright and developer email---
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file dev/skeletons/skeleton_list.php
* \ingroup mymodule othermodule1 othermodule2
* \brief This file is an example of a php page
* Put here some comments
*/
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test
//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test
//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
// Change this following line to use the correct relative path (../, ../../, etc)
$res=0;
if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php'; // to work if your module directory is into dolibarr root htdocs directory
if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php'; // to work if your module directory is into a subdir of root htdocs directory
if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
if (! $res) die("Include of main fails");
// Change this following line to use the correct relative path from htdocs
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
dol_include_once('/mymodule/class/skeleton_class.class.php');
// Load traductions files requiredby by page
$langs->load("mymodule");
$langs->load("other");
// Get parameters
$id = GETPOST('id','int');
$action = GETPOST('action','alpha');
$backtopage = GETPOST('backtopage');
$myparam = GETPOST('myparam','alpha');
$search_field1=GETPOST("search_field1");
$search_field2=GETPOST("search_field2");
$optioncss = GETPOST('optioncss','alpha');
// Load variable for pagination
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');
if ($page == -1) { $page = 0; }
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) $sortfield="t.rowid"; // Set here default search field
if (! $sortorder) $sortorder="ASC";
// Protection if external user
$socid=0;
if ($user->societe_id > 0)
{
$socid = $user->societe_id;
//accessforbidden();
}
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
$hookmanager->initHooks(array('skeletonlist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('mymodule');
$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
// Load object if id or ref is provided as parameter
$object=new Skeleton_Class($db);
if (($id > 0 || ! empty($ref)) && $action != 'add')
{
$result=$object->fetch($id,$ref);
if ($result < 0) dol_print_error($db);
}
/*******************************************************************
* ACTIONS
*
* Put here all code to do according to value of "action" parameter
********************************************************************/
$parameters=array();
$reshook=$hookmanager->executeHooks('doActions',$parameters); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
{
$search_field1='';
$search_field2='';
$search_date_creation='';
$search_date_update='';
$search_array_options=array();
}
if (empty($reshook))
{
// Action to delete
if ($action == 'confirm_delete')
{
$result=$object->delete($user);
if ($result > 0)
{
// Delete OK
setEventMessages("RecordDeleted", null, 'mesgs');
header("Location: ".dol_buildpath('/mymodule/list.php',1));
exit;
}
else
{
if (! empty($object->errors)) setEventMessages(null,$object->errors,'errors');
else setEventMessages($object->error,null,'errors');
}
}
}
/***************************************************
* VIEW
*
* Put here all code to build page
****************************************************/
llxHeader('','MyPageName','');
$form=new Form($db);
// Put here content of your page
$title = $langs->trans('MyModuleListTitle');
// Example : Adding jquery code
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
function init_myfunc()
{
jQuery("#myid").removeAttr(\'disabled\');
jQuery("#myid").attr(\'disabled\',\'disabled\');
}
init_myfunc();
jQuery("#mybutton").click(function() {
init_myfunc();
});
});
</script>';
$sql = "SELECT";
$sql.= " t.rowid,";
$sql.= " t.field1,";
$sql.= " t.field2";
// Add fields for extrafields
foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key;
// Add fields from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql.= " FROM ".MAIN_DB_PREFIX."mytable as t";
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."mytable_extrafields as ef on (u.rowid = ef.fk_object)";
$sql.= " WHERE 1 = 1";
//$sql.= " WHERE u.entity IN (".getEntity('mytable',1).")";
if ($search_field1) $sql.= natural_search("field1",$search_field1);
if ($search_field2) $sql.= natural_search("field2",$search_field2);
if ($sall) $sql.= natural_search(array_keys($fieldstosearchall), $sall);
// Add where from extra fields
foreach ($search_array_options as $key => $val)
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
$typ=$extrafields->attribute_type[$tmpkey];
$mode=0;
if (in_array($typ, array('int'))) $mode=1; // Search on a numeric
if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit)))
{
$sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
}
}
// Add where from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql.=$db->order($sortfield,$sortorder);
//$sql.= $db->plimit($conf->liste_limit+1, $offset);
// Count total nb of records
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
$sql.= $db->plimit($conf->liste_limit+1, $offset);
dol_syslog($script_file, LOG_DEBUG);
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$params='';
if ($search_field1 != '') $params.= '&amp;search_field1='.urlencode($search_field1);
if ($search_field2 != '') $params.= '&amp;search_field2='.urlencode($search_field2);
if ($optioncss != '') $param.='&optioncss='.$optioncss;
// Add $param from extra fields
foreach ($search_array_options as $key => $val)
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
}
print_barre_liste($title, $page, $_SERVER["PHP_SELF"],$params,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_companies');
print '<form method="GET" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
if ($sall)
{
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
print $langs->trans("FilterOnInto", $sall, join(', ',$fieldstosearchall));
}
if (! empty($moreforfilter))
{
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
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;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
print '<table class="liste '.($moreforfilter?"listwithfilterbefore":"").'">';
// Fields title
print '<tr class="liste_titre">';
if (! empty($arrayfields['t.field1']['checked'])) print_liste_field_titre($langs->trans('field1'),$_SERVER['PHP_SELF'],'t.field1','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['t.field2']['checked'])) print_liste_field_titre($langs->trans('field2'),$_SERVER['PHP_SELF'],'t.field2','',$param,'',$sortfield,$sortorder);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
$align=$extrafields->getAlignFlag($key);
print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
}
}
}
// Hook fields
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (! empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($langs->trans("DateCreationShort"),$_SERVER["PHP_SELF"],"t.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($langs->trans("DateModificationShort"),$_SERVER["PHP_SELF"],"t.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
//if (! empty($arrayfields['t.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"t.status","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch ');
print '</tr>'."\n";
// Fields title search
print '<tr class="liste_titre">';
if (! empty($arrayfields['t.field1']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_field1" value="'.$search_field1.'" size="10"></td>';
if (! empty($arrayfields['t.field2']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_field2" value="'.$search_field2.'" size="10"></td>';
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked'])) print '<td class="liste_titre"></td>';
}
}
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (! empty($arrayfields['t.datec']['checked']))
{
// Date creation
print '<td class="liste_titre">';
print '</td>';
}
if (! empty($arrayfields['t.tms']['checked']))
{
// Date modification
print '<td class="liste_titre">';
print '</td>';
}
/*if (! empty($arrayfields['u.statut']['checked']))
{
// Status
print '<td class="liste_titre" align="center">';
print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut);
print '</td>';
}*/
// Action column
print '<td class="liste_titre" align="right">';
print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
print '</td>';
print '</tr>'."\n";
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
if ($obj)
{
// You can use here results
print '<tr>';
if (! empty($arrayfields['t.field1']['checked'])) print '<td>'.$obj->field1.'</td>';
if (! empty($arrayfields['t.field2']['checked'])) print '<td>'.$obj->field2.'</td>';
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
print '<td';
$align=$extrafields->getAlignFlag($key);
if ($align) print ' align="'.$align.'"';
print '>';
$tmpkey='options_'.$key;
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
print '</td>';
}
}
}
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
$reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Date creation
if (! empty($arrayfields['t.datec']['checked']))
{
print '<td align="center">';
print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
print '</td>';
}
// Date modification
if (! empty($arrayfields['t.tms']['checked']))
{
print '<td align="center">';
print dol_print_date($db->jdate($obj->date_update), 'dayhour');
print '</td>';
}
// Status
/*
if (! empty($arrayfields['u.statut']['checked']))
{
$userstatic->statut=$obj->statut;
print '<td align="center">'.$userstatic->getLibStatut(3).'</td>';
}*/
// Action column
print '<td></td>';
print '</tr>';
}
$i++;
}
$db->free($resql);
$parameters=array('sql' => $sql);
$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print "</table>\n";
print "</form>\n";
$db->free($result);
}
else
{
$error++;
dol_print_error($db);
}
// End of page
llxFooter();
$db->close();

View File

@ -162,7 +162,7 @@ foreach($dirbarcode as $reldir)
{
$filebis=$reg[1];
// Chargement de la classe de codage
// Loading encoding class
require_once $newdir.$file;
$classname = "mod".ucfirst($filebis);
$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'))
{
$listfield=explode(',',$tabfield[$id]);
@ -581,7 +581,12 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
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
if (isset($_POST["localtax1"]) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0
if (isset($_POST["localtax2"]) && empty($_POST["localtax2"])) $_POST["localtax2"]='0'; // If empty, we force to 0

View File

@ -344,7 +344,7 @@ foreach ($dirmodels as $reldir)
$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')
{
// Chargement de la classe de numerotation
// Charging the numbering class
require_once $dir.$filebis;
$module = new $classname($db);
@ -750,6 +750,20 @@ print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" /
print "</td></tr>\n";
print '</form>';
// Add js auto fill amount on paiement form
$var=! $var;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
print '<input type="hidden" name="action" value="set_FAC_AUTO_FILLJS" />';
print '<tr '.$bc[$var].'><td>';
print $langs->trans("JSOnPaimentBill");
print '</td><td width="60" align="center">';
print $form->selectyesno("FAC_AUTO_FILLJS",$conf->global->FAC_AUTO_FILLJS,1);
print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />';
print "</td></tr>\n";
print '</form>';
$var=! $var;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
@ -784,20 +798,6 @@ print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" /
print "</td></tr>\n";
print '</form>';
// Add js auto fill amount on paiement form
$var=! $var;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
print '<input type="hidden" name="action" value="set_FAC_AUTO_FILLJS" />';
print '<tr '.$bc[$var].'><td>';
print $langs->trans("JSOnPaimentBill");
print '</td><td width="60" align="center">';
print $form->selectyesno("FAC_AUTO_FILLJS",$conf->global->FAC_AUTO_FILLJS,1);
print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />';
print "</td></tr>\n";
print '</form>';
print '</table>';

View File

@ -27,6 +27,13 @@ require '../main.inc.php';
// required Class
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("oauth");
@ -36,6 +43,8 @@ if (!$user->admin)
$action = GETPOST('action', 'alpha');
// Supported OAUTH
$supportedoauth2array=array('OAUTH_GOOGLE_NAME');
// API access parameters OAUTH
$list = array (
array(
@ -297,11 +306,7 @@ print '<input type="hidden" name="action" value="update">';
dol_fiche_head(array(), '', '', 0, 'technic');
// 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
print $langs->trans("ListOfSupportedOauthProviders").'<br><br>';
print '<table class="noborder" width="100%">';
@ -309,12 +314,16 @@ $var = true;
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">';
// Api Name
$label = $langs->trans($key[0]);
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';
$var = !$var;

View File

@ -130,7 +130,7 @@ foreach ($dirmodels as $reldir)
$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')
{
// Chargement de la classe de numerotation
// Charging the numbering class
require_once $dir.$filebis;
$module = new $classname($db);

View File

@ -62,7 +62,8 @@ if ($action == 'update')
dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DESC"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_REF"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_PDF_USE_ISO_LOCATION", $_POST["MAIN_PDF_USE_ISO_LOCATION"],'chaine',0,'',$conf->entity);
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
exit;
}
@ -135,6 +136,12 @@ if ($action == 'edit') // Edit
print '<table summary="more" class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
// Hide VAT Intra on address
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowVATIntaInAddress").'</td><td>';
print $form->selectyesno('MAIN_TVAINTRA_NOT_IN_ADDRESS',(! empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS))?$conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS:0,1);
print '</td></tr>';
// Show prof id 1 in address into pdf
$var=!$var;
if (! $noCountryCode)
@ -223,12 +230,6 @@ if ($action == 'edit') // Edit
print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT',(! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))?$conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT:0,1);
print '</td></tr>';
// Hide Tva Intra on adress
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowVATIntaInAddress").'</td><td>';
print $form->selectyesno('MAIN_TVAINTRA_NOT_IN_ADDRESS',(! empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS))?$conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS:0,1);
print '</td></tr>';
//Desc
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDescOnPDF").'</td><td>';
@ -247,6 +248,12 @@ if ($action == 'edit') // Edit
print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS',(! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS:0,1);
print '</td></tr>';
// Place customer adress to the ISO location
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("PlaceCustomerAddressToIsoLocation").'</td><td>';
print $form->selectyesno('MAIN_PDF_USE_ISO_LOCATION',(! empty($conf->global->MAIN_PDF_USE_ISO_LOCATION))?$conf->global->MAIN_PDF_USE_ISO_LOCATION:0,1);
print '</td></tr>';
print '</table>';
@ -303,6 +310,12 @@ else // Show
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
// Hide Intra VAT on address
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowVATIntaInAddress").'</td><td colspan="2">';
print yn($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS,1);
print '</td></tr>';
// Show prof id 1 in address into pdf
$var=!$var;
if (! $noCountryCode)
@ -386,13 +399,6 @@ else // Show
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px" colspan="2">'.$langs->trans("Value").'</td></tr>';
// Hide any PDF informations
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("HideAnyVATInformationOnPDF").'</td><td colspan="2">';
print yn($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT,1);
print '</td></tr>';
// Encrypt and protect PDF
$var=!$var;
print "<tr ".$bc[$var].">";
@ -421,11 +427,11 @@ else // Show
print "</td>";
print '</tr>';
// Hide Tva Intra on adress
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowVATIntaInAddress").'</td><td colspan="2">';
print yn($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS,1);
print '</td></tr>';
// Hide any PDF informations
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("HideAnyVATInformationOnPDF").'</td><td colspan="2">';
print yn($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT,1);
print '</td></tr>';
//Desc
$var=!$var;
@ -445,6 +451,10 @@ else // Show
print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS,1);
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("PlaceCustomerAddressToIsoLocation").'</td><td colspan="2">';
print yn($conf->global->MAIN_PDF_USE_ISO_LOCATION,1);
print '</td></tr>';
print '</table>';

View File

@ -0,0 +1,442 @@
<?php
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/admin/receiptprinter.php
* \ingroup printing
* \brief Page to setup receipt printer
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/receiptprinter.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
$langs->load("admin");
$langs->load("receiptprinter");
if (! $user->admin) accessforbidden();
$action = GETPOST('action','alpha');
$mode = GETPOST('mode','alpha');
$printername = GETPOST('printername', 'alpha');
$printerid = GETPOST('printerid', 'int');
$parameter = GETPOST('parameter', 'alpha');
$template = GETPOST('template', 'alpha');
$templatename = GETPOST('templatename', 'alpha');
$templateid = GETPOST('templateid', 'int');
$printer = new dolReceiptPrinter($db);
if (!$mode) $mode='config';
// used in library escpos maybe useful if php doesn't support gzdecode
if (!function_exists('gzdecode')) {
function gzdecode($data)
{
return gzinflate(substr($data,10,-8));
}
}
/*
* Action
*/
if ($action == 'addprinter' && $user->admin)
{
$error=0;
$db->begin();
if (empty($printername)) {
$error++;
setEventMessages($langs->trans("PrinterNameEmpty"), null, 'errors');
}
if (empty($parameter)) {
setEventMessages($langs->trans("PrinterParameterEmpty"), null, 'warnings');
}
if (! $error)
{
$result= $printer->AddPrinter($printername, GETPOST('printertypeid', 'int'), $parameter);
if ($result > 0) $error++;
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("PrinterAdded",$printername), null);
}
else
{
$db->rollback();
dol_print_error($db);
}
}
$action = '';
}
if ($action == 'deleteprinter' && $user->admin)
{
$error=0;
$db->begin();
if (empty($printerid)) {
$error++;
setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors');
}
if (! $error)
{
$result= $printer->DeletePrinter($printerid);
if ($result > 0) $error++;
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("PrinterDeleted",$printername), null);
}
else
{
$db->rollback();
dol_print_error($db);
}
}
$action = '';
}
if ($action == 'updateprinter' && $user->admin)
{
$error=0;
$db->begin();
if (empty($printerid)) {
$error++;
setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors');
}
if (! $error)
{
$result= $printer->UpdatePrinter($printername, GETPOST('printertypeid', 'int'), $parameter, $printerid);
if ($result > 0) $error++;
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("PrinterUpdated",$printername), null);
}
else
{
$db->rollback();
dol_print_error($db);
}
}
$action = '';
}
if ($action == 'testprinter' && $user->admin)
{
$error=0;
if (empty($printerid)) {
$error++;
setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors');
}
if (! $error)
{
// test
$ret = $printer->SendTestToPrinter($printerid);
if ($ret == 0)
{
setEventMessages($langs->trans("TestSentToPrinter", $printername), null);
}
else
{
setEventMessages($printer->error, $printer->errors, 'errors');
}
}
$action = '';
}
if ($action == 'updatetemplate' && $user->admin)
{
$error=0;
$db->begin();
if (empty($templateid)) {
$error++;
setEventMessages($langs->trans("TemplateIdEmpty"), null, 'errors');
}
if (! $error)
{
$result= $printer->UpdateTemplate($templatename, $template, $templateid);
if ($result > 0) $error++;
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("TemplateUpdated",$templatename), null);
}
else
{
$db->rollback();
dol_print_error($db);
}
}
$action = '';
}
/*
* View
*/
$form = new Form($db);
llxHeader('',$langs->trans("ReceiptPrinterSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("ReceiptPrinterSetup"),$linkback,'title_setup');
$head = receiptprinteradmin_prepare_head($mode);
if ($mode == 'config' && $user->admin)
{
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=config" autocomplete="off">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
if ($action!='editprinter') {
print '<input type="hidden" name="action" value="addprinter">';
} else {
print '<input type="hidden" name="action" value="updateprinter">';
}
dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), 0, 'technic');
print $langs->trans("ReceiptPrinterDesc")."<br><br>\n";
print '<table class="noborder" width="100%">'."\n";
$var=true;
print '<tr class="liste_titre">';
print '<th>'.$langs->trans("Name").'</th>';
print '<th>'.$langs->trans("Type").'</th>';
print '<th>'.$langs->trans("Parameters").'</th>';
print '<th></th>';
print '<th></th>';
print '<th></th>';
print "</tr>\n";
$ret = $printer->listprinters();
if ($ret > 0) {
setEventMessages($printer->error, $printer->errors, 'errors');
} else {
for ($line=0; $line < count($printer->listprinters); $line++) {
$var = !$var;
print '<tr '.$bc[$var].'>';
if ($action=='editprinter' && $printer->listprinters[$line]['rowid']==$printerid) {
print '<input type="hidden" name="printerid" value="'.$printer->listprinters[$line]['rowid'].'">';
print '<td><input size="50" type="text" name="printername" value="'.$printer->listprinters[$line]['name'].'"></td>';
$ret = $printer->selectTypePrinter($printer->listprinters[$line]['fk_type']);
print '<td>'.$printer->resprint.'</td>';
print '<td><input size="60" type="text" name="parameter" value="'.$printer->listprinters[$line]['parameter'].'"></td>';
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '</tr>';
} else {
print '<td>'.$printer->listprinters[$line]['name'].'</td>';
switch ($printer->listprinters[$line]['fk_type']) {
case 1:
$connector = 'CONNECTOR_DUMMY';
break;
case 2:
$connector = 'CONNECTOR_FILE_PRINT';
break;
case 3:
$connector = 'CONNECTOR_NETWORK_PRINT';
break;
case 4:
$connector = 'CONNECTOR_WINDOWS_PRINT';
break;
case 5:
$connector = 'CONNECTOR_JAVA';
break;
default:
$connector = 'CONNECTOR_UNKNOWN';
break;
}
print '<td>'.$langs->trans($connector).'</td>';
print '<td>'.$printer->listprinters[$line]['parameter'].'</td>';
// edit icon
print '<td><a href="'.$_SERVER['PHP_SELF'].'?mode=config&amp;action=editprinter&amp;printerid='.$printer->listprinters[$line]['rowid'].'">';
print img_picto($langs->trans("Edit"),'edit');
print '</a></td>';
// delete icon
print '<td><a href="'.$_SERVER['PHP_SELF'].'?mode=config&amp;action=deleteprinter&amp;printerid='.$printer->listprinters[$line]['rowid'].'&amp;printername='.$printer->listprinters[$line]['name'].'">';
print img_picto($langs->trans("Delete"),'delete');
print '</a></td>';
// test icon
print '<td><a href="'.$_SERVER['PHP_SELF'].'?mode=config&amp;action=testprinter&amp;printerid='.$printer->listprinters[$line]['rowid'].'&amp;printername='.$printer->listprinters[$line]['name'].'">';
print img_picto($langs->trans("TestPrinter"),'printer');
print '</a></td>';
print '</tr>';
}
}
}
if ($action!='editprinter') {
print '<tr class="liste_titre">';
print '<th>'.$langs->trans("Name").'</th>';
print '<th>'.$langs->trans("Type").'</th>';
print '<th>'.$langs->trans("Parameters").'</th>';
print '<th></th>';
print '<th></th>';
print '<th></th>';
print "</tr>\n";
print '<tr>';
print '<td><input size="50" type="text" name="printername"></td>';
$ret = $printer->selectTypePrinter();
print '<td>'.$printer->resprint.'</td>';
print '<td><input size="60" type="text" name="parameter"></td>';
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '</tr>';
}
print '</table>';
dol_fiche_end();
if ($action!='editprinter') {
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Add")).'"></div>';
} else {
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'"></div>';
}
print '</form>';
print '<div><p></div>';
dol_fiche_head();
print '<table class="noborder" width="100%">'."\n";
$var=true;
print '<tr><td>'.$langs->trans("CONNECTOR_DUMMY").':</td><td>'.$langs->trans("CONNECTOR_DUMMY_HELP").'</td></tr>';
print '<td>'.$langs->trans("CONNECTOR_NETWORK_PRINT").':</td><td>'.$langs->trans("CONNECTOR_NETWORK_PRINT_HELP").'</td></tr>';
print '<td>'.$langs->trans("CONNECTOR_FILE_PRINT").':</td><td>'.$langs->trans("CONNECTOR_FILE_PRINT_HELP").'</td></tr>';
print '<td>'.$langs->trans("CONNECTOR_WINDOWS_PRINT").':</td><td>'.$langs->trans("CONNECTOR_WINDOWS_PRINT_HELP").'</td></tr>';
//print '<td>'.$langs->trans("CONNECTOR_JAVA").':</td><td>'.$langs->trans("CONNECTOR_JAVA_HELP").'</td></tr>';
print '</table>';
dol_fiche_end();
}
if ($mode == 'template' && $user->admin)
{
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=template" autocomplete="off">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
if ($action!='edittemplate') {
print '<input type="hidden" name="action" value="addtemplate">';
} else {
print '<input type="hidden" name="action" value="updatetemplate">';
}
dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), 0, 'technic');
print $langs->trans("ReceiptPrinterTemplateDesc")."<br><br>\n";
print '<table class="noborder" width="100%">'."\n";
$var=true;
print '<tr class="liste_titre">';
print '<th>'.$langs->trans("Name").'</th>';
print '<th>'.$langs->trans("Template").'</th>';
print '<th></th>';
print '<th></th>';
print '<th></th>';
print "</tr>\n";
$ret = $printer->listPrintersTemplates();
//print '<pre>'.print_r($printer->listprinterstemplates, true).'</pre>';
if ($ret > 0) {
setEventMessages($printer->error, $printer->errors, 'errors');
} else {
for ($line=0; $line < count($printer->listprinterstemplates); $line++) {
$var = !$var;
print '<tr '.$bc[$var].'>';
if ($action=='edittemplate' && $printer->listprinterstemplates[$line]['rowid']==$templateid) {
print '<input type="hidden" name="templateid" value="'.$printer->listprinterstemplates[$line]['rowid'].'">';
print '<td><input size="50" type="text" name="templatename" value="'.$printer->listprinterstemplates[$line]['name'].'"></td>';
print '<td><textarea name="template" wrap="soft" cols="120" rows="12">'.$printer->listprinterstemplates[$line]['template'].'</textarea>';
print '</td>';
print '<td></td>';
print '<td></td>';
print '<td></td>';
} else {
print '<td>'.$printer->listprinterstemplates[$line]['name'].'</td>';
print '<td>'.nl2br(htmlentities($printer->listprinterstemplates[$line]['template'])).'</td>';
// edit icon
print '<td><a href="'.$_SERVER['PHP_SELF'].'?mode=template&amp;action=edittemplate&amp;templateid='.$printer->listprinterstemplates[$line]['rowid'].'">';
print img_picto($langs->trans("Edit"),'edit');
print '</a></td>';
// delete icon
print '<td><a href="'.$_SERVER['PHP_SELF'].'?mode=template&amp;action=deletetemplate&amp;templateid='.$printer->listprinterstemplates[$line]['rowid'].'&amp;templatename='.$printer->listprinterstemplates[$line]['name'].'">';
print img_picto($langs->trans("Delete"),'delete');
print '</a></td>';
// test icon
print '<td><a href="'.$_SERVER['PHP_SELF'].'?mode=template&amp;action=testtemplate&amp;templateid='.$printer->listprinterstemplates[$line]['rowid'].'&amp;templatename='.$printer->listprinterstemplates[$line]['name'].'">';
print img_picto($langs->trans("TestPrinterTemplate"),'printer');
print '</a></td>';
}
print '</tr>';
}
}
print '</table>';
if ($action!='edittemplate') {
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Add")).'"></div>';
} else {
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'"></div>';
}
print '</form>';
print '<div><p></div>';
print '<table class="noborder" width="100%">'."\n";
$var=true;
print '<tr class="liste_titre">';
print '<th>'.$langs->trans("Tag").'</th>';
print '<th>'.$langs->trans("Description").'</th>';
print "</tr>\n";
for ($tag=0; $tag < count($printer->tags); $tag++) {
$var = !$var;
print '<tr '.$bc[$var].'>';
print '<td>&lt;'.$printer->tags[$tag].'&gt;</td><td>'.$langs->trans(strtoupper($printer->tags[$tag])).'</td>';
print '</tr>';
}
print '</table>';
dol_fiche_end();
}
// to remove after test
$object->date_time = '2015-11-02 22:30:25';
$object->id = 1234;
$object->customer_firstname = 'John';
$object->customer_lastname = 'Deuf';
$object->vendor_firstname = 'Jim';
$object->vendor_lastname = 'Big';
$object->barcode = '3700123862396';
//$printer->sendToPrinter($object, 1, 16);
//setEventMessages($printer->error, $printer->errors, 'errors');
llxFooter();
$db->close();

View File

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

View File

@ -58,6 +58,7 @@ if (GETPOST('action','alpha') == 'set')
$res = dolibarr_set_const($db,"CASHDESK_ID_WAREHOUSE",(GETPOST('CASHDESK_ID_WAREHOUSE','alpha') > 0 ? GETPOST('CASHDESK_ID_WAREHOUSE','alpha') : ''),'chaine',0,'',$conf->entity);
$res = dolibarr_set_const($db,"CASHDESK_NO_DECREASE_STOCK",GETPOST('CASHDESK_NO_DECREASE_STOCK','alpha'),'chaine',0,'',$conf->entity);
$res = dolibarr_set_const($db,"CASHDESK_SERVICES", GETPOST('CASHDESK_SERVICES','alpha'),'chaine',0,'',$conf->entity);
$res = dolibarr_set_const($db,"CASHDESK_DOLIBAR_RECEIPT_PRINTER", GETPOST('CASHDESK_DOLIBAR_RECEIPT_PRINTER','alpha'),'chaine',0,'',$conf->entity);
dol_syslog("admin/cashdesk: level ".GETPOST('level','alpha'));
@ -169,6 +170,17 @@ if (! empty($conf->service->enabled))
print "</td></tr>\n";
}
// Use Dolibarr Receipt Printer
if (! empty($conf->receiptprinter->enabled))
{
$var=! $var;
print '<tr '.$bc[$var].'><td>';
print $langs->trans("DolibarrReceiptPrinter").' ('.$langs->trans("FeatureNotYetAvailable").')';
print '<td colspan="2">';
print $form->selectyesno("CASHDESK_DOLIBAR_RECEIPT_PRINTER",$conf->global->CASHDESK_DOLIBAR_RECEIPT_PRINTER,1);
print "</td></tr>\n";
}
print '</table>';
print '<br>';

View File

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

View File

@ -95,7 +95,7 @@ $cancel != $langs->trans("Cancel") &&
else
{
$action = 'add';
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
@ -128,7 +128,7 @@ $cancel != $langs->trans("Cancel") &&
else
{
$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
{
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);
if ($result >= 0)
{
setEventMessage($langs->trans("WasAddedSuccessfully",$newobject->ref));
setEventMessages($langs->trans("WasAddedSuccessfully",$newobject->ref), null, 'mesgs');
}
else
{
if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
setEventMessage($langs->trans("ObjectAlreadyLinkedToCategory"),'warnings');
setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings');
}
else
{

View File

@ -96,7 +96,7 @@ $hookmanager->initHooks(array('actioncard','globalcard'));
/*
* Actions
*/
$listUserAssignedUpdated = false;
// Remove user to assigned list
if (GETPOST('removedassigned') || GETPOST('removedassigned') == '0')
{
@ -114,6 +114,8 @@ if (GETPOST('removedassigned') || GETPOST('removedassigned') == '0')
$donotclearsession=1;
if ($action == 'add') $action = 'create';
if ($action == 'update') $action = 'edit';
$listUserAssignedUpdated = true;
}
// Add user to assigned list
@ -133,6 +135,8 @@ if (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser'))
$donotclearsession=1;
if ($action == 'add') $action = 'create';
if ($action == 'update') $action = 'edit';
$listUserAssignedUpdated = true;
}
// Action clone object
@ -838,6 +842,28 @@ if ($id > 0)
$result4=$object->fetch_userassigned();
$result5=$object->fetch_optionals($id,$extralabels);
if($listUserAssignedUpdated || $donotclearsession) {
$datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]);
$datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]);
$object->fk_action = dol_getIdFromCode($db, GETPOST("actioncode"), 'c_actioncomm');
$object->label = GETPOST("label");
$object->datep = $datep;
$object->datef = $datef;
$object->percentage = $percentage;
$object->priority = GETPOST("priority");
$object->fulldayevent= GETPOST("fullday")?1:0;
$object->location = GETPOST('location');
$object->socid = GETPOST("socid");
$object->contactid = GETPOST("contactid",'int');
//$object->societe->id = $_POST["socid"]; // deprecated
//$object->contact->id = $_POST["contactid"]; // deprecated
$object->fk_project = GETPOST("projectid",'int');
$object->note = GETPOST("note");
}
if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0)
{
dol_print_error($db,$object->error);

View File

@ -62,7 +62,7 @@ if ($action == 'builddoc')
$result=$cat->write_file(GETPOST('id','int'));
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
{
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
$action='create';
}
}
@ -147,7 +147,7 @@ if ($action == 'add' || $action == 'update')
else
{
$reload = 0;
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
$action= "edit";
}
}

View File

@ -743,7 +743,7 @@ if (empty($reshook))
// Add buying price
$fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : '');
$buyingprice = (GETPOST('buying_price') ? GETPOST('buying_price') : '');
$buyingprice = (GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value
// Extrafields
$extrafieldsline = new ExtraFields($db);

View File

@ -105,7 +105,7 @@ if (empty($reshook))
$result=$object->fetch($id);
$object->code_compta=$_POST["customeraccountancycode"];
$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
@ -113,7 +113,7 @@ if (empty($reshook))
{
$object->fetch($id);
$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
@ -121,7 +121,7 @@ if (empty($reshook))
{
$object->fetch($id);
$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
@ -130,7 +130,7 @@ if (empty($reshook))
$object->fetch($id);
$object->tva_assuj=$_POST['assujtva_value'];
$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
@ -157,7 +157,7 @@ if (empty($reshook))
$object->fetch($id);
$object->outstanding_limit=GETPOST('outstanding_limit');
$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"]))
{
setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors');
setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
}
else
{
@ -129,7 +129,7 @@ if (empty($reshook))
}
else
{
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
$action='';
@ -141,14 +141,14 @@ if (empty($reshook))
if (empty($conf->global->MAILING_LIMIT_SENDBYWEB))
{
// As security measure, we don't allow send from the GUI
setEventMessage($langs->trans("MailingNeedCommand"), 'warnings');
setEventMessage('<textarea cols="70" rows="'.ROWS_2.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.'</textarea>', 'warnings');
setEventMessage($langs->trans("MailingNeedCommand2"), 'warnings');
setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings');
setEventMessages('<textarea cols="70" rows="'.ROWS_2.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.'</textarea>', null, 'warnings');
setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings');
$action='';
}
else if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0)
{
setEventMessage($langs->trans("NotEnoughPermissions"), 'warnings');
setEventMessages($langs->trans("NotEnoughPermissions"), null, 'warnings');
$action='';
}
else
@ -351,27 +351,27 @@ if (empty($reshook))
}
else
{
setEventMessage($langs->transnoentitiesnoconv("NoMoreRecipientToSendTo"));
setEventMessages($langs->transnoentitiesnoconv("NoMoreRecipientToSendTo"), null, 'mesgs');
}
// Loop finished, set global statut of mail
if ($nbko > 0)
{
$statut=2; // Status 'sent partially' (because at least one error)
if ($nbok > 0) setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok));
else setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok));
if ($nbok > 0) setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs');
else setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs');
}
else
{
if ($nbok >= $num)
{
$statut=3; // Send to everybody
setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok));
setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs');
}
else
{
$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();
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
{
setEventMessage($langs->trans("ResultKo").'<br>'.$mailfile->error.' '.$result, 'errors');
setEventMessages($langs->trans("ResultKo").'<br>'.$mailfile->error.' '.$result, null, 'errors');
}
$action='';
@ -488,7 +488,7 @@ if (empty($reshook))
$mesgs[] = $object->error;
}
setEventMessage($mesgs, 'errors');
setEventMessages($mesg, $mesgs, 'errors');
$action="create";
}
@ -518,7 +518,7 @@ if (empty($reshook))
$mesg = $object->error;
}
setEventMessage($mesg, 'errors');
setEventMessages($mesg, $mesgs, 'errors');
$action="";
}
@ -544,7 +544,7 @@ if (empty($reshook))
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_remove_file_process($_POST['removedfile'],0);
dol_remove_file_process($_POST['removedfile'],0,0); // We really delete file linked to mailing
$action="edit";
}
@ -582,7 +582,7 @@ if (empty($reshook))
$mesgs[] =$object->error;
}
setEventMessage($mesgs, 'errors');
setEventMessages($mesg, $mesgs, 'errors');
$action="edit";
}
else
@ -597,7 +597,7 @@ if (empty($reshook))
if ($object->id > 0)
{
$object->valid($user);
setEventMessage($langs->trans("MailingSuccessfullyValidated"));
setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs');
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
@ -628,7 +628,7 @@ if (empty($reshook))
}
else
{
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
$db->rollback();
}
}
@ -764,18 +764,18 @@ else
// You ensure that every user is using its own SMTP server.
$linktoadminemailbefore='<a href="'.DOL_URL_ROOT.'/admin/mails.php">';
$linktoadminemailend='</a>';
setEventMessage($langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]), 'warnings');
setEventMessage($langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']), 'warnings');
if (! empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) setEventMessage($langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), 'warnings');
setEventMessages($langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]), null, '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)) setEventMessages($langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), null, 'warnings');
$_GET["action"]='';
}
else if (empty($conf->global->MAILING_LIMIT_SENDBYWEB))
{
// Pour des raisons de securite, on ne permet pas cette fonction via l'IHM,
// on affiche donc juste un message
setEventMessage($langs->trans("MailingNeedCommand"), 'warnings');
setEventMessage('<textarea cols="60" rows="'.ROWS_1.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.'</textarea>', 'warnings');
setEventMessage($langs->trans("MailingNeedCommand2"), 'warnings');
setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings');
setEventMessages('<textarea cols="60" rows="'.ROWS_1.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.'</textarea>', null, 'warnings');
setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings');
$_GET["action"]='';
}
else
@ -1093,7 +1093,10 @@ else
}
print '</table>';
print "</div>";
dol_fiche_end();
print "\n";
print '<form name="edit_mailing" action="card.php" method="post" enctype="multipart/form-data">'."\n";
@ -1103,6 +1106,9 @@ else
// Print mail content
print load_fiche_titre($langs->trans("EMail"),'','');
dol_fiche_head();
print '<table class="border" width="100%">';
// Subject
@ -1168,7 +1174,9 @@ else
print '</table>';
print '<br><div class="center">';
dol_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button" value="'.$langs->trans("Save").'" name="save">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" class="button" value="'.$langs->trans("Cancel").'" name="cancel">';

View File

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

View File

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

View File

@ -6,7 +6,7 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* 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 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
@ -131,7 +131,7 @@ if (empty($reshook))
{
if (! GETPOST('socid', 3))
{
setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors');
setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
}
else
{
@ -141,7 +141,7 @@ if (empty($reshook))
header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result);
exit();
} else {
if (count($object->errors) > 0) setEventMessage($object->errors, 'errors');
if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors');
$action = '';
}
}
@ -157,7 +157,7 @@ if (empty($reshook))
exit();
} else {
$langs->load("errors");
setEventMessage($langs->trans($object->error), 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
@ -211,8 +211,8 @@ if (empty($reshook))
}
} else {
$langs->load("errors");
if (count($object->errors) > 0) setEventMessage($object->errors, 'errors');
else setEventMessage($langs->trans($object->error), 'errors');
if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors');
else setEventMessages($langs->trans($object->error), null, 'errors');
}
}
@ -318,7 +318,7 @@ if (empty($reshook))
$id = $object->create_from($user);
} else {
setEventMessage($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), 'errors');
setEventMessages($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), null, 'errors');
}
} else {
$object->ref = GETPOST('ref');
@ -507,7 +507,7 @@ if (empty($reshook))
if ($result < 0)
{
$error++;
setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors');
setEventMessages($langs->trans("ErrorFailedToAddContact"), null, 'errors');
}
}
@ -671,7 +671,7 @@ if (empty($reshook))
if ($object->id > 0) {
$result = $object->insert_discount($_POST["remise_id"]);
if ($result < 0) {
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
@ -859,8 +859,8 @@ if (empty($reshook))
}
// Margin
$fournprice = (GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : '');
$buyingprice = (GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : '');
$fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : '');
$buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : ''); // If buying_price is '0', we muste keep this value
$date_start = dol_mktime(0, 0, 0, GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year'));
$date_end = dol_mktime(0, 0, 0, GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year'));
@ -875,7 +875,7 @@ if (empty($reshook))
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));
setEventMessage($mesg, 'errors');
setEventMessages($mesg, null, 'errors');
} else {
// 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);
@ -929,13 +929,13 @@ if (empty($reshook))
} else {
$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'))
{
// Define info_bits
@ -954,8 +954,8 @@ if (empty($reshook))
$pu_ht = GETPOST('price_ht');
// Add buying price
$fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : '');
$buyingprice = (GETPOST('buying_price') ? GETPOST('buying_price') : '');
$fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : '');
$buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value
$date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
$date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
@ -991,7 +991,7 @@ if (empty($reshook))
$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))) {
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 ++;
}
} else {
@ -1040,7 +1040,7 @@ if (empty($reshook))
} else {
$db->rollback();
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
@ -1137,9 +1137,9 @@ if (empty($reshook))
} else {
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
$langs->load("errors");
setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors');
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
} else {
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
@ -1636,13 +1636,13 @@ if ($action == 'create')
else if ($action == 'validate') {
$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);
if ($ref == 'PROV') {
$numref = $object->getNextNumRef($soc);
if (empty($numref)) {
$error ++;
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
} else {
$numref = $object->ref;

View File

@ -375,13 +375,15 @@ class Propal extends CommonObject
* @param int $date_end End date of the line
* @param array $array_options extrafields array
* @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
*
* @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");
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
@ -400,7 +402,7 @@ class Propal extends CommonObject
$txtva=price2num($txtva);
$txlocaltax1=price2num($txlocaltax1);
$txlocaltax2=price2num($txlocaltax2);
$pa_ht=price2num($pa_ht);
$pa_ht=price2num($pa_ht);
if ($price_base_type=='HT')
{
$pu=$pu_ht;
@ -499,6 +501,9 @@ class Propal extends CommonObject
$this->line->fk_fournprice = $fk_fournprice;
$this->line->pa_ht = $pa_ht;
$this->line->origin_id = $origin_id;
$this->line->origin = $origin;
// Mise en option de la ligne
if (empty($qty) && empty($special_code)) $this->line->special_code=3;
@ -570,7 +575,8 @@ class Propal extends CommonObject
{
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';
// Clean parameters
@ -894,7 +900,9 @@ class Propal extends CommonObject
$this->lines[$i]->date_start,
$this->lines[$i]->date_end,
$this->lines[$i]->array_options,
$this->lines[$i]->fk_unit
$this->lines[$i]->fk_unit,
$this->element,
$this->lines[$i]->id
);
if ($result < 0)
@ -1049,13 +1057,17 @@ class Propal extends CommonObject
$clonedObj->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
$clonedObj->fk_delivery_address = '';
$project = new Project($db);
if ($this->fk_project > 0 && $project->fetch($this->fk_project)) {
if ($project->socid <= 0) $clonedObj->fk_project = $this->fk_project;
else $clonedObj->fk_project = '';
} else {
$clonedObj->fk_project = '';
}
/*if (!empty($conf->projet->enabled))
{
$project = new Project($db);
if ($this->fk_project > 0 && $project->fetch($this->fk_project)) {
if ($project->socid <= 0) $clonedObj->fk_project = $this->fk_project;
else $clonedObj->fk_project = '';
} else {
$clonedObj->fk_project = '';
}
}*/
$clonedObj->fk_project = ''; // A cloned proposal is set by default to no project.
}
// reset ref_client
@ -1380,7 +1392,10 @@ class Propal extends CommonObject
*/
function update_extrafields($user)
{
global $conf, $hookmanager;
$action='update';
$error = 0;
// Actions on extra fields (by external module or standard code)
// TODO le hook fait double emploi avec le trigger !!
@ -2713,7 +2728,7 @@ class Propal extends CommonObject
*/
function getNomUrl($withpicto=0,$option='', $get_params='')
{
global $langs;
global $langs, $conf;
$result='';
$label = '<u>' . $langs->trans("ShowPropal") . '</u>';
@ -3086,6 +3101,8 @@ class PropaleLigne extends CommonObjectLine
dol_syslog(get_class($this)."::insert rang=".$this->rang);
$pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'.
// Clean parameters
if (empty($this->tva_tx)) $this->tva_tx=0;
if (empty($this->localtax1_tx)) $this->localtax1_tx=0;
@ -3102,11 +3119,10 @@ class PropaleLigne extends CommonObjectLine
if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
if (empty($this->fk_fournprice)) $this->fk_fournprice=0;
if (! is_numeric($this->qty)) $this->qty = 0;
if (empty($this->pa_ht)) $this->pa_ht=0;
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0)
if ($this->pa_ht == 0 && $pa_ht_isemptystring)
{
if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0)
{
@ -3254,7 +3270,7 @@ class PropaleLigne extends CommonObjectLine
/**
* Update propal line object into DB
*
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int <0 if ko, >0 if ok
*/
function update($notrigger=0)
@ -3263,6 +3279,8 @@ class PropaleLigne extends CommonObjectLine
$error=0;
$pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'.
// Clean parameters
if (empty($this->tva_tx)) $this->tva_tx=0;
if (empty($this->localtax1_tx)) $this->localtax1_tx=0;
@ -3281,11 +3299,10 @@ class PropaleLigne extends CommonObjectLine
if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
if (empty($this->fk_fournprice)) $this->fk_fournprice=0;
if (empty($this->subprice)) $this->subprice=0;
if (empty($this->pa_ht)) $this->pa_ht=0;
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0)
if ($this->pa_ht == 0 && $pa_ht_isemptystring)
{
if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0)
{

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
* Copyright (C) 2005-2009 Destailleur Laurent <eldy@users.sourceforge.net>
* 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
* 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)
{
$langs->load("errors");
setEventMessage($langs->trans('ErrorRecordNotFound'), 'errors');
setEventMessages($langs->trans('ErrorRecordNotFound'), null, 'errors');
$error++;
}
else if ($ret < 0)
{
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
}
@ -75,7 +75,7 @@ else
/*
* Ajout d'un nouveau contact
* Add a new contact
*/
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')
{
$langs->load("errors");
setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors');
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
}
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)
{
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)
{
$result = $object->delete_contact($lineid);

View File

@ -64,7 +64,7 @@ if ($socid > 0)
print '<table class="border" width="100%">';
// Name
print '<tr><td width="20%">'.$langs->trans("Thirdparty").'</td><td width="80%" colspan="3">'.$societe->getNomUrl(1).'</td></tr>';
print '<tr><td width="20%">'.$langs->trans("ThirdParty").'</td><td width="80%" colspan="3">'.$societe->getNomUrl(1).'</td></tr>';
// Prefix
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field

View File

@ -65,17 +65,17 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes')
if (! $res > 0)
{
$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)
{
$error++;
setEventMessage($langs->trans("TotalOfTwoDiscountMustEqualsOriginal"), 'errors');
setEventMessages($langs->trans("TotalOfTwoDiscountMustEqualsOriginal"), null, 'errors');
}
if (! $error && $discount->fk_facture_line)
{
$error++;
setEventMessage($langs->trans("ErrorCantSplitAUsedDiscount"), 'errors');
setEventMessages($langs->trans("ErrorCantSplitAUsedDiscount"), null, 'errors');
}
if (! $error)
{
@ -166,13 +166,13 @@ if ($action == 'setremise')
else
{
$error++;
setEventMessage($soc->error, 'errors');
setEventMessages($soc->error, $soc->errors, 'errors');
}
}
}
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
{
setEventMessage($discount->error, 'errors');
setEventMessages($discount->error, $discount->errors, 'errors');
$db->rollback();
}
}
@ -216,7 +216,7 @@ if ($socid > 0)
$object->fetch($socid);
/*
* Affichage onglets
* Display tabs
*/
$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.= " rc.datec as dc, rc.description,";

View File

@ -354,7 +354,7 @@ if (empty($reshook))
$array_options = $lines[$i]->array_options;
}
$result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->fk_unit);
$result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->fk_unit, $object->origin, $lines[$i]->rowid);
if ($result < 0) {
$error++;
@ -733,8 +733,8 @@ if (empty($reshook))
}
// Margin
$fournprice = (GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : '');
$buyingprice = (GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : '');
$fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : '');
$buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : ''); // If buying_price is '0', we muste keep this value
// Local Taxes
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty);
@ -833,8 +833,8 @@ if (empty($reshook))
$localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
// Add buying price
$fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : '');
$buyingprice = (GETPOST('buying_price') ? GETPOST('buying_price') : '');
$fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : '');
$buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value
// Extrafields Lines
$extrafieldsline = new ExtraFields($db);
@ -1166,9 +1166,9 @@ if (empty($reshook))
if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->commande->creer)
if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->commande->creer)
{
if ($action == 'addcontact')
if ($action == 'addcontact')
{
if ($object->id > 0) {
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
@ -1189,7 +1189,7 @@ if (empty($reshook))
}
// bascule du statut d'un contact
else if ($action == 'swapstatut')
else if ($action == 'swapstatut')
{
if ($object->id > 0) {
$result = $object->swapContactStatus(GETPOST('ligne'));
@ -1199,7 +1199,7 @@ if (empty($reshook))
}
// Efface un contact
else if ($action == 'deletecontact')
else if ($action == 'deletecontact')
{
$result = $object->delete_contact($lineid);
@ -1433,7 +1433,7 @@ if ($action == 'create' && $user->rights->commande->creer)
print '</td></tr>';
// TODO How record was recorded OrderMode (llx_c_input_method)
// Project
if (! empty($conf->projet->enabled) && $socid > 0)
{
@ -1996,7 +1996,7 @@ if ($action == 'create' && $user->rights->commande->creer)
print '</td></tr>';
// TODO How record was recorded OrderMode (llx_c_input_method)
// Project
if (! empty($conf->projet->enabled))
{

View File

@ -417,7 +417,7 @@ class Commande extends CommonOrder
{
$mouvP = new MouvementStock($this->db);
// We increment stock of product (and sub-products)
$result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderBackToDraftInDolibarr",$this->ref));
$result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderBackToDraftInDolibarr",$this->ref));
if ($result < 0) { $error++; }
}
}
@ -601,7 +601,7 @@ class Commande extends CommonOrder
{
$mouvP = new MouvementStock($this->db);
// We increment stock of product (and sub-products)
$result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderCanceledInDolibarr",$this->ref));
$result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderCanceledInDolibarr",$this->ref)); // price is 0, we don't want WAP to be changed
if ($result < 0)
{
$error++;
@ -777,7 +777,9 @@ class Commande extends CommonOrder
$this->lines[$i]->pa_ht,
$this->lines[$i]->label,
$this->lines[$i]->array_options,
$this->lines[$i]->fk_unit
$this->lines[$i]->fk_unit,
$this->element,
$this->lines[$i]->id
);
if ($result < 0)
{
@ -950,10 +952,11 @@ class Commande extends CommonOrder
// Clear fields
$this->user_author_id = $user->id;
$this->user_valid = '';
$this->date = dol_now();
$this->date_creation = '';
$this->date_validation = '';
$this->ref_client = '';
// Create clone
$result=$this->create($user);
if ($result < 0) $error++;
@ -1005,7 +1008,7 @@ class Commande extends CommonOrder
$error=0;
$this->date_commande = dol_now();
$this->source = 0;
@ -1141,6 +1144,8 @@ class Commande extends CommonOrder
* @param string $label Label
* @param array $array_options extrafields array. Example array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...)
* @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
*
* @see add_product
@ -1150,7 +1155,7 @@ class Commande extends CommonOrder
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit)
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
*/
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_options=0, $fk_unit=null)
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0)
{
global $mysoc, $conf, $langs;
@ -1269,6 +1274,8 @@ class Commande extends CommonOrder
$this->line->total_ttc=$total_ttc;
$this->line->product_type=$type;
$this->line->special_code=$special_code;
$this->line->origin=$origin;
$this->line->origin_id=$origin_id;
$this->line->fk_parent_line=$fk_parent_line;
$this->line->fk_unit=$fk_unit;
@ -2317,6 +2324,7 @@ class Commande extends CommonOrder
function classifyBilled()
{
global $conf, $user, $langs;
$error = 0;
$this->db->begin();
@ -2631,6 +2639,7 @@ class Commande extends CommonOrder
global $hookmanager, $conf;
$action='create';
$error = 0;
// Actions on extra fields (by external module or standard code)
// TODO le hook fait double emploi avec le trigger !!
@ -2867,7 +2876,7 @@ class Commande extends CommonOrder
*/
function LibStatut($statut,$billed,$mode)
{
global $langs;
global $langs, $conf;
//print 'x'.$statut.'-'.$billed;
if ($mode == 0)
{
@ -3507,6 +3516,8 @@ class OrderLine extends CommonOrderLine
$error=0;
$pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'.
dol_syslog(get_class($this)."::insert rang=".$this->rang);
// Clean parameters
@ -3523,11 +3534,10 @@ class OrderLine extends CommonOrderLine
if (empty($this->info_bits)) $this->info_bits=0;
if (empty($this->special_code)) $this->special_code=0;
if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
if (empty($this->pa_ht)) $this->pa_ht=0;
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0)
if ($this->pa_ht == 0 && $pa_ht_isemptystring)
{
if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0)
{
@ -3641,6 +3651,8 @@ class OrderLine extends CommonOrderLine
$error=0;
$pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'.
// Clean parameters
if (empty($this->tva_tx)) $this->tva_tx=0;
if (empty($this->localtax1_tx)) $this->localtax1_tx=0;
@ -3661,7 +3673,7 @@ class OrderLine extends CommonOrderLine
if (empty($this->pa_ht)) $this->pa_ht=0;
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0)
if ($this->pa_ht == 0 && $pa_ht_isemptystring)
{
if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0)
{

View File

@ -378,19 +378,6 @@ if ($id > 0 || ! empty($ref))
{
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 (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>';
}
}
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>';
}

View File

@ -998,7 +998,12 @@ class Account extends CommonObject
$link = '<a href="'.DOL_URL_ROOT.'/compta/bank/account.php?account='.$this->id.$linkclose;
$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.' ');
$result.=$link.$this->label.$linkend;
return $result;

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* 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) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
@ -587,7 +587,7 @@ if ($result)
if ($user->rights->banque->consolidate)
{
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>';
}
else

View File

@ -186,7 +186,7 @@ if ($resql)
print '<br>';
// Show last bank receipts
$nbmax=5;
$nbmax=15; // We accept to show last 15 receipts (so we can have more than one year)
$liste="";
$sql = "SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX."bank";
$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 '<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>';
if ($options)
{

View File

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

View File

@ -713,7 +713,8 @@ if (empty($reshook))
// Credit note invoice
if ($_POST['type'] == Facture::TYPE_CREDIT_NOTE)
{
if (! ($_POST['fac_avoir'] > 0))
$sourceinvoice = GETPOST('fac_avoir');
if (! ($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE))
{
$error ++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CorrectInvoice")), null, 'errors');
@ -746,7 +747,7 @@ if (empty($reshook))
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
// Proprietes particulieres a facture avoir
$object->fk_facture_source = $_POST['fac_avoir'];
$object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : '';
$object->type = Facture::TYPE_CREDIT_NOTE;
$id = $object->create($user);
@ -1400,7 +1401,7 @@ if (empty($reshook))
// Margin
$fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : '');
$buyingprice = price2num(GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : '');
$buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : ''); // If buying_price is '0', we muste keep this value
// Local Taxes
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty);
@ -1507,8 +1508,8 @@ if (empty($reshook))
// Add buying price
$fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : '');
$buyingprice = price2num(GETPOST('buying_price') ? GETPOST('buying_price') : '');
$buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
@ -2033,7 +2034,7 @@ if ($action == 'create')
$newinvoice_static->paye = $valarray ['paye'];
$optionsav .= '<option value="' . $key . '"';
if ($key == $_POST['fac_avoir'])
if ($key == GETPOST('fac_avoir'))
$optionsav .= ' selected';
$optionsav .= '>';
$optionsav .= $newinvoice_static->ref;
@ -2834,7 +2835,7 @@ else if ($id > 0 || ! empty($ref))
$facreplaced->fetch($object->fk_facture_source);
print ' (' . $langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)) . ')';
}
if ($object->type == Facture::TYPE_CREDIT_NOTE) {
if ($object->type == Facture::TYPE_CREDIT_NOTE && !empty($object->fk_facture_source)) {
$facusing = new Facture($db);
$facusing->fetch($object->fk_facture_source);
print ' (' . $langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)) . ')';
@ -3688,6 +3689,15 @@ else if ($id > 0 || ! empty($ref))
print '<div class="inline-block divButAction"><a class="butAction" href="facture/fiche-rec.php?facid=' . $object->id . '&amp;action=create">' . $langs->trans("ChangeIntoRepeatableInvoice") . '</a></div>';
}
}
// Create a credit note
if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut > 0 && $user->rights->facture->creer)
{
if (! $objectidnext)
{
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?socid=' . $object->socid .'&amp;fac_avoir=' . $object->id . '&amp;action=create&amp;type=2">' . $langs->trans("CreateCreditNote") . '</a></div>';
}
}
//Create next situation invoice
if ($user->rights->facture->creer && ($object->type == 5) && ($object->statut == 1 || $object->statut == 2)) {

View File

@ -63,6 +63,7 @@ class Facture extends CommonInvoice
var $author;
var $fk_user_author;
var $fk_user_valid;
var $date; // Date invoice
var $date_creation; // Creation date
var $date_validation; // Validation date
var $datem;
@ -385,6 +386,8 @@ class Facture extends CommonInvoice
{
$newinvoiceline=$this->lines[$i];
$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
{
// 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]->rang,
$this->lines[$i]->special_code,
'',
0,
$this->element,
$this->lines[$i]->id,
$fk_parent_line,
$this->lines[$i]->fk_fournprice,
$this->lines[$i]->pa_ht,
@ -873,7 +876,7 @@ class Facture extends CommonInvoice
*/
function getNomUrl($withpicto=0,$option='',$max=0,$short=0,$moretitle='')
{
global $langs;
global $langs, $conf;
$result='';
@ -1853,7 +1856,7 @@ class Facture extends CommonInvoice
$mouvP = new MouvementStock($this->db);
$mouvP->origin = &$this;
// We decrease stock for product
if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num));
if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr",$num));
else $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num));
if ($result < 0) {
$error++;
@ -3852,7 +3855,9 @@ class FactureLigne extends CommonInvoiceLine
$error=0;
dol_syslog(get_class($this)."::insert rang=".$this->rang, LOG_DEBUG);
$pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'.
dol_syslog(get_class($this)."::insert rang=".$this->rang, LOG_DEBUG);
// Clean parameters
$this->desc=trim($this->desc);
@ -3871,11 +3876,10 @@ class FactureLigne extends CommonInvoiceLine
if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
if (empty($this->fk_prev_id)) $this->fk_prev_id = 'null';
if (empty($this->situation_percent)) $this->situation_percent = 0;
if (empty($this->pa_ht)) $this->pa_ht=0;
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0)
if ($this->pa_ht == 0 && $pa_ht_isemptystring)
{
if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0)
{
@ -4050,6 +4054,8 @@ class FactureLigne extends CommonInvoiceLine
$error=0;
$pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'.
// Clean parameters
$this->desc=trim($this->desc);
if (empty($this->tva_tx)) $this->tva_tx=0;
@ -4065,14 +4071,13 @@ class FactureLigne extends CommonInvoiceLine
if (empty($this->product_type)) $this->product_type=0;
if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
if (is_null($this->situation_percent)) $this->situation_percent=100;
if (empty($this->pa_ht)) $this->pa_ht=0;
// Check parameters
if ($this->product_type < 0) return -1;
if (empty($this->pa_ht)) $this->pa_ht=0;
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0)
if ($this->pa_ht == 0 && $pa_ht_isemptystring)
{
if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0)
{

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>';
$datepayment = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
$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>'.$langs->trans('Comments').'</td></tr>';

View File

@ -47,15 +47,16 @@ $search_firstname=GETPOST("search_firstname");
$search_societe=GETPOST("search_societe");
$search_poste=GETPOST("search_poste");
$search_phone=GETPOST("search_phone");
$search_phoneper=GETPOST("search_phoneper");
$search_phonepro=GETPOST("search_phonepro");
$search_phonemob=GETPOST("search_phonemob");
$search_phone_perso=GETPOST("search_phone_perso");
$search_phone_pro=GETPOST("search_phone_pro");
$search_phone_mobile=GETPOST("search_phone_mobile");
$search_fax=GETPOST("search_fax");
$search_email=GETPOST("search_email");
$search_skype=GETPOST("search_skype");
$search_priv=GETPOST("search_priv");
$search_categ=GETPOST("search_categ",'int');
$search_status=GETPOST("search_status",'int');
$search_type=GETPOST('search_type','alpha');
if ($search_status=='') $search_status=1; // always display activ customer first
$optioncss = GETPOST('optioncss','alpha');
@ -77,47 +78,41 @@ $limit = $conf->liste_limit;
$offset = $limit * $page;
$langs->load("companies");
$contextpage='contactlist';
$titre = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses"));
if ($type == "p")
{
$contextpage='contactprospectlist';
$titre.=' ('.$langs->trans("ThirdPartyProspects").')';
$urlfiche="card.php";
}
if ($type == "c")
{
$contextpage='contactcustomerlist';
$titre.=' ('.$langs->trans("ThirdPartyCustomers").')';
$urlfiche="card.php";
}
else if ($type == "f")
{
$contextpage='contactsupplierlist';
$titre.=' ('.$langs->trans("ThirdPartySuppliers").')';
$urlfiche="card.php";
}
else if ($type == "o")
{
$contextpage='contactotherlist';
$titre.=' ('.$langs->trans("OthersNotLinkedToThirdParty").')';
$urlfiche="";
}
if (GETPOST('button_removefilter_x') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter')) // All tests are required to be compatible with all browsers
{
$sall="";
$search_firstlast_only="";
$search_lastname="";
$search_firstname="";
$search_societe="";
$search_poste="";
$search_phone="";
$search_phoneper="";
$search_phonepro="";
$search_phonemob="";
$search_fax="";
$search_email="";
$search_skype="";
$search_priv="";
$seach_status=1;
}
if ($search_priv < 0) $search_priv='';
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array($contextpage));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('contact');
$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array(
@ -128,21 +123,65 @@ $fieldstosearchall = array(
);
/*
* Actions
*/
$parameters=array();
$reshook=$hookmanager->executeHooks('doActions',$parameters); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
if (empty($reshook))
{
}
if (GETPOST('button_removefilter_x') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter')) // All tests are required to be compatible with all browsers
{
$sall="";
$search_firstlast_only="";
$search_lastname="";
$search_firstname="";
$search_societe="";
$search_poste="";
$search_phone="";
$search_phone_perso="";
$search_phone_pro="";
$search_phone_mobile="";
$search_fax="";
$search_email="";
$search_skype="";
$search_priv="";
$search_status=-1;
}
if ($search_priv < 0) $search_priv='';
/*
* View
*/
$form=new Form($db);
$formother=new FormOther($db);
$contactstatic=new Contact($db);
$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
llxHeader('',$title,'EN:Module_Third_Parties|FR:Module_Tiers|ES:M&oacute;dulo_Empresas');
$form=new Form($db);
$formother=new FormOther($db);
$sql = "SELECT s.rowid as socid, s.nom as name,";
$sql.= " p.rowid as cidp, p.lastname as lastname, p.statut, p.firstname, p.poste, p.email, p.skype,";
$sql.= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.tms,";
$sql.= " p.rowid as cidp, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.skype,";
$sql.= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,";
$sql.= " co.code as country_code";
// Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) $sql.=",ef.".$key.' as options_'.$key;
// Add fields from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as p";
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contact_extrafields as ef on (p.rowid = ef.fk_object)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = p.fk_pays";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
if (! empty($search_categ)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_contact as cs ON p.rowid = cs.fk_socpeople"; // We need this table joined to the select in order to filter by categ
@ -190,17 +229,17 @@ if (strlen($search_phone))
{
$sql .= " AND (p.phone LIKE '%".$db->escape($search_phone)."%' OR p.phone_perso LIKE '%".$db->escape($search_phone)."%' OR p.phone_mobile LIKE '%".$db->escape($search_phone)."%')";
}
if (strlen($search_phoneper))
if (strlen($search_phone_perso))
{
$sql .= " AND p.phone_perso LIKE '%".$db->escape($search_phoneper)."%'";
$sql .= " AND p.phone_perso LIKE '%".$db->escape($search_phone_perso)."%'";
}
if (strlen($search_phonepro))
if (strlen($search_phone_pro))
{
$sql .= " AND p.phone LIKE '%".$db->escape($search_phonepro)."%'";
$sql .= " AND p.phone LIKE '%".$db->escape($search_phone_pro)."%'";
}
if (strlen($search_phonemob))
if (strlen($search_phone_mobile))
{
$sql .= " AND p.phone_mobile LIKE '%".$db->escape($search_phonemob)."%'";
$sql .= " AND p.phone_mobile LIKE '%".$db->escape($search_phone_mobile)."%'";
}
if (strlen($search_fax))
{
@ -214,7 +253,7 @@ if (strlen($search_skype)) // filtre sur skype
{
$sql .= " AND p.skype LIKE '%".$db->escape($search_skype)."%'";
}
if ($search_status!='') $sql .= " AND p.statut = ".$db->escape($search_status);
if ($search_status != '' && $search_status >= 0) $sql .= " AND p.statut = ".$db->escape($search_status);
if ($type == "o") // filtre sur type
{
$sql .= " AND p.fk_soc IS NULL";
@ -239,6 +278,24 @@ if (! empty($socid))
{
$sql .= " AND s.rowid = ".$socid;
}
// Add where from extra fields
foreach ($search_array_options as $key => $val)
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
$typ=$extrafields->attribute_type[$tmpkey];
$mode=0;
if (in_array($typ, array('int'))) $mode=1; // Search on a numeric
if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit)))
{
$sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
}
}
// Add where from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
// Count total nb of records
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
@ -246,6 +303,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
// Add order and limit
if($view == "recent")
{
@ -263,23 +321,39 @@ dol_syslog("contact/list.php", LOG_DEBUG);
$result = $db->query($sql);
if ($result)
{
$contactstatic=new Contact($db);
$param ='&begin='.htmlspecialchars($begin).'&view='.htmlspecialchars($view).'&userid='.htmlspecialchars($userid).'&contactname='.htmlspecialchars($sall);
$param.='&type='.htmlspecialchars($type).'&view='.htmlspecialchars($view).'&search_lastname='.htmlspecialchars($search_lastname).'&search_firstname='.htmlspecialchars($search_firstname).'&search_societe='.htmlspecialchars($search_societe).'&search_email='.htmlspecialchars($search_email);
if (!empty($search_categ)) $param.='&search_categ='.htmlspecialchars($search_categ);
if ($search_status != '') $param.='&amp;search_status='.htmlspecialchars($search_status);
if ($search_priv == '0' || $search_priv == '1') $param.="&search_priv=".htmlspecialchars($search_priv);
if ($optioncss != '') $param.='&optioncss='.$optioncss;
$num = $db->num_rows($result);
$i = 0;
$param ='&begin='.urlencode($begin).'&view='.urlencode($view).'&userid='.urlencode($userid).'&contactname='.urlencode($sall);
$param.='&type='.urlencode($type).'&view='.urlencode($view).'&search_lastname='.urlencode($search_lastname).'&search_firstname='.urlencode($search_firstname).'&search_societe='.urlencode($search_societe).'&search_email='.urlencode($search_email);
if (!empty($search_categ)) $param.='&search_categ='.urlencode($search_categ);
if ($search_lastname != '') $param.='&amp;search_lastname='.urlencode($search_lastname);
if ($search_firstname != '') $param.='&amp;search_firstname='.urlencode($search_firstname);
if ($search_zip != '') $param.='&amp;search_zip='.urlencode($search_zip);
if ($search_town != '') $param.='&amp;search_town='.urlencode($search_town);
if ($search_job != '') $param.='&amp;search_job='.urlencode($search_job);
if ($search_phone_pro != '') $param.='&amp;search_phone_pro='.urlencode($search_phone_pro);
if ($search_phone_perso != '') $param.='&amp;search_phone_perso='.urlencode($search_phone_perso);
if ($search_phone_mobile != '') $param.='&amp;search_phone_mobile='.urlencode($search_phone_mobile);
if ($search_fax != '') $param.='&amp;search_fax='.urlencode($search_fax);
if ($search_email != '') $param.='&amp;search_email='.urlencode($search_email);
if ($search_status != '') $param.='&amp;search_status='.urlencode($search_status);
if ($search_priv == '0' || $search_priv == '1') $param.="&search_priv=".urlencode($search_priv);
if ($optioncss != '') $param.='&optioncss='.$optioncss;
// Add $param from extra fields
foreach ($search_array_options as $key => $val)
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
}
print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords,'title_companies.png');
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="view" value="'.dol_escape_htmltag($view).'">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
@ -306,75 +380,199 @@ if ($result)
{
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
$parameters=array('type'=>$type);
$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
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;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
print '<table class="liste '.($moreforfilter?"listwithfilterbefore":"").'">';
// Ligne des titres
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Lastname"),$_SERVER["PHP_SELF"],"p.lastname", $begin, $param, '', $sortfield,$sortorder);
print_liste_field_titre($langs->trans("Firstname"),$_SERVER["PHP_SELF"],"p.firstname", $begin, $param, '', $sortfield,$sortorder);
print_liste_field_titre($langs->trans("PostOrFunction"),$_SERVER["PHP_SELF"],"p.poste", $begin, $param, '', $sortfield,$sortorder);
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER["PHP_SELF"],"s.nom", $begin, $param, '', $sortfield,$sortorder);
print_liste_field_titre($langs->trans("Phone"),$_SERVER["PHP_SELF"],"p.phone", $begin, $param, '', $sortfield,$sortorder);
print_liste_field_titre($langs->trans("PhoneMobile"),$_SERVER["PHP_SELF"],"p.phone_mobile", $begin, $param, '', $sortfield,$sortorder);
print_liste_field_titre($langs->trans("Fax"),$_SERVER["PHP_SELF"],"p.fax", $begin, $param, '', $sortfield,$sortorder);
print_liste_field_titre($langs->trans("EMail"),$_SERVER["PHP_SELF"],"p.email", $begin, $param, '', $sortfield,$sortorder);
if (! empty($conf->skype->enabled)) { print_liste_field_titre($langs->trans("Skype"),$_SERVER["PHP_SELF"],"p.skype", $begin, $param, '', $sortfield,$sortorder); }
print_liste_field_titre($langs->trans("DateModificationShort"),$_SERVER["PHP_SELF"],"p.tms", $begin, $param, 'align="center"', $sortfield,$sortorder);
print_liste_field_titre($langs->trans("ContactVisibility"),$_SERVER["PHP_SELF"],"p.priv", $begin, $param, 'align="center"', $sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"p.statut", $begin, $param, 'align="center"', $sortfield,$sortorder);
print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch ');
if (! empty($arrayfields['p.lastname']['checked'])) print_liste_field_titre($langs->trans("Lastname"),$_SERVER["PHP_SELF"],"p.lastname", $begin, $param, '', $sortfield,$sortorder);
if (! empty($arrayfields['p.firstname']['checked'])) print_liste_field_titre($langs->trans("Firstname"),$_SERVER["PHP_SELF"],"p.firstname", $begin, $param, '', $sortfield,$sortorder);
if (! empty($arrayfields['p.zip']['checked'])) print_liste_field_titre($langs->trans("Zip"),$_SERVER["PHP_SELF"],"p.zip", $begin, $param, '', $sortfield,$sortorder);
if (! empty($arrayfields['p.town']['checked'])) print_liste_field_titre($langs->trans("Town"),$_SERVER["PHP_SELF"],"p.town", $begin, $param, '', $sortfield,$sortorder);
if (! empty($arrayfields['p.poste']['checked'])) print_liste_field_titre($langs->trans("PostOrFunction"),$_SERVER["PHP_SELF"],"p.poste", $begin, $param, '', $sortfield,$sortorder);
if (! empty($arrayfields['p.phone']['checked'])) print_liste_field_titre($langs->trans("Phone"),$_SERVER["PHP_SELF"],"p.phone", $begin, $param, '', $sortfield,$sortorder);
if (! empty($arrayfields['p.phone_perso']['checked'])) print_liste_field_titre($langs->trans("PhonePerso"),$_SERVER["PHP_SELF"],"p.phone_perso", $begin, $param, '', $sortfield,$sortorder);
if (! empty($arrayfields['p.phone_mobile']['checked'])) print_liste_field_titre($langs->trans("PhoneMobile"),$_SERVER["PHP_SELF"],"p.phone_mobile", $begin, $param, '', $sortfield,$sortorder);
if (! empty($arrayfields['p.fax']['checked'])) print_liste_field_titre($langs->trans("Fax"),$_SERVER["PHP_SELF"],"p.fax", $begin, $param, '', $sortfield,$sortorder);
if (! empty($arrayfields['p.email']['checked'])) print_liste_field_titre($langs->trans("EMail"),$_SERVER["PHP_SELF"],"p.email", $begin, $param, '', $sortfield,$sortorder);
if (! empty($arrayfields['p.skype']['checked'])) print_liste_field_titre($langs->trans("Skype"),$_SERVER["PHP_SELF"],"p.skype", $begin, $param, '', $sortfield,$sortorder);
if (! empty($arrayfields['p.thirdparty']['checked'])) print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER["PHP_SELF"],"s.nom", $begin, $param, '', $sortfield,$sortorder);
if (! empty($arrayfields['p.priv']['checked'])) print_liste_field_titre($langs->trans("ContactVisibility"),$_SERVER["PHP_SELF"],"p.priv", $begin, $param, 'align="center"', $sortfield,$sortorder);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
$align=$extrafields->getAlignFlag($key);
print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
}
}
}
// Hook fields
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($langs->trans("DateCreationShort"),$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($langs->trans("DateModificationShort"),$_SERVER["PHP_SELF"],"p.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
if (! empty($arrayfields['p.statut']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"p.statut","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch ');
print "</tr>\n";
// Lines for filter fields
print '<tr class="liste_titre">';
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_lastname" size="9" value="'.dol_escape_htmltag($search_lastname).'">';
print '</td>';
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_firstname" size="9" value="'.dol_escape_htmltag($search_firstname).'">';
print '</td>';
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_poste" size="9" value="'.dol_escape_htmltag($search_poste).'">';
print '</td>';
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
if (! empty($arrayfields['p.lastname']['checked']))
{
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_societe" size="9" value="'.dol_escape_htmltag($search_societe).'">';
print '<input class="flat" type="text" name="search_lastname" size="6" value="'.dol_escape_htmltag($search_lastname).'">';
print '</td>';
}
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_phonepro" size="8" value="'.dol_escape_htmltag($search_phonepro).'">';
print '</td>';
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_phonemob" size="8" value="'.dol_escape_htmltag($search_phonemob).'">';
print '</td>';
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_fax" size="8" value="'.dol_escape_htmltag($search_fax).'">';
print '</td>';
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_email" size="8" value="'.dol_escape_htmltag($search_email).'">';
print '</td>';
if (! empty($conf->skype->enabled))
if (! empty($arrayfields['p.lastname']['checked']))
{
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_skype" size="8" value="'.dol_escape_htmltag($search_skype).'">';
print '<input class="flat" type="text" name="search_firstname" size="6" value="'.dol_escape_htmltag($search_firstname).'">';
print '</td>';
}
if (! empty($arrayfields['p.poste']['checked']))
{
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_poste" size="5" value="'.dol_escape_htmltag($search_poste).'">';
print '</td>';
}
if (! empty($arrayfields['p.zip']['checked']))
{
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_zip" size="3" value="'.dol_escape_htmltag($search_zip).'">';
print '</td>';
}
if (! empty($arrayfields['p.town']['checked']))
{
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_town" size="5" value="'.dol_escape_htmltag($search_town).'">';
print '</td>';
}
if (! empty($arrayfields['p.phone']['checked']))
{
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_phone_pro" size="6" value="'.dol_escape_htmltag($search_phone_pro).'">';
print '</td>';
}
if (! empty($arrayfields['p.phone_perso']['checked']))
{
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_phone_perso" size="6" value="'.dol_escape_htmltag($search_phone_perso).'">';
print '</td>';
}
if (! empty($arrayfields['p.phone_mobile']['checked']))
{
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_phone_mobile" size="6" value="'.dol_escape_htmltag($search_phone_mobile).'">';
print '</td>';
}
if (! empty($arrayfields['p.fax']['checked']))
{
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_fax" size="6" value="'.dol_escape_htmltag($search_fax).'">';
print '</td>';
}
if (! empty($arrayfields['p.email']['checked']))
{
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_email" size="6" value="'.dol_escape_htmltag($search_email).'">';
print '</td>';
}
if (! empty($arrayfields['p.skype']['checked']))
{
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_skype" size="6" value="'.dol_escape_htmltag($search_skype).'">';
print '</td>';
}
if (! empty($arrayfields['p.thirdparty']['checked']))
{
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_societe" size="8" value="'.dol_escape_htmltag($search_societe).'">';
print '</td>';
}
if (! empty($arrayfields['p.priv']['checked']))
{
print '<td class="liste_titre" align="center">';
$selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate"));
print $form->selectarray('search_priv',$selectarray,$search_priv,1);
print '</td>';
}
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
}
}
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Date creation
if (! empty($arrayfields['p.datec']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
// Date modification
if (! empty($arrayfields['p.tms']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
if (! empty($arrayfields['p.statut']['checked']))
{
print '<td class="liste_titre" align="center">';
print $form->selectarray('search_status', array('-1'=>'', '0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status);
print '</td>';
}
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="center">';
$selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate"));
print $form->selectarray('search_priv',$selectarray,$search_priv,1);
print '</td>';
print '<td class="liste_titre" align="center">';
print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status);
print '</td>';
print '<td class="liste_titre" align="right">';
print '<input type="image" name="button_search" class="liste_titre" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '<input type="image" name="button_removefilter" class="liste_titre" src="'.img_picto($langs->trans("RemoveFilter"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
print '</td>';
print '</tr>';
$var=True;
@ -385,8 +583,6 @@ if ($result)
$var=!$var;
print "<tr ".$bc[$var].">";
// Name
print '<td valign="middle">';
$contactstatic->lastname=$obj->lastname;
$contactstatic->firstname='';
$contactstatic->id=$obj->cidp;
@ -395,17 +591,68 @@ if ($result)
$contactstatic->phone_pro=$obj->phone_pro;
$contactstatic->phone_perso=$obj->phone_perso;
$contactstatic->phone_mobile=$obj->phone_mobile;
print $contactstatic->getNomUrl(1,'',20);
print '</td>';
$contactstatic->zip=$obj->zip;
$contactstatic->town=$obj->town;
// Name
if (! empty($arrayfields['p.lastname']['checked']))
{
print '<td valign="middle">';
print $contactstatic->getNomUrl(1,'',20);
print '</td>';
}
// Firstname
print '<td>'.dol_trunc($obj->firstname,20).'</td>';
// Function
print '<td>'.dol_trunc($obj->poste,20).'</td>';
if (! empty($arrayfields['p.firstname']['checked']))
{
print '<td>'.dol_trunc($obj->firstname,20).'</td>';
}
// Zip
if (! empty($arrayfields['p.zip']['checked']))
{
print '<td>'.dol_trunc($obj->zip,20).'</td>';
}
// Town
if (! empty($arrayfields['p.town']['checked']))
{
print '<td>'.dol_trunc($obj->town,20).'</td>';
}
// Function
if (! empty($arrayfields['p.poste']['checked']))
{
print '<td>'.dol_trunc($obj->poste,20).'</td>';
}
// Phone
if (! empty($arrayfields['p.phone']['checked']))
{
print '<td>'.dol_print_phone($obj->phone_pro,$obj->country_code,$obj->cidp,$obj->socid,'AC_TEL').'</td>';
}
// Phone perso
if (! empty($arrayfields['p.phone_perso']['checked']))
{
print '<td>'.dol_print_phone($obj->phone_perso,$obj->country_code,$obj->cidp,$obj->socid,'AC_TEL').'</td>';
}
// Phone mobile
if (! empty($arrayfields['p.phone_mobile']['checked']))
{
print '<td>'.dol_print_phone($obj->phone_mobile,$obj->country_code,$obj->cidp,$obj->socid,'AC_TEL').'</td>';
}
// Fax
if (! empty($arrayfields['p.fax']['checked']))
{
print '<td>'.dol_print_phone($obj->fax,$obj->country_code,$obj->cidp,$obj->socid,'AC_TEL').'</td>';
}
// EMail
if (! empty($arrayfields['p.email']['checked']))
{
print '<td>'.dol_print_email($obj->email,$obj->cidp,$obj->socid,'AC_EMAIL',18).'</td>';
}
// Skype
if (! empty($arrayfields['p.skype']['checked']))
{
if (! empty($conf->skype->enabled)) { print '<td>'.dol_print_skype($obj->skype,$obj->cidp,$obj->socid,'AC_SKYPE',18).'</td>'; }
}
// Company
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
if (! empty($arrayfields['p.thirdparty']['checked']))
{
print '<td>';
if ($obj->socid)
@ -420,27 +667,53 @@ if ($result)
print '</td>';
}
// Phone
print '<td>'.dol_print_phone($obj->phone_pro,$obj->country_code,$obj->cidp,$obj->socid,'AC_TEL').'</td>';
// Phone mobile
print '<td>'.dol_print_phone($obj->phone_mobile,$obj->country_code,$obj->cidp,$obj->socid,'AC_TEL').'</td>';
// Fax
print '<td>'.dol_print_phone($obj->fax,$obj->country_code,$obj->cidp,$obj->socid,'AC_TEL').'</td>';
// EMail
print '<td>'.dol_print_email($obj->email,$obj->cidp,$obj->socid,'AC_EMAIL',18).'</td>';
// Skype
if (! empty($conf->skype->enabled)) { print '<td>'.dol_print_skype($obj->skype,$obj->cidp,$obj->socid,'AC_SKYPE',18).'</td>'; }
// Private/Public
if (! empty($arrayfields['p.priv']['checked']))
{
print '<td align="center">'.$contactstatic->LibPubPriv($obj->priv).'</td>';
}
// Date
print '<td align="center">'.dol_print_date($db->jdate($obj->tms),"day").'</td>';
// Private/Public
print '<td align="center">'.$contactstatic->LibPubPriv($obj->priv).'</td>';
// Status
print '<td align="center">'.$contactstatic->getLibStatut(3).'</td>';
// Links Add action and Export vcard
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
print '<td';
$align=$extrafields->getAlignFlag($key);
if ($align) print ' align="'.$align.'"';
print '>';
$tmpkey='options_'.$key;
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
print '</td>';
}
}
}
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
$reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Date creation
if (! empty($arrayfields['p.datec']['checked']))
{
print '<td align="center">';
print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
print '</td>';
}
// Date modification
if (! empty($arrayfields['p.tms']['checked']))
{
print '<td align="center">';
print dol_print_date($db->jdate($obj->date_update), 'dayhour');
print '</td>';
}
// Status
if (! empty($arrayfields['p.statut']['checked']))
{
print '<td align="center">'.$contactstatic->getLibStatut(3).'</td>';
}
// Action column - Links Add action and Export vcard
print '<td align="right">';
print '<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&amp;backtopage=1&amp;contactid='.$obj->cidp.'&amp;socid='.$obj->socid.'">'.img_object($langs->trans("AddAction"),"action").'</a>';
print ' &nbsp; ';

View File

@ -1042,7 +1042,7 @@ if ($action == 'create')
// Thirdparty
print '<tr>';
print '<td class="fieldrequired">'.$langs->trans('Thirdparty').'</td>';
print '<td class="fieldrequired">'.$langs->trans('ThirdParty').'</td>';
if ($socid>0)
{
print '<td colspan="2">';

View File

@ -190,7 +190,7 @@ if ($resql)
$moreforfilter.='</div>';
}
// If the user can view categories of products
if ($conf->categorie->enabled && $user->rights->produit->lire)
if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire))
{
include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$moreforfilter.='<div class="divsearchfield">';

View File

@ -0,0 +1,601 @@
<?php
/*
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
*
* 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/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/class/dolreceiptprinter.class.php
* \brief Print receipt ticket on various ESC/POS printer
*/
/*
* Tags for ticket template
*
* <dol_align_left> Left align text
* <dol_align_center> Center text
* <dol_align_right> Right align text
* <dol_use_font_a> Use font A of printer
* <dol_use_font_b> Use font B of printer
* <dol_use_font_c> Use font C of printer
* <dol_bold> </dol_bold> Text Bold
* <dol_double_height> </dol_double_height> Text double height
* <dol_double_width> </dol_double_width> Text double width
* <dol_underline> </dol_underline> Underline text
* <dol_underline_2dots> </dol_underline_2dots> Underline with double line
* <dol_emphasized> </dol_emphasized> Emphasized text
* <dol_switch_colors> </dol_switch_colors> Print in white on black
* <dol_print_barcode> Print barcode
* <dol_print_barcode_customer_id> Print barcode customer id
* <dol_set_print_width_57> Ticket print width of 57mm
* <dol_cut_paper_full> Cut ticket completely
* <dol_cut_paper_partial> Cut ticket partially
* <dol_open_drawer> Open cash drawer
* <dol_activate_buzzer> Activate buzzer
*
* Code which can be placed everywhere
* <dol_print_qrcode> Print QR Code
* <dol_print_date> Print date AAAA-MM-DD
* <dol_print_date_time> Print date and time AAAA-MM-DD HH:MM:SS
* <dol_print_year> Print Year
* <dol_print_month_letters> Print month in letters (example : november)
* <dol_print_month> Print month number
* <dol_print_day> Print day number
* <dol_print_day_letters> Print day number
* <dol_print_table> Print table number (for restaurant, bar...)
* <dol_print_cutlery> Print number of cutlery (for restaurant)
* <dol_print_payment> Print payment method
* <dol_print_logo> Print logo stored on printer. Example : <print_logo>32|32
* <dol_print_logo_old> Print logo stored on printer. Must be followed by logo code. For old printers.
* <dol_print_order_lines> Print order lines
* <dol_print_order_tax> Print order total tax
* <dol_print_order_local_tax> Print order local tax
* <dol_print_order_total> Print order total
* <dol_print_order_number> Print order number
* <dol_print_order_number_unique> Print order number after validation
* <dol_print_customer_firstname> Print customer firstname
* <dol_print_customer_lastname> Print customer name
* <dol_print_customer_mail> Print customer mail
* <dol_print_customer_phone> Print customer phone
* <dol_print_customer_mobile> Print customer mobile
* <dol_print_customer_skype> Print customer skype
* <dol_print_customer_tax_number> Print customer VAT number
* <dol_print_customer_account_balance> Print customer account balance
* <dol_print_vendor_last_name> Print vendor name
* <dol_print_vendor_first_name> Print vendor firstname
* <dol_print_vendor_mail> Print vendor mail
* <dol_print_customer_points> Print customer points
* <dol_print_order_points> Print number of points for this order
*
* Conditional code at line start (if…then Print)
* <dol_print_if_customer> Print the line IF a customer is affected to the order
* <dol_print_if_vendor> Print the line IF a vendor is affected to the order
* <dol_print_if_happy_hour> Print the line IF Happy Hour
* <dol_print_if_num_order_unique> Print the line IF order is validated
* <dol_print_if_customer_points> Print the line IF customer points > 0
* <dol_print_if_order_points> Print the line IF points of the order > 0
* <dol_print_if_customer_tax_number> Print the line IF customer has vat number
* <dol_print_if_customer_account_balance_positive> Print the line IF customer balance > 0
*
*/
require_once DOL_DOCUMENT_ROOT .'/includes/mike42/escpos-php/Escpos.php';
/**
* Class to manage Receipt Printers
*/
class dolReceiptPrinter extends Escpos
{
const CONNECTOR_DUMMY = 1;
const CONNECTOR_FILE_PRINT = 2;
const CONNECTOR_NETWORK_PRINT = 3;
const CONNECTOR_WINDOWS_PRINT = 4;
//const CONNECTOR_JAVA = 5;
var $db;
var $tags;
var $printer;
var $template;
var $error;
var $errors;
/**
* Constructor
*
* @param DoliDB $db database
*/
function __construct($db)
{
$this->db=$db;
$this->tags = array(
'dol_align_left',
'dol_align_center',
'dol_align_right',
'dol_use_font_a',
'dol_use_font_b',
'dol_use_font_c',
'dol_bold',
'/dol_bold',
'dol_double_height',
'/dol_double_height',
'dol_double_width',
'/dol_double_width',
'dol_underline',
'/dol_underline',
'dol_underline_2dots',
'/dol_underline',
'dol_emphasized',
'/dol_emphasized',
'dol_switch_colors',
'/dol_switch_colors',
'dol_print_barcode',
'dol_print_barcode_customer_id',
'dol_set_print_width_57',
'dol_cut_paper_full',
'dol_cut_paper_partial',
'dol_open_drawer',
'dol_activate_buzzer',
'dol_print_qrcode',
'dol_print_date',
'dol_print_date_time',
'dol_print_year',
'dol_print_month_letters',
'dol_print_month',
'dol_print_day',
'dol_print_day_letters',
'dol_print_table',
'dol_print_cutlery',
'dol_print_payment',
'dol_print_logo',
'dol_print_logo_old',
'dol_print_order_lines',
'dol_print_order_tax',
'dol_print_order_local_tax',
'dol_print_order_total',
'dol_print_order_number',
'dol_print_order_number_unique',
'dol_print_customer_firstname',
'dol_print_customer_lastname',
'dol_print_customer_mail',
'dol_print_customer_phone',
'dol_print_customer_mobile',
'dol_print_customer_skype',
'dol_print_customer_tax_number',
'dol_print_customer_account_balance',
'dol_print_vendor_lastname',
'dol_print_vendor_firstname',
'dol_print_vendor_mail',
'dol_print_customer_points',
'dol_print_order_points',
'dol_print_if_customer',
'dol_print_if_vendor',
'dol_print_if_happy_hour',
'dol_print_if_num_order_unique',
'dol_print_if_customer_points',
'dol_print_if_order_points',
'dol_print_if_customer_tax_number',
'dol_print_if_customer_account_balance_positive',
);
}
/**
* list printers
*
* @return int 0 if OK; >0 if KO
*/
function listPrinters()
{
global $conf;
$error = 0;
$line = 0;
$sql = 'SELECT rowid, name, fk_type, parameter';
$sql.= ' FROM '.MAIN_DB_PREFIX.'printer_receipt';
$sql.= ' WHERE entity = '.$conf->entity;
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
while ($line < $num) {
$obj[] = $this->db->fetch_array($resql);
$line++;
}
} else {
$error++;
$this->errors[] = $this->db->lasterror;
}
$this->listprinters = $obj;
return $error;
}
/**
* List printers templates
*
* @return int 0 if OK; >0 if KO
*/
function listPrintersTemplates()
{
global $conf;
$error = 0;
$line = 0;
$sql = 'SELECT rowid, name, template';
$sql.= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template';
$sql.= ' WHERE entity = '.$conf->entity;
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
while ($line < $num) {
$obj[] = $this->db->fetch_array($resql);
$line++;
}
} else {
$error++;
$this->errors[] = $this->db->lasterror;
}
$this->listprinterstemplates = $obj;
return $error;
}
/**
* Form to Select type printer
*
* @param string $selected Id printer type pre-selected
* @param string $htmlname select html name
* @return int 0 if OK; >0 if KO
*/
function selectTypePrinter($selected='', $htmlname='printertypeid')
{
global $langs;
$error = 0;
$html = '<select class="flat" name="'.$htmlname.'">';
$html.= '<option value="1" '.($selected==1?'selected="selected"':'').'>'.$langs->trans('CONNECTOR_DUMMY').'</option>';
$html.= '<option value="2" '.($selected==2?'selected="selected"':'').'>'.$langs->trans('CONNECTOR_FILE_PRINT').'</option>';
$html.= '<option value="3" '.($selected==3?'selected="selected"':'').'>'.$langs->trans('CONNECTOR_NETWORK_PRINT').'</option>';
$html.= '<option value="4" '.($selected==4?'selected="selected"':'').'>'.$langs->trans('CONNECTOR_WINDOWS_PRINT').'</option>';
//$html.= '<option value="5" '.($selected==5?'selected="selected"':'').'>'.$langs->trans('CONNECTOR_JAVA').'</option>';
$html.= '</select>';
$this->resprint = $html;
return $error;
}
/**
* Function to Add a printer in db
*
* @param string $name Printer name
* @param int $type Printer type
* @param string $parameter Printer parameter
* @return int 0 if OK; >0 if KO
*/
function AddPrinter($name, $type, $parameter)
{
global $conf;
$error = 0;
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'printer_receipt';
$sql.= ' (name, fk_type, parameter, entity)';
$sql.= ' VALUES ("'.$this->db->escape($name).'", '.$type.', "'.$this->db->escape($parameter).'", '.$conf->entity.')';
$resql = $this->db->query($sql);
if (! $resql) {
$error++;
$this->errors[] = $this->db->lasterror;
}
return $error;
}
/**
* Function to Update a printer in db
*
* @param string $name Printer name
* @param int $type Printer type
* @param string $parameter Printer parameter
* @param int $printerid Printer id
* @return int 0 if OK; >0 if KO
*/
function UpdatePrinter($name, $type, $parameter, $printerid)
{
global $conf;
$error = 0;
$sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt';
$sql.= ' SET name="'.$this->db->escape($name).'"';
$sql.= ', fk_type='.$type;
$sql.= ', parameter="'.$this->db->escape($parameter).'"';
$sql.= ' WHERE rowid='.$printerid;
$resql = $this->db->query($sql);
if (! $resql) {
$error++;
$this->errors[] = $this->db->lasterror;
}
return $error;
}
/**
* Function to Delete a printer from db
*
* @param int $printerid Printer id
* @return int 0 if OK; >0 if KO
*/
function DeletePrinter($printerid)
{
global $conf;
$error = 0;
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'printer_receipt';
$sql.= ' WHERE rowid='.$printerid;
$resql = $this->db->query($sql);
if (! $resql) {
$error++;
$this->errors[] = $this->db->lasterror;
}
return $error;
}
/**
* Function to Update a printer template in db
*
* @param string $name Template name
* @param int $template Template
* @param int $templateid Template id
* @return int 0 if OK; >0 if KO
*/
function UpdateTemplate($name, $template, $templateid)
{
global $conf;
$error = 0;
$sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt_template';
$sql.= ' SET name="'.$this->db->escape($name).'"';
$sql.= ', template="'.$this->db->escape($template).'"';
$sql.= ' WHERE rowid='.$templateid;
$resql = $this->db->query($sql);
if (! $resql) {
$error++;
$this->errors[] = $this->db->lasterror;
}
return $error;
}
/**
* Function to Send Test page to Printer
*
* @param int $printerid Printer id
* @return int 0 if OK; >0 if KO
*/
function SendTestToPrinter($printerid)
{
global $conf;
$error = 0;
$img = new EscposImage(DOL_DOCUMENT_ROOT .'/theme/common/dolibarr_logo_bw.png');
$ret = $this->InitPrinter($printerid);
if ($ret>0) {
setEventMessages($this->error, $this->errors, 'errors');
} else {
try {
$this->printer->graphics($img);
$this->printer->text("Hello World!\n");
$testStr = "Testing 123";
$this->printer->qrCode($testStr);
$this->printer->text("Most simple example\n");
$this->printer->feed();
$this->printer->cut();
//print '<pre>'.print_r($this->connector, true).'</pre>';
$this->printer->close();
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
$error++;
}
}
return $error;
}
/**
* Function to Print Receipt Ticket
*
* @param object $object order or invoice object
* @param int $templateid Template id
* @param int $printerid Printer id
* @return int 0 if OK; >0 if KO
*/
function SendToPrinter($object, $templateid, $printerid)
{
global $conf;
$error = 0;
$ret = $this->loadTemplate($templateid);
// tags a remplacer par leur valeur avant de parser
$this->template = str_replace('<dol_print_num_order>', $object->id, $this->template);
$this->template = str_replace('<dol_print_customer_firstname>', $object->customer_firstname, $this->template);
$this->template = str_replace('<dol_print_customer_lastname>', $object->customer_lastname, $this->template);
$this->template = str_replace('<dol_print_customer_mail>', $object->customer_mail, $this->template);
$this->template = str_replace('<dol_print_customer_phone>', $object->customer_phone, $this->template);
$this->template = str_replace('<dol_print_customer_mobile>', $object->customer_mobile, $this->template);
$this->template = str_replace('<dol_print_customer_skype>', $object->customer_skype, $this->template);
$this->template = str_replace('<dol_print_customer_tax_number>', $object->customer_tax_number, $this->template);
$this->template = str_replace('<dol_print_customer_account_balance>', $object->customer_account_balance, $this->template);
$this->template = str_replace('<dol_print_vendor_firstname>', $object->vendor_firstname, $this->template);
$this->template = str_replace('<dol_print_vendor_lastname>', $object->vendor_lastname, $this->template);
$this->template = str_replace('<dol_print_date_time>', $object->date_time, $this->template);
// parse template
$p = xml_parser_create();
xml_parse_into_struct($p, $this->template, $vals, $index);
xml_parser_free($p);
//print '<pre>'.print_r($index, true).'</pre>';
//print '<pre>'.print_r($vals, true).'</pre>';
// print ticket
$level = 0;
$html = '<table border="1" style="width:210px"><pre>';
$ret = $this->InitPrinter($printerid);
if ($ret>0) {
setEventMessages($this->error, $this->errors, 'errors');
} else {
for ($line=0; $line < count($vals); $line++) {
switch ($vals[$line]['tag']) {
case 'DOL_ALIGN_CENTER':
$this->printer->setJustification(Escpos::JUSTIFY_CENTER);
$html.='<center>';
$this->printer->text($vals[$line]['value']);
break;
case 'DOL_ALIGN_RIGHT':
$this->printer->setJustification(Escpos::JUSTIFY_RIGHT);
$html.='<right>';
break;
case 'DOL_ALIGN_LEFT':
$this->printer->setJustification(Escpos::JUSTIFY_LEFT);
$html.='<left>';
break;
case 'DOL_OPEN_DRAWER':
$this->printer->pulse();
$html.= ' &#991;'.nl2br($vals[$line]['value']);
break;
case 'DOL_PRINT_BARCODE':
// $vals[$line]['value'] -> barcode($content, $type)
$this->printer->barcode($object->barcode);
break;
case 'DOL_PRINT_QRCODE':
// $vals[$line]['value'] -> qrCode($content, $ec, $size, $model)
$this->printer->qrcode($vals[$line]['value']);
$html.='QRCODE: '.$vals[$line]['value'];
break;
case 'DOL_CUT_PAPER_FULL':
$this->printer->cut(Escpos::CUT_FULL);
$html.= ' &#9986;'.nl2br($vals[$line]['value']);
break;
case 'DOL_CUT_PAPER_PARTIAL':
$this->printer->cut(Escpos::CUT_PARTIAL);
$html.= ' &#9986;'.nl2br($vals[$line]['value']);
break;
case 'DOL_USE_FONT_A':
$this->printer->setFont(Escpos::FONT_A);
$this->printer->text($vals[$line]['value']);
break;
case 'DOL_USE_FONT_B':
$this->printer->setFont(Escpos::FONT_B);
$this->printer->text($vals[$line]['value']);
break;
case 'DOL_USE_FONT_C':
$this->printer->setFont(Escpos::FONT_C);
$this->printer->text($vals[$line]['value']);
break;
default:
$this->printer->text($vals[$line]['value']);
$html.= nl2br($vals[$line]['value']);
$this->errors[] = 'UnknowTag: &lt;'.strtolower($vals[$line]['tag']).'&gt;';
$error++;
break;
}
}
$html.= '</pre></table>';
print $html;
// Close and print
// uncomment next line to see content sent to printer
//print '<pre>'.print_r($this->connector, true).'</pre>';
$this->printer->close();
}
return $error;
}
/**
* Function to load Template
*
* @param int $templateid Template id
* @return int 0 if OK; >0 if KO
*/
function loadTemplate($templateid)
{
global $conf;
$error = 0;
$sql = 'SELECT template';
$sql.= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template';
$sql.= ' WHERE rowid='.$templateid;
$sql.= ' AND entity = '.$conf->entity;
$resql = $this->db->query($sql);
if ($resql) {
$obj = $this->db->fetch_array($resql);
} else {
$error++;
$this->errors[] = $this->db->lasterror;
}
if (empty($obj)) {
$error++;
$this->errors[] = 'TemplateDontExist';
} else {
$this->template = $obj['0'];
}
return $error;
}
/**
* Function Init Printer
*
* @param int $printerid Printer id
* @return int 0 if OK; >0 if KO
*/
function InitPrinter($printerid)
{
global $conf;
$error=0;
$sql = 'SELECT rowid, name, fk_type, parameter';
$sql.= ' FROM '.MAIN_DB_PREFIX.'printer_receipt';
$sql.= ' WHERE rowid = '.$printerid;
$sql.= ' AND entity = '.$conf->entity;
$resql = $this->db->query($sql);
if ($resql) {
$obj = $this->db->fetch_array($resql);
} else {
$error++;
$this->errors[] = $this->db->lasterror;
}
if (empty($obj)) {
$error++;
$this->errors[] = 'PrinterDontExist';
}
if (! $error) {
$parameter = $obj['parameter'];
try {
switch ($obj['fk_type']) {
case 1:
require_once DOL_DOCUMENT_ROOT .'/includes/escpos/src/DummyPrintConnector.php';
$this->connector = new DummyPrintConnector();
break;
case 2:
$this->connector = new FilePrintConnector($parameter);
break;
case 3:
$parameters = explode(':', $parameter);
$this->connector = new NetworkPrintConnector($parameters[0], $parameters[1]);
break;
case 4:
$this->connector = new WindowsPrintConnector($parameter);
break;
default:
$this->connector = 'CONNECTOR_UNKNOWN';
break;
}
$this->printer = new Escpos($this->connector);
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
$error++;
}
}
return $error;
}
}

View File

@ -258,7 +258,7 @@ class ExtraFields
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));
}

View File

@ -118,7 +118,7 @@ class HookManager
* @param Object $object Object to use hooks on
* @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...)
* @return mixed For 'addreplace hooks (doActions,formObjectOptions,pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop standard actions, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results and set into ->resArray.
* For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results and set into ->resArray.
* For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results and set into ->resArray.
* All types can also return some values into an array ->results.
* $this->error or this->errors are also defined by class called by this function if error.
*/
@ -169,7 +169,7 @@ class HookManager
)
)) $hooktype='addreplace';
// Deprecated hook types ('returnvalue')
if (preg_match('/^pdf_/',$method) && $method != 'pdf_writelinedesc') $hooktype='returnvalue'; // pdf_xxx except pdf_writelinedesc are 'returnvalue' hooks. When there is 2 hooks of this type, only last one win. TODO Move them into 'output' or 'addreplace' hooks.
//if (preg_match('/^pdf_/',$method) && $method != 'pdf_writelinedesc') $hooktype='returnvalue'; // pdf_xxx except pdf_writelinedesc are 'returnvalue' hooks. When there is 2 hooks of this type, only last one win. TODO Move them into 'output' or 'addreplace' hooks.
if ($method == 'insertExtraFields')
{
$hooktype='returnvalue'; // deprecated. TODO Remove all code with "executeHooks('insertExtraFields'" as soon as there is a trigger available.

View File

@ -1546,7 +1546,7 @@ class Form
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) {
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';
$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>';
$i = 0;
@ -4057,10 +4057,11 @@ class Form
* @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 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
* @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;
@ -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;
print $retstring;
@ -4513,22 +4521,26 @@ class Form
* @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 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 $delayedhtmlcontent;
$out = '';
$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">
$(document).ready(function () {
'.($callurlonselect ? 'var saveRemoteData = [];':'').'
'.($callurlonselect ? 'var saveRemoteData = [];':'').'
$(".'.$htmlname.'").select2({
$(".'.$htmlname.'").select2({
ajax: {
dir: "ltr",
url: "'.$url.'",
@ -4584,12 +4596,17 @@ class Form
});
});' : '' ) . '
});
</script>';
});
</script>';
$out.='<input type="text" class="'.$htmlname.($morecss?' '.$morecss:'').'" '.($moreparam?$moreparam.' ':'').'name="'.$htmlname.'">';
if ($acceptdelayedhtml)
{
$delayedhtmlcontent.=$outdelayed;
}
else
{
$out.=$outdelayed;
}
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.
*
* @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 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)
@ -5192,7 +5209,7 @@ class Form
$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')
{
$ret.=dol_htmlentities($object->name);
@ -5360,7 +5377,7 @@ class Form
else
{
$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';
if ($object->gender == 'man') $nophoto='/public/theme/common/user_man.png';

View File

@ -800,13 +800,14 @@ function unActivateModule($value, $requiredby=1)
}
else
{
// TODO Replace this after DolibarrModules is moved as abstract class with a try catch to show module is bugged
//print $dir.$modFile;
// TODO Replace this after DolibarrModules is moved as abstract class with a try catch to show module we try to disable has not been found or could not be loaded
$genericMod = new DolibarrModules($db);
$genericMod->name=preg_replace('/^mod/i','',$modName);
$genericMod->rights_class=strtolower(preg_replace('/^mod/i','',$modName));
$genericMod->const_name='MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',$modName));
dol_syslog("modules::unActivateModule Failed to find module file, we use generic function with name " . $modName);
$genericMod->_remove('');
$genericMod->_remove(array());
}
// Desactivation des modules qui dependent de lui

View File

@ -171,6 +171,7 @@ 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

View File

@ -106,7 +106,7 @@ function doc_getlinedesc($line,$outputlangs,$hideref=0,$hidedesc=0,$issupplierli
$ref_prodserv = "";
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")." ";
}

View File

@ -854,7 +854,7 @@ function dol_get_fiche_end($notab=0)
* Show tab footer of a card
*
* @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 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)
@ -870,28 +870,67 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
{
global $conf, $form, $user, $langs;
//$showlogo=$object->logo;
$showlogo=1;
$maxvisiblephotos=1;
$showimage=1;
$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;
$modulepart='societe';
$modulepart='unknown';
if ($object->element == 'societe') $modulepart='societe';
if ($object->element == 'contact') $modulepart='contact';
if ($object->element == 'member') $modulepart='memberphoto';
if ($object->element == 'user') $modulepart='userphoto';
if ($object->element == 'product') $modulepart='product';
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 ($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');
} else {
}
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 {
$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);
}
if (! empty($object->name_alias)) $morehtmlref.='<div class="refidno">'.$object->name_alias.'</div>';
$morehtmlref.='<div class="refidno">';
$morehtmlref.=$object->getBannerAddress('refaddress',$object);
$morehtmlref.='</div>';
if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && in_array($object->element, array('societe', 'contact', 'member')))
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.=$object->getBannerAddress('refaddress',$object);
$morehtmlref.='</div>';
}
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.=$langs->trans("TechnicalID").': '.$object->id;
@ -3860,7 +3899,7 @@ function get_exdir($num,$level,$alpha,$withoutslash,$object,$modulepart)
$path = '';
if (! empty($level) && in_array($modulepart, array('cheque','user','category','holiday','shipment', 'member','don','donation','supplier_invoice','invoice_supplier')))
if (! empty($level) && in_array($modulepart, array('cheque','user','category','holiday','shipment', 'member','don','donation','supplier_invoice','invoice_supplier','mailing')))
{
// This part should be removed once all code is using "get_exdir" to forge path, with all parameters provided
if (empty($alpha)) $num = preg_replace('/([^0-9])/i','',$num);
@ -5154,6 +5193,10 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0)
{
global $db,$langs;
if ($mode == 0)
{
$value=preg_replace('/\*/','%',$value); // Replace * with %
}
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
@ -5225,17 +5268,17 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0)
/**
* 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 $extImgTarget Force image format for thumbs. Use '' to keep same extension than original image.
* @return string New file name
* @param string $extImgTarget Force image extension for thumbs. Use '' to keep same extension than original image.
* @return string New file name (full or relative path, including the thumbs/)
*/
function getImageFileNameForSize($file, $extName, $extImgTarget='')
{
$dirName = dirname($file);
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);
if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.jpg$/i',$file)?'.jpg':'');
@ -5249,5 +5292,5 @@ function getImageFileNameForSize($file, $extName, $extImgTarget='')
$subdir='';
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
}
//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)
{
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 = 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
//$fp = fopen($imgThumbName, "w");

View File

@ -515,7 +515,7 @@ function pdf_pagehead(&$pdf,$outputlangs,$page_height)
global $conf;
// Add a background image on document
if (! empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) // Warning, this option make TCPDF generation beeing crazy and some content disappeared behin the image
if (! empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) // Warning, this option make TCPDF generation being crazy and some content disappeared behind the image
{
$pdf->SetAutoPageBreak(0,0); // Disable auto pagebreak before adding image
$pdf->Image($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_X:0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y:0), 0, $page_height);
@ -1166,7 +1166,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
$ref_prodserv = "";
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")." ";
}

View File

@ -98,7 +98,7 @@ function product_prepare_head($object)
$head[$h][2] = 'referers';
$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)
{

View File

@ -0,0 +1,72 @@
<?php
/* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/lib/receiptprinter.lib.php
* \ingroup printing
* \brief Library for receipt printer functions
*/
/**
* Define head array for tabs of receipt printer setup pages
*
* @param string $mode Mode
* @return Array of head
*/
function receiptprinteradmin_prepare_head($mode)
{
global $langs, $conf;
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT."/admin/receiptprinter.php?mode=config";
$head[$h][1] = $langs->trans("ListPrinters");
$head[$h][2] = 'config';
$h++;
$head[$h][0] = DOL_URL_ROOT."/admin/receiptprinter.php?mode=template";
$head[$h][1] = $langs->trans("SetupReceiptTemplate");
$head[$h][2] = 'template';
$h++;
if ($mode == 'test')
{
$head[$h][0] = DOL_URL_ROOT."/admin/receiptprinter.php?mode=test";
$head[$h][1] = $langs->trans("TargetedPrinter");
$head[$h][2] = 'test';
$h++;
}
//$object=new stdClass();
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab
//complete_head_from_modules($conf,$langs,$object,$head,$h,'printingadmin');
//complete_head_from_modules($conf,$langs,$object,$head,$h,'printing','remove');
return $head;
}

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', 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->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
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', 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
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__);

View File

@ -1088,7 +1088,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
}
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);
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

@ -201,15 +201,15 @@ class DolibarrModules // Can not be abstract, because we need to insta
*
* @param DoliDB $db Database handler
*/
public function __construct($db)
{
$this->db = $db;
}
// We should but can't set this as abstract because this will make dolibarr hang
// after migration due to old module not implementing. We must wait PHP is able to make
// a try catch on Fatal error to manage this correctly.
function __construct($db)
{
$this->db=$db;
}
// We need constructor into function unActivateModule into admin.lib.php
/**
* Enables a module.
* Inserts all informations into database

View File

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

View File

@ -1503,7 +1503,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ReplacementInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
}
if ($object->type == 2)
if ($object->type == 2 && !empty($object->fk_facture_source))
{
$objectreplaced=new Facture($this->db);
$objectreplaced->fetch($object->fk_facture_source);
@ -1546,10 +1546,13 @@ class pdf_crabe extends ModelePDFFactures
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);
// Show sender
$posy=42;
$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
$posx=$this->marge_gauche;
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
$hautcadre=40;
$hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
// Show sender frame
$pdf->SetTextColor(0,0,0);
@ -1558,19 +1561,19 @@ class pdf_crabe extends ModelePDFFactures
$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
$pdf->SetXY($posx,$posy);
$pdf->SetFillColor(230,230,230);
$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
$pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
$pdf->SetTextColor(0,0,60);
// Show sender name
$pdf->SetXY($posx+2,$posy+3);
$pdf->SetFont('','B', $default_font_size);
$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
$pdf->MultiCell($widthrecbox-2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
$posy=$pdf->getY();
// Show sender information
$pdf->SetXY($posx+2,$posy);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
$pdf->MultiCell($widthrecbox-2, 4, $carac_emetteur, 0, 'L');
@ -1596,9 +1599,9 @@ class pdf_crabe extends ModelePDFFactures
$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,($usecontact?$object->contact:''),$usecontact,'target');
// Show recipient
$widthrecbox=100;
$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
$posy=42;
$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;

View File

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

View File

@ -51,7 +51,7 @@ class modOauth extends DolibarrModules
$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)
$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);
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
$this->special = 1;

View File

@ -0,0 +1,145 @@
<?php
/* Copyright (C) 2014-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
*
* 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/>.
*/
/** \defgroup printing Module Receipt Printer
* \brief Module for activation of printing icon to make receipt ticket
*/
/**
* \file htdocs/core/modules/modReceiptPrinter.class.php
* \ingroup printing
* \brief File of class to describe and activate module Receipt Printer
*/
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
/**
* Class to describe and activate module Receipt Printer
*/
class modReceiptPrinter extends DolibarrModules
{
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
$this->db = $db ;
$this->numero = 67000;
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
// It is used to group modules in module setup page
$this->family = "technic";
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$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)
$this->description = "ReceiptPrinterDesc";
$this->version = 'development'; // 'development' or 'experimental' or 'dolibarr' or version
$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)
$this->special = 1;
// Name of image file used for this module.
// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
$this->picto = 'printer';
// Data directories to create when module is enabled.
$this->dirs = array();
// Config pages
$this->config_page_url = array("receiptprinter.php");
// Dependencies
$this->depends = array();
$this->requiredby = array();
$this->phpmin = array(5,1); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(3,9,-2); // Minimum version of Dolibarr required by module
$this->conflictwith = array();
$this->langfiles = array("receiptprinter");
// Constants
$this->const = array();
// Boxes
$this->boxes = array();
// Permissions
$this->rights = array();
$this->rights_class = 'receiptprinter';
$r=0;
// $this->rights[$r][0] Id permission (unique tous modules confondus)
// $this->rights[$r][1] Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission)
// $this->rights[$r][2] Non utilise
// $this->rights[$r][3] 1=Permis par defaut, 0=Non permis par defaut
// $this->rights[$r][4] Niveau 1 pour nommer permission dans code
// $this->rights[$r][5] Niveau 2 pour nommer permission dans code
$r++;
$this->rights[$r][0] = 67000;
$this->rights[$r][1] = 'ReceiptPrinter';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 1;
$this->rights[$r][4] = 'read';
// Main menu entries
$this->menus = array(); // List of menus to add
$r=0;
// This is to declare the Top Menu entry:
//$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', // Put 0 if this is a top menu
// 'type'=>'left', // This is a Top menu entry
// 'titre'=>'MenuDirectPrinting',
// 'mainmenu'=>'printing',
// 'url'=>'/printing/index.php',
// 'langs'=>'printing', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
// 'position'=>300,
// 'enabled'=>'$conf->printing->enabled && $leftmenu==\'modulesadmintools\'',
// 'perms'=>'$user->rights->printing->read', // Use 'perms'=>'1' if you want your menu with no permission rules
// 'target'=>'',
// 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both
$r++;
}
/**
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function init($options='')
{
global $conf;
// Clean before activation
$this->remove($options);
$sql = array(
"CREATE TABLE IF NOT EXISTS llx_printer_receipt (rowid int(11) NOT NULL AUTO_INCREMENT, name varchar(128), fk_type int(11), parameter varchar(128), entity int(11), PRIMARY KEY (rowid)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;",
"CREATE TABLE IF NOT EXISTS llx_printer_receipt_template (rowid int(11) NOT NULL AUTO_INCREMENT, name varchar(128), template text, entity int(11), PRIMARY KEY (rowid)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;",
);
return $this->_init($sql,$options);
}
}

View File

@ -30,12 +30,25 @@ use OAuth\Common\Consumer\Credentials;
use OAuth\Common\Token\TokenInterface;
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');
$backtourl = GETPOST('backtourl', 'alpha');
/**
* Create a new instance of the URI class with the current URI, stripping the query string
*/
$uriFactory = new \OAuth\Common\Http\Uri\UriFactory();
$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER);
$currentUri->setQuery('');
//$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER);
//$currentUri->setQuery('');
$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php');
/**
* Load the credential for the service
@ -43,8 +56,15 @@ $currentUri->setQuery('');
/** @var $serviceFactory \OAuth\ServiceFactory An OAuth service factory. */
$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
$storage = new DoliStorage($db, $conf);
// Setup the credentials for the requests
$credentials = new Credentials(
$conf->global->OAUTH_GOOGLE_ID,
@ -52,6 +72,7 @@ $credentials = new Credentials(
$currentUri->getAbsoluteUri()
);
// Instantiate the Api service using the credentials, http client and storage mechanism for the token
/** @var $apiService Service */
// TODO remove hardcoded array
@ -59,52 +80,71 @@ $apiService = $serviceFactory->createService('Google', $credentials, $storage, a
// access type needed for google refresh token
$apiService->setAccessType('offline');
//print '<pre>'.print_r($apiService,true).'</pre>';
//print 'Has access Token: '.($storage->hasAccessToken('Google')?'Yes':'No').'</ br>';
//print 'Has Author State: '.($storage->hasAuthorizationState('Google')?'Yes':'No').'</ br>';
//print 'Authorization State: '.$storage->retrieveAuthorizationState('Google').'</ br>';
//print '<td><pre>'.print_r($token,true).'</pre></td>';
if (! empty($_GET['code'])) {
llxHeader('',$langs->trans("OAuthSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("OAuthSetup"),$linkback,'title_setup');
$langs->load("oauth");
/*
* Actions
*/
if ($action == 'delete')
{
$storage->clearToken('Google');
setEventMessages($langs->trans('TokenDeleted'), null, 'mesgs');
header('Location: ' . $backtourl);
exit();
}
if (! empty($_GET['code'])) // We are coming from Google oauth page
{
//llxHeader('',$langs->trans("OAuthSetup"));
//$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
$state = isset($_GET['state']) ? $_GET['state'] : null;
try {
$token = $storage->retrieveAccessToken('Google');
} catch (Exception $e) {
print $e->getMessage();
}
//print '<pre>'.print_r($token->getRefreshToken(),true).'</pre>';
//$refreshtoken = $token->getRefreshToken();
//print '<table>';
// This was a callback request from service, get the token
$apiService->requestAccessToken($_GET['code'], $state);
//print '<pre>'.print_r($apiService,true).'</pre>';
try {
$token = $storage->retrieveAccessToken('Google');
//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) {
print $e->getMessage();
}
$newrefreshtoken = $token->getRefreshToken();
if (empty($newrefreshtoken) && ! empty($refreshtoken)) {
$token->setRefreshToken($refreshtoken);
$storage->storeAccessToken('Google', $token);
}
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>';
} else {
$backtourl = $_SESSION["backtourlsavedbeforeoauthjump"];
unset($_SESSION["backtourlsavedbeforeoauthjump"]);
header('Location: ' . $backtourl);
exit();
}
else
{
$_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl;
$url = $apiService->getAuthorizationUri();
// we go on google authorization page
header('Location: ' . $url);
exit();
}
llxFooter();
/*
* View
*/
// No view at all, just actions
$db->close();

View File

@ -87,6 +87,8 @@ class printing_printgcp extends PrintingDriver
$this->errors[] = $e->getMessage();
$token_ok = false;
}
//var_dump($this->errors);exit;
$expire = false;
// Is token expired or will token expire in the next 30 seconds
if ($token_ok) {
@ -116,9 +118,13 @@ class printing_printgcp extends PrintingDriver
$refreshtoken = $token->getRefreshToken();
$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_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')) {
$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 {
$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');
}
$this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php', 'type'=>'authlink');
} else {
$this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthNotConfigured', 'type'=>'info');
}
@ -369,7 +375,8 @@ class printing_printgcp extends PrintingDriver
*/
function list_jobs()
{
global $conf, $db, $bc;
global $conf, $db, $langs, $bc;
$error = 0;
$html = '';
// Token storage
@ -432,20 +439,31 @@ class printing_printgcp extends PrintingDriver
$var = True;
$jobs = $responsedata['jobs'];
//$html .= '<pre>'.print_r($jobs['0'],true).'</pre>';
foreach ($jobs as $value )
if (is_array($jobs))
{
$var = !$var;
$html .= '<tr '.$bc[$var].'>';
$html .= '<td>'.$value['id'].'</td>';
$html .= '<td>'.$value['ownerId'].'</td>';
$html .= '<td>'.$value['printerName'].'</td>';
$html .= '<td>'.$value['title'].'</td>';
$html .= '<td>'.$value['status'].'</td>';
$html .= '<td>&nbsp;</td>';
$html .= '</tr>';
foreach ($jobs as $value)
{
$var = !$var;
$html .= '<tr '.$bc[$var].'>';
$html .= '<td>'.$value['id'].'</td>';
$html .= '<td>'.$value['ownerId'].'</td>';
$html .= '<td>'.$value['printerName'].'</td>';
$html .= '<td>'.$value['title'].'</td>';
$html .= '<td>'.$value['status'].'</td>';
$html .= '<td>&nbsp;</td>';
$html .= '</tr>';
}
}
else
{
$html .= '<tr '.$bc[$var].'>';
$html .= '<td colspan="6">'.$langs->trans("None").'</td>';
$html .= '</tr>';
}
$html .= '</table>';
$this->resprint = $html;
return $error;
}

View File

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

View File

@ -5,6 +5,7 @@
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* 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
* it under the terms of the GNU General Public License as published by
@ -315,14 +316,39 @@ else {
<?php
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;
else $colspan = 9;
if($this->situation_cycle_ref) $colspan++;
if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc
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
$colspan = 6;
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
$colspan++;
}
if ($this->situation_cycle_ref) {
$colspan++;
}
// We add 1 if col total ttc
if (!empty($inputalsopricewithtax)) {
$colspan++;
}
if ($conf->global->PRODUCT_USE_UNITS) {
$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))
{
@ -489,6 +515,7 @@ jQuery(document).ready(function() {
});
$("#prod_entry_mode_predef").on( "click", function() {
console.log("click prod_entry_mode_predef");
setforpredef();
jQuery('#trlinefordates').show();
});
@ -496,6 +523,7 @@ jQuery(document).ready(function() {
/* When changing predefined product, we reload list of supplier prices */
$("#idprod, #idprodfournprice").change(function()
{
console.log("change #idprod, #idprodfournprice, conf->global->MARGIN_TYPE=<?php echo $conf->global->MARGIN_TYPE ?>");
setforpredef();
jQuery('#trlinefordates').show();
@ -506,16 +534,17 @@ jQuery(document).ready(function() {
?>
/* Code for margin */
$("#fournprice_predef options").remove();
$("#fournprice_predef").find("option").remove();
$("#fournprice_predef").hide();
$("#buying_price").val("").show();
/* Call post to load content of combo list fournprice_predef */
$.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', { 'idprod': $(this).val() }, function(data) {
$.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php?bestpricefirst=1', { 'idprod': $(this).val() }, function(data) {
if (data && data.length > 0)
{
var options = '';
var defaultkey = '';
var defaultprice = '';
var bestpricefound = 0;
var i = 0;
$(data).each(function() {
if (this.id != 'pmpprice')
@ -524,24 +553,23 @@ jQuery(document).ready(function() {
this.price = parseFloat(this.price);//fix this.price >0
// If margin is calculated on best supplier price, we set it by defaut (but only if value is not 0)
var defaultbuyprice = '<?php echo ((isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == '1')?'bestsupplierprice':''); ?>';
if (i == 1 && this.price > 0 && 'bestsupplierprice' == defaultbuyprice) { defaultkey = this.id; defaultprice = this.price; }
options += '<option value="'+this.id+'" price="'+this.price+'"';
if (this.price > 0 && i == 1) { defaultkey = this.id; defaultprice = this.price; }
options += '>'+this.label+'</option>';
var defaultbuyprice = '<?php echo ((isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == '1')?'bestsupplierprice':''); ?>'; // We set here default value to use
console.log(this.id+" "+this.price+" "+defaultbuyprice+" "+(this.price > 0));
if (bestpricefound == 0 && this.price > 0 && 'bestsupplierprice' == defaultbuyprice) { defaultkey = this.id; defaultprice = this.price; bestpricefound=1; } // bestpricefound is used to take the first price > 0
}
if (this.id == 'pmpprice')
{
// If margin is calculated on PMP, we set it by defaut (but only if value is not 0)
var defaultbuyprice = '<?php echo ((isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'pmp')?'pmp':''); ?>';
console.log(this.id+" "+this.price+" "+defaultbuyprice);
if (this.price > 0 && 'pmp' == defaultbuyprice) { defaultkey = this.id; defaultprice = this.price; }
options += '<option value="'+this.id+'" price="'+this.price+'">'+this.label+'</option>';
}
options += '<option value="'+this.id+'" price="'+this.price+'">'+this.label+'</option>';
});
options += '<option value="inputprice" price="'+defaultprice+'"><?php echo $langs->trans("InputPrice"); ?></option>';
console.log("defaultkey="+defaultkey);
$("#fournprice_predef").html(options).show();
if (defaultkey != '')
{
@ -556,6 +584,7 @@ jQuery(document).ready(function() {
$("#buying_price").val(Math.round(defaultprice,<?php print ($conf->global->MAIN_MAX_DECIMALS_UNIT ? $conf->global->MAIN_MAX_DECIMALS_UNIT : 5); ?>));
$("#fournprice_predef").change(function() {
console.log("change on fournprice_predef");
/* Hide field buying_price according to choice into list (if 'inputprice' or not) */
var linevalue=$(this).find('option:selected').val();
var pricevalue = $(this).find('option:selected').attr("price");

View File

@ -1048,7 +1048,7 @@ class Expedition extends CommonObject
// no lot/serial
// We increment stock of product (and sub-products)
// We use warehouse selected for each line
$result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, $obj->subprice, $langs->trans("ShipmentDeletedInDolibarr", $this->ref));
$result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, 0, $langs->trans("ShipmentDeletedInDolibarr", $this->ref)); // price is set to 0 because we dont want to see WAP changed
if ($result < 0)
{
$error++;$this->errors=$this->errors + $mouvS->errors;
@ -1061,7 +1061,7 @@ class Expedition extends CommonObject
// We use warehouse selected for each line
foreach($lotArray as $lot)
{
$result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $lot->dluo_qty, $obj->subprice, $langs->trans("ShipmentDeletedInDolibarr", $this->ref), $lot->eatby, $lot->sellby, $lot->batch);
$result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $lot->dluo_qty, 0, $langs->trans("ShipmentDeletedInDolibarr", $this->ref), $lot->eatby, $lot->sellby, $lot->batch); // price is set to 0 because we dont want to see WAP changed
if ($result < 0)
{
$error++;$this->errors=$this->errors + $mouvS->errors;

View File

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

View File

@ -30,6 +30,7 @@
* \brief File that include conf.php file and commons lib like functions.lib.php
*/
if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr');
if (! defined('DOL_VERSION')) define('DOL_VERSION','3.9.0-beta');
if (! defined('EURO')) define('EURO',chr(128));

View File

@ -39,7 +39,7 @@ $langs->load('stocks');
/*
* View
*/
*/
top_httphead();
@ -49,7 +49,11 @@ if ($idprod > 0)
{
$producttmp=new ProductFournisseur($db);
$producttmp->fetch($idprod);
$productSupplierArray = $producttmp->list_product_fournisseur_price($idprod, 's.nom, pfp.quantity, pfp.price'); // We list all price per supplier, and then firstly with the lower quantity. So we can choose first one with enough quantity into list.
$sorttouse = 's.nom, pfp.quantity, pfp.price';
if (GETPOST('bestpricefirst')) $sorttouse = 'pfp.unitprice, s.nom, pfp.quantity, pfp.price';
$productSupplierArray = $producttmp->list_product_fournisseur_price($idprod, $sorttouse); // We list all price per supplier, and then firstly with the lower quantity. So we can choose first one with enough quantity into list.
if ( is_array($productSupplierArray))
{
foreach ($productSupplierArray as $productSupplier)
@ -81,13 +85,13 @@ if ($idprod > 0)
$label = price($price,0,$langs,0,0,-1,$conf->currency)."/".$langs->trans("Unit");
if ($productSupplier->fourn_ref) $label.=' ('.$productSupplier->fourn_ref.')';
$prices[] = array("id" => $productSupplier->product_fourn_price_id, "price" => price($price,0,'',0), "label" => $label, "title" => $title);
$prices[] = array("id" => $productSupplier->product_fourn_price_id, "price" => price2num($price,0,'',0), "label" => $label, "title" => $title); // For price field, we must use price2num(), for label or title, price()
}
}
// Add price for pmp
$price=$producttmp->pmp;
$prices[] = array("id" => 'pmpprice', "price" => $price, "label" => $langs->trans("PMPValueShort").': '.price($price,0,$langs,0,0,-1,$conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price,0,$langs,0,0,-1,$conf->currency));
$prices[] = array("id" => 'pmpprice', "price" => price2num($price), "label" => $langs->trans("PMPValueShort").': '.price($price,0,$langs,0,0,-1,$conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price,0,$langs,0,0,-1,$conf->currency)); // For price field, we must use price2num(), for label or title, price()
}
echo json_encode($prices);

View File

@ -481,7 +481,7 @@ class CommandeFournisseur extends CommonOrder
}
else
{
$this->error='Not Authorized';
$this->error='NotAuthorized';
dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
return -1;
}
@ -936,6 +936,7 @@ class CommandeFournisseur extends CommonOrder
*/
function commande($user, $date, $methode, $comment='')
{
global $langs;
dol_syslog(get_class($this)."::commande");
$result = 0;
if ($user->rights->fournisseur->commande->commander)
@ -946,16 +947,24 @@ class CommandeFournisseur extends CommonOrder
dol_syslog(get_class($this)."::commande", LOG_DEBUG);
if ($this->db->query($sql))
{
$this->statut = 3;
$this->methode_commande_id = $methode;
$this->date_commande = $this->db->idate($date);
$result = 1;
$this->log($user, 3, $date, $comment);
}
else
{
$this->error = $this->db->lasterror();
$this->errors[] = $this->db->lasterror();
$result = -1;
}
}
else
{
$result = -1;
$this->error = $langs->trans('NotAuthorized');
$this->errors[] = $lanfs->trans('NotAuthorized');
dol_syslog(get_class($this)."::commande User not Authorized", LOG_ERR);
}
return $result ;
@ -1762,7 +1771,7 @@ class CommandeFournisseur extends CommonOrder
*/
function Livraison($user, $date, $type, $comment)
{
global $conf;
global $conf, $langs;
$result = 0;
$error = 0;
@ -1829,6 +1838,7 @@ class CommandeFournisseur extends CommonOrder
if ($resql)
{
$result = 0;
$this->statut = $statut;
$result=$this->log($user, $statut, $date, $comment);
$this->db->commit();
@ -1843,6 +1853,8 @@ class CommandeFournisseur extends CommonOrder
}
else
{
$this->error = $langs->trans('NotAuthorized');
$this->errors[] = $langs->trans('NotAuthorized');
dol_syslog(get_class($this)."::Livraison Not Authorized");
$result = -3;
}
@ -1992,6 +2004,7 @@ class CommandeFournisseur extends CommonOrder
if (! $error)
{
$this->statut = $status;
$this->db->commit();
return 1;
}
@ -2295,7 +2308,7 @@ class CommandeFournisseur extends CommonOrder
$clause = " WHERE";
$sql = "SELECT c.rowid, c.date_creation as datec, c.fk_statut,c.date_livraison as delivery_date";
$sql = "SELECT c.rowid, c.date_creation as datec, c.date_commande, c.fk_statut, c.date_livraison as delivery_date";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c";
if (!$user->rights->societe->client->voir && !$user->societe_id)
{
@ -2315,7 +2328,7 @@ class CommandeFournisseur extends CommonOrder
$response = new WorkboardResponse();
$response->warning_delay=$conf->commande->fournisseur->warning_delay/60/60/24;
$response->label=$langs->trans("SuppliersOrdersToProcess");
$response->url=DOL_URL_ROOT.'/fourn/commande/index.php';
$response->url=DOL_URL_ROOT.'/fourn/commande/list.php?statut=1,2,3';
$response->img=img_object($langs->trans("Orders"),"order");
while ($obj=$this->db->fetch_object($resql))
@ -2323,7 +2336,7 @@ class CommandeFournisseur extends CommonOrder
$response->nbtodo++;
$commandestatic->date_livraison = $this->db->jdate($obj->delivery_date);
$commandestatic->date_commande = $this->db->jdate($obj->datec);
$commandestatic->date_commande = $this->db->jdate($obj->date_commande);
$commandestatic->statut = $obj->fk_statut;
if ($commandestatic->hasDelay()) {
@ -2477,11 +2490,11 @@ class CommandeFournisseur extends CommonOrder
public function hasDelay()
{
global $conf;
$now = dol_now();
$date_to_test = empty($this->date_livraison) ? $this->date_commande : $this->date_livraison;
return ($this->statut != 3) && $date_to_test < ($now - $conf->commande->fournisseur->warning_delay);
return ($this->statut != 3) && $date_to_test && $date_to_test < ($now - $conf->commande->fournisseur->warning_delay);
}
}

View File

@ -704,15 +704,14 @@ if (empty($reshook))
if ($action == 'confirm_commande' && $confirm == 'yes' && $user->rights->fournisseur->commande->commander)
{
$result = $object->commande($user, $_REQUEST["datecommande"], $_REQUEST["methode"], $_REQUEST['comment']);
$result = $object->commande($user, $_REQUEST["datecommande"], $_REQUEST["methode"], $_REQUEST['comment']);
if ($result > 0)
{
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
exit;
}
$action = '';
}
else
{
setEventMessages($object->error, $object->errors, 'errors');
@ -767,15 +766,15 @@ if (empty($reshook))
{
$date_liv = dol_mktime(GETPOST('rehour'),GETPOST('remin'),GETPOST('resec'),GETPOST("remonth"),GETPOST("reday"),GETPOST("reyear"));
$result = $object->Livraison($user, $date_liv, GETPOST("type"), GETPOST("comment"));
$result = $object->Livraison($user, $date_liv, GETPOST("type"), GETPOST("comment"));
if ($result > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
exit;
}
setEventMessages($langs->trans("DeliveryStateSaved"), null);
$action = '';
}
else if($result == -3)
{
setEventMessage($langs->trans("NotAuthorized"), 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
else
{

View File

@ -100,8 +100,14 @@ if ($socid > 0)
{
$fourn = new Fournisseur($db);
$fourn->fetch($socid);
$title .= ' ('.$fourn->name.')';
$title .= ' - '.$fourn->name;
}
if (GETPOST('statut','alpha'))
{
if (GETPOST('statut','alpha') == '1,2,3') $title.=' - '.$langs->trans("StatusOrderToProcessShort");
else $title.=' - '.$langs->trans($commandestatic->statuts[GETPOST('statut','alpha')]);
}
llxHeader('',$title);
@ -157,9 +163,9 @@ if ($sall)
if ($socid) $sql.= " AND s.rowid = ".$socid;
//Required triple check because statut=0 means draft filter
if (GETPOST('statut', 'int') !== '')
if (GETPOST('statut', 'alpha') !== '')
{
$sql .= " AND cf.fk_statut IN (".GETPOST('statut').")";
$sql .= " AND cf.fk_statut IN (".GETPOST('statut', 'alpha').")";
}
if ($search_refsupp)
{
@ -245,7 +251,7 @@ if ($resql)
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="right">';
$formorder->selectSupplierOrderStatus($search_status,1,'search_status');
$formorder->selectSupplierOrderStatus((strstr($search_status, ',')?-1:$search_status),1,'search_status');
print '</td>';
print '<td class="liste_titre" align="right"><input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';

View File

@ -273,7 +273,7 @@ if ($resql)
if ($search_all)
{
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%">';

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);
$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 ";
$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";
@ -292,11 +292,11 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print $supplierstatic->getNomUrl(1,'supplier');
print '</td></tr>';
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>'.$langs->trans('Comments').'</td></tr>';
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 rowspan="3" valign="top">';
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))
{
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>';
}
else

View File

@ -231,7 +231,9 @@ if ($id > 0)
$title = $langs->trans("User");
dol_fiche_head($head, 'paidholidays', $title, 0, 'user');
dol_banner_tab($fuser,'id','',$user->rights->user->user->lire || $user->admin);
$linkback = '<a href="'.DOL_URL_ROOT.'/user/index.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($fuser,'id',$linkback,$user->rights->user->user->lire || $user->admin);
print '<div class="underbanner clearboth"></div>';

View File

@ -86,6 +86,10 @@ class DoliStorage implements TokenStorageInterface
*/
public function storeAccessToken($service, TokenInterface $token)
{
//var_dump("storeAccessToken");
//var_dump($token);
dol_syslog("storeAccessToken");
$serializedToken = serialize($token);
$this->tokens[$service] = $token;
@ -95,6 +99,10 @@ class DoliStorage implements TokenStorageInterface
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."oauth_token";
$sql.= " WHERE service='".$service."' AND entity=1";
$resql = $this->db->query($sql);
if (! $resql)
{
dol_print_error($this->db);
}
$obj = $this->db->fetch_array($resql);
if ($obj) {
// update
@ -108,7 +116,8 @@ class DoliStorage implements TokenStorageInterface
$sql.= " VALUES ('".$service."', '".$this->db->escape($serializedToken)."', 1)";
$resql = $this->db->query($sql);
}
//print $sql;
// allow chaining
return $this;
}
@ -122,8 +131,13 @@ class DoliStorage implements TokenStorageInterface
$sql = "SELECT token FROM ".MAIN_DB_PREFIX."oauth_token";
$sql.= " WHERE service='".$service."'";
$resql = $this->db->query($sql);
if (! $resql)
{
dol_print_error($this->db);
}
$result = $this->db->fetch_array($resql);
$token = unserialize($result[token]);
$token = unserialize($result['token']);
$this->tokens[$service] = $token;
return is_array($this->tokens)
@ -138,14 +152,15 @@ class DoliStorage implements TokenStorageInterface
{
// TODO
// get previously saved tokens
$tokens = $this->session->get($this->key);
//$tokens = $this->retrieveAccessToken($service);
if (is_array($tokens) && array_key_exists($service, $tokens)) {
unset($tokens[$service]);
//if (is_array($tokens) && array_key_exists($service, $tokens)) {
// unset($tokens[$service]);
// Replace the stored tokens array
$this->conf->set($this->key, $tokens);
}
$sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token";
$sql.= " WHERE service='".$service."'";
$resql = $this->db->query($sql);
//}
// allow chaining
return $this;
@ -182,8 +197,6 @@ class DoliStorage implements TokenStorageInterface
public function storeAuthorizationState($service, $state)
{
// TODO save or update
// get previously saved tokens
//$states = $this->conf->get($this->stateKey);
if (!is_array($states)) {
$states = array();
@ -192,10 +205,26 @@ class DoliStorage implements TokenStorageInterface
$states[$service] = $state;
$this->states[$service] = $state;
// save
$sql = "INSERT INTO ".MAIN_DB_PREFIX."oauth_state (service, state, entity)";
$sql.= " VALUES ('".$service."', '".$state."', 1)";
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."oauth_state";
$sql.= " WHERE service='".$service."' AND entity=1";
$resql = $this->db->query($sql);
if (! $resql)
{
dol_print_error($this->db);
}
$obj = $this->db->fetch_array($resql);
if ($obj) {
// update
$sql = "UPDATE ".MAIN_DB_PREFIX."oauth_state";
$sql.= " SET state='".$this->db->escape($state)."'";
$sql.= " WHERE rowid='".$obj['rowid']."'";
$resql = $this->db->query($sql);
} else {
// save
$sql = "INSERT INTO ".MAIN_DB_PREFIX."oauth_state (service, state, entity)";
$sql.= " VALUES ('".$service."', '".$state."', 1)";
$resql = $this->db->query($sql);
}
// allow chaining
return $this;

File diff suppressed because it is too large Load Diff

View File

@ -793,4 +793,9 @@ DELETE FROM llx_c_regions WHERE code_region=420 and fk_pays=4;
ALTER TABLE llx_c_paiement MODIFY COLUMN libelle varchar(62);
ALTER TABLE llx_societe_remise_except MODIFY COLUMN description text NOT NULL;
ALTER TABLE llx_societe_remise_except MODIFY COLUMN description text NOT NULL;
-- Fix bad data
update llx_opensurvey_sondage set format = 'D' where format = 'D+';
update llx_opensurvey_sondage set format = 'A' where format = 'A+';

View File

@ -19,6 +19,14 @@
-- -- 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
update llx_opensurvey_sondage set format = 'D' where format = 'D+';
update llx_opensurvey_sondage set format = 'A' where format = 'A+';
INSERT INTO llx_const (name, value, type, note, visible) values (__ENCRYPT('MAIN_DELAY_EXPENSEREPORTS_TO_PAY')__,__ENCRYPT('31')__,'chaine','Tolérance de retard avant alerte (en jours) sur les notes de frais impayées',0);
INSERT INTO llx_const (name, value, type, note, visible) values ('MAIN_SIZE_SHORTLISTE_LIMIT','4','chaine','Longueur maximum des listes courtes (fiche client)',0);
@ -48,16 +56,17 @@ create table llx_overwrite_trans
transvalue text
)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_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_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 extraparams varchar(255);
@ -68,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_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 DROP INDEX idx_ecm_directories;
@ -99,20 +108,20 @@ 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_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;
CREATE TABLE IF NOT EXISTS llx_c_hrm_function
(
rowid integer PRIMARY KEY,
pos tinyint DEFAULT 0 NOT NULL,
pos smallint DEFAULT 0 NOT NULL,
code varchar(16) NOT NULL,
label varchar(50),
c_level tinyint DEFAULT 0 NOT NULL,
active tinyint DEFAULT 1 NOT NULL
c_level smallint DEFAULT 0 NOT NULL,
active smallint DEFAULT 1 NOT NULL
)ENGINE=innodb;
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(1, 5, 'EXECBOARD', 'Executive board', 0, 1);
@ -128,10 +137,10 @@ INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES
CREATE TABLE IF NOT EXISTS llx_c_hrm_department
(
rowid integer PRIMARY KEY,
pos tinyint DEFAULT 0 NOT NULL,
pos smallint DEFAULT 0 NOT NULL,
code varchar(16) NOT NULL,
label varchar(50),
active tinyint DEFAULT 1 NOT NULL
active smallint DEFAULT 1 NOT NULL
)ENGINE=innodb;
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(1, 5,'MANAGEMENT', 'Management', 1);
@ -170,10 +179,11 @@ CREATE TABLE IF NOT EXISTS llx_establishment (
fk_user_mod integer NOT NULL,
datec datetime NOT NULL,
tms timestamp NOT NULL,
status tinyint DEFAULT 1
status smallint DEFAULT 1
) ENGINE=InnoDB;
ALTER TABLE llx_projet_task_time ADD COLUMN invoice_id integer DEFAULT NULL;
ALTER TABLE llx_projet_task_time ADD COLUMN invoice_line_id integer DEFAULT NULL;
@ -194,6 +204,7 @@ create table llx_stock_lotserial
) ENGINE=innodb;
-- Add budget tables
create table llx_budget
(
@ -216,7 +227,7 @@ create table llx_budget_lines
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
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,
datec datetime,
tms timestamp,
@ -225,21 +236,21 @@ create table llx_budget_lines
import_key integer
)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
-- 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);
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);
-- Add position field
ALTER TABLE llx_c_typent ADD COLUMN position integer NOT NULL DEFAULT 0;
ALTER TABLE llx_c_forme_juridique ADD COLUMN position integer NOT NULL DEFAULT 0;
ALTER TABLE llx_c_type_fees ADD COLUMN position integer NOT NULL DEFAULT 0;
-- NEW Level multiprice generator based on per cent variations over base price
CREATE TABLE llx_product_pricerules
(
@ -249,5 +260,50 @@ CREATE TABLE llx_product_pricerules
var_percent FLOAT NOT NULL, -- Price variation over based 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_pricerules ADD CONSTRAINT unique_level UNIQUE (level);
ALTER TABLE llx_product ADD COLUMN price_autogen smallint DEFAULT 0;
ALTER TABLE llx_product_pricerules ADD CONSTRAINT unique_level UNIQUE (level);
-- Delete deprecated fields
ALTER TABLE llx_opensurvey_sondage DROP COLUMN survey_link_visible;
ALTER TABLE llx_opensurvey_sondage DROP INDEX idx_id_sondage_admin;
ALTER TABLE llx_opensurvey_sondage DROP COLUMN id_sondage_admin;
ALTER TABLE llx_opensurvey_sondage DROP COLUMN canedit;
ALTER TABLE llx_opensurvey_sondage DROP COLUMN origin;
DROP TABLE llx_opensurvey_sujet_studs;
CREATE TABLE llx_opensurvey_formquestions (
rowid INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY,
id_sondage VARCHAR(16),
question TEXT,
available_answers TEXT -- List of available answers
) ENGINE=InnoDB;
CREATE TABLE llx_opensurvey_user_formanswers (
fk_user_survey INTEGER NOT NULL,
fk_question INTEGER NOT NULL,
reponses TEXT
) 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,
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,
note text,
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
-- 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);
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);

View File

@ -18,13 +18,13 @@
create table llx_budget_lines
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_budget integer NOT NULL,
fk_project integer NOT NULL,
amount double(24,8) NOT NULL,
datec datetime,
tms timestamp,
fk_user_creat integer,
fk_user_modif integer,
import_key integer
rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_budget 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,
datec datetime,
tms timestamp,
fk_user_creat integer,
fk_user_modif integer,
import_key integer
)ENGINE=innodb;

View File

@ -14,6 +14,11 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Change are done into list pages to use the new code to manage
-- selection by users of fields. Once all changes are done with new
-- code, we will be able to use this table to store the content of
-- the $arrayfields table.
-- Table not used / not required for the moment.
-- ========================================================================
create table llx_c_field_list

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

@ -0,0 +1,24 @@
-- ============================================================================
-- Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- 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_opensurvey_formquestions (
rowid INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY,
id_sondage VARCHAR(16),
question TEXT,
available_answers TEXT -- List of available answers
) ENGINE=InnoDB;

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