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

This commit is contained in:
eldy 2011-10-07 01:40:52 +02:00
commit 35996b6cf1
79 changed files with 4887 additions and 3736 deletions

View File

@ -19,14 +19,18 @@ For users:
- New: Can build PDF in USLetter format or canada format.
- New: Can export into Excel 2007 format.
- New: Add hidden option CASHDESK_FORCE_STOCK_ON_BILL
- New: Can search on part of barcode into POS module.
For developers:
- New: Add webservice to get or create a prodcut or service.
- New: Log module outputs can be setup with "or" rule (not only "xor").
- New: Add FirePHP output for logging module.
- Qual: Data structure for supplier prices is simpler.
- Qual: Removed no more used external libraries.
- Qual: Cleaned a lot of dead code.
- Qual: Parent templates classes were moved as abstract classes.
- Qual: Add more "hooks".
- Qual: Add "canvas" feature to overwrite page of thirdparty, contact, product with yours.
- More OOP (usage of "abstract", "static", ...), unifformize constructors.
- Qual: More OOP (usage of "abstract", "static", ...), uniformize constructors.
***** ChangeLog for 3.1 compared to 3.0 *****

116
README.md Normal file
View File

@ -0,0 +1,116 @@
# DOLIBARR ERP/CRM
Dolibarr ERP/CRM is a modern software to manage your company or foundation activity (contacts, suppliers, invoices, orders, stocks, agenda, ...).It's an opensource software (wrote with PHP language) designed for small and medium companies, foundation and freelances. You can freely install, use and distribute it as a standalone application or as a web application to use it from every internet access and media.
## INSTALL
If you have no technical knowledge, use Windows and you are looking for an autoinstaller to install Dolibarr ERP/CRM in few clicks, you must download DoliWamp (the all-in-one package of Dolibarr for Windows).
You can download it at: [Official Website] (http://www.dolibarr.org/downloads/cat_view/62-stable-versions)
If you already have installed a Web server and a Mysql database, you can install this version like this:
- Copy directory "dolibarr" and all its files inside your web server root, or copy directory anywhere and set up your web server to use "dolibarr/htdocs" as root for a new web server virtual host (second choice need to be server administrator).
- Create an empty file "htdocs/conf/conf.php" and set permissions for your web server user (write permissions will be removed once install is finished).
- From your browser, call the dolibarr "install/" page.
Url depends on choice made on first step:
http://localhost/dolibarr/htdocs/install/
or
http://yourdolibarrvirtualhost/install/
- Follow instructions provided by installer...
## UPGRADE
To upgrade Dolibarr from an old version to this one:
- Overwrite all old files inside old 'dolibarr' directory by files provided into new version package.
- If you came from version x.y.z to x.y.w (only third number differ), there is no need to run any migrate process.
- If you came from a beta version or from any version x.y.z to any other where x or y number differs, you must call the Dolibarr "install/" page in your browser (this should be done automatically at first dolibarr access).
This URL should looks like:
http://localhost/dolibarr/htdocs/install/
or
http://yourdolibarrhost/install/index.php
Then choose the "update" option according to your case.
Note: Migrate process can be ran safely several times.
## WHAT'S NEW
See ChangeLog file.
## WHAT DOLIBARR CAN DO
### Main modules/features:
- Products and services catalog
- Customers, Prospects or Suppliers directory
- Address book
- Stock management
- Bank accounts management
- Orders management with PDF export
- Commercial proposals management with PDF export
- Contracts management
- Invoices management with PDF export
- Payments management
- Standing orders management
- Shipping management
- ECM (Electronic Content Management)
- EMailings
- Agenda with ical,vcal export for third tools integration
- Management of foundation members
- Donation management
### Other modules:
- Bookmarks management
- Can reports Dolibarr events inside Webcalendar or Phenix
- Data export tools
- LDAP connectivity
- Third parties or products categories
- ClickToDial phone numbers
- RSS
### Miscellanous:
- Mutli-user, with several permissions levels for each feature.
- Serveral menu managers (can be used by internal users, as a back-office, with a particular menu, or by external users, as a front-office, with another menu and permissions).
- Very user friendly and easy to use.
- Optional WYSIWYG forms, optional Ajax forms.
- Several skins.
- Code is highly customizable (a lot of use of modules and submodules).
- Works with Mysql 3.1 or higher, experimental support for PostgreSql.
- Works with PHP 4.3 or higher.
- An easy to understand and maintain code (PHP with no heavy frameworks).
- A trigger architecture to allow you to make Dolibarr business events run PHP code to update your own information system.
- "NPR VAT Rate" (French particularity for managing VAT in DOM-TOM called "Non Perçue Récupérable").
## WHAT DOLIBARR CAN'T DO YET (TODO LIST)
This is features that Dolibarr does not support completely yet:
- Accountancy.
- Dolibarr can manage only one currency.
- Dolibarr does not support the double Canadian Tax.
- Dolibarr does not make coffee (not yet).
- Stock management with option increase/decrease on invoice works on warehouse number one only (no way to choose warehouse).
- Stock management with option increase/decrease on orders works on warehouse number one only (no way to choose warehouse).

View File

@ -262,6 +262,7 @@ if ($nboftargetok) {
$ret=`rm -f $BUILDROOT/$PROJECT/pom.xml`;
$ret=`rm -f $BUILDROOT/$PROJECT/default.properties`;
$ret=`rm -f $BUILDROOT/$PROJECT/git2cvs.sh`;
$ret=`rm -f $BUILDROOT/$PROJECT/README.md`;
$ret=`rm -fr $BUILDROOT/$PROJECT/build/html`;
$ret=`rm -f $BUILDROOT/$PROJECT/build/DoliW*-*`;

View File

@ -495,7 +495,7 @@ if ($rowid)
// Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
{
print '<tr><td>'.$langs->trans("Login").'</td><td class="valeur">'.$adh->login.'&nbsp;</td>';
print '<tr><td>'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$adh->login.'&nbsp;</td>';
print $showphoto; $showphoto='';
print '</tr>';
}

View File

@ -1560,11 +1560,9 @@ class Adherent extends CommonObject
//curl_setopt($ch, CURLOPT_POST, 0);
//curl_setopt($ch, CURLOPT_POSTFIELDS, "a=3&b=5");
//--- Start buffering
//ob_start();
$result=curl_exec($ch);
dol_syslog($result);
//--- End buffering and clean output
//ob_end_clean();
if (curl_error($ch) > 0)
{
// error
@ -1632,11 +1630,9 @@ class Adherent extends CommonObject
//curl_setopt($ch, CURLOPT_POST, 0);
//curl_setopt($ch, CURLOPT_POSTFIELDS, "a=3&b=5");
//--- Start buffering
//ob_start();
$result=curl_exec($ch);
dol_syslog($result);
//--- End buffering and clean output
//ob_end_clean();
$rescode=curl_error($ch);
if ($rescode > 0)
{

View File

@ -151,7 +151,7 @@ if ($id > 0)
// Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
{
print '<tr><td>'.$langs->trans("Login").'</td><td class="valeur">'.$member->login.'&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$member->login.'&nbsp;</td></tr>';
}
// Morphy

View File

@ -99,7 +99,7 @@ if ($id)
// Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
{
print '<tr><td>'.$langs->trans("Login").'</td><td class="valeur">'.$adh->login.'&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$adh->login.'&nbsp;</td></tr>';
}
// Morphy

View File

@ -3,7 +3,7 @@
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
*
* This program is free software; you can redistribute it and/or modify
@ -41,8 +41,8 @@ $acts[0] = "activate";
$acts[1] = "disable";
//$actl[0] = $langs->trans("Activate");
//$actl[1] = $langs->trans("Disable");
$actl[0] = img_picto($langs->trans("Disabled"),'off');
$actl[1] = img_picto($langs->trans("Activated"),'on');
$actl[0] = img_picto($langs->trans("Disabled"),'switch_off');
$actl[1] = img_picto($langs->trans("Activated"),'switch_on');
$listoffset=GETPOST('listoffset');
$listlimit=GETPOST('listlimit')>0?GETPOST('listlimit'):1000;
@ -122,7 +122,7 @@ $tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.d
$tabsql[8] = "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_typent";
//$tabsql[9] = "SELECT code, code_iso, label as libelle, symbole, active FROM ".MAIN_DB_PREFIX."c_currencies";
$tabsql[9] = "SELECT code, code_iso, label as libelle, active FROM ".MAIN_DB_PREFIX."c_currencies";
$tabsql[10]= "SELECT t.rowid, t.taux, t.localtax1, t.localtax2, p.libelle as pays, p.code as pays_code, t.fk_pays as pays_id, t.recuperableonly, t.note, t.active, t.accountancy_code FROM ".MAIN_DB_PREFIX."c_tva as t, llx_c_pays as p WHERE t.fk_pays=p.rowid";
$tabsql[10]= "SELECT t.rowid, t.taux, t.localtax1, t.localtax2, p.libelle as pays, p.code as pays_code, t.fk_pays as pays_id, t.recuperableonly, t.note, t.active, t.accountancy_code FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p WHERE t.fk_pays=p.rowid";
$tabsql[11]= "SELECT t.rowid as rowid, element, source, code, libelle, active FROM ".MAIN_DB_PREFIX."c_type_contact AS t";
$tabsql[12]= "SELECT c.rowid as rowid, code, sortorder, c.libelle, c.libelle_facture, nbjour, fdm, decalage, active FROM ".MAIN_DB_PREFIX.'c_payment_term AS c';
$tabsql[13]= "SELECT id as rowid, code, c.libelle, type, active FROM ".MAIN_DB_PREFIX."c_paiement AS c";
@ -780,12 +780,68 @@ if ($_GET["id"])
$valuetoshow=price($valuetoshow);
}
else if ($fieldlist[$field]=='libelle_facture') {
$langs->load("bills");
$key=$langs->trans("PaymentCondition".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "PaymentCondition".strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
$valuetoshow=nl2br($valuetoshow);
}
else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]=='llx_c_pays') {
else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_pays') {
$key=$langs->trans("Country".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
}
else if ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_availability') {
$langs->load("propal");
$key=$langs->trans("AvailabilityType".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
}
else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_actioncomm') {
$key=$langs->trans("Action".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
}
else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_currencies') {
$key=$langs->trans("Currency".strtoupper($obj->code_iso));
$valuetoshow=($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso))?$key:$obj->$fieldlist[$field];
}
else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_typent') {
$key=$langs->trans(strtoupper($obj->code));
$valuetoshow=($key != strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
}
else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_prospectlevel') {
$key=$langs->trans(strtoupper($obj->code));
$valuetoshow=($key != strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
}
else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_civilite') {
$key=$langs->trans("Civility".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
}
else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_type_contact') {
$key=$langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
}
else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_payment_term') {
$langs->load("bills");
$key=$langs->trans("PaymentConditionShort".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
}
else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_paiement') {
$langs->load("bills");
$key=$langs->trans("PaymentType".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "PaymentType".strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
}
else if ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_input_reason') {
$key=$langs->trans("DemandReasonType".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "DemandReasonType".strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
}
else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_input_method') {
$langs->load("orders");
$key=$langs->trans($obj->code);
$valuetoshow=($obj->code && $key != $obj->code)?$key:$obj->$fieldlist[$field];
}
else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_shipment_mode') {
$langs->load("sendings");
$key=$langs->trans("SendingMethod".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "SendingMethod".strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
}
else if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='pays_id') {
$showfield=0;
}

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
@ -20,7 +20,7 @@
/**
* \file htdocs/admin/syslog.php
* \ingroup syslog
* \brief Setup page for syslog module
* \brief Setup page for logs module
*/
require("../main.inc.php");
@ -31,13 +31,91 @@ if (!$user->admin) accessforbidden();
$langs->load("admin");
$langs->load("other");
$error=0; $mesg='';
$action = GETPOST("action");
$syslog_file_on=(defined('SYSLOG_FILE_ON') && constant('SYSLOG_FILE_ON'))?1:0;
$syslog_syslog_on=(defined('SYSLOG_SYSLOG_ON') && constant('SYSLOG_SYSLOG_ON'))?1:0;
$syslog_firephp_on=(defined('SYSLOG_FIREPHP_ON') && constant('SYSLOG_FIREPHP_ON'))?1:0;
/*
* Actions
*/
if ($action== 'setlevel')
// Set modes
if ($action == 'set')
{
$db->begin();
$res = dolibarr_del_const($db,"SYSLOG_FILE_ON",0);
$res = dolibarr_del_const($db,"SYSLOG_SYSLOG_ON",0);
$res = dolibarr_del_const($db,"SYSLOG_FIREPHP_ON",0);
if (! $error && GETPOST("filename"))
{
$filename=GETPOST("filename");
$filelog=GETPOST("filename");
$filelog=preg_replace('/DOL_DATA_ROOT/i',DOL_DATA_ROOT,$filelog);
$file=@fopen($filelog,"a+");
if ($file)
{
fclose($file);
dol_syslog("admin/syslog: file ".$filename);
$res = dolibarr_set_const($db,"SYSLOG_FILE",$filename,'chaine',0,'',0);
if (! $res > 0) $error++;
$syslog_file_on=GETPOST('SYSLOG_FILE_ON');
if (! $error) $res = dolibarr_set_const($db,"SYSLOG_FILE_ON",$syslog_file_on,'chaine',0,'',0);
}
else
{
$error++;
$mesg = "<font class=\"error\">".$langs->trans("ErrorFailedToOpenFile",$filename)."</font>";
}
}
if (! $error && GETPOST("facility"))
{
$facility=GETPOST("facility");
if (defined($_POST["facility"]))
{
// Only LOG_USER supported on Windows
if (! empty($_SERVER["WINDIR"])) $facility='LOG_USER';
dol_syslog("admin/syslog: facility ".$facility);
$res = dolibarr_set_const($db,"SYSLOG_FACILITY",$facility,'chaine',0,'',0);
if (! $res > 0) $error++;
$syslog_syslog_on=GETPOST('SYSLOG_SYSLOG_ON');
if (! $error) $res = dolibarr_set_const($db,"SYSLOG_SYSLOG_ON",$syslog_syslog_on,'chaine',0,'',0);
}
else
{
$error++;
$mesg = "<font class=\"error\">".$langs->trans("ErrorUnknownSyslogConstant",$facility)."</font>";
}
}
if (! $error && isset($_POST['SYSLOG_FIREPHP_ON'])) // If firephp no available, post is not present
{
$syslog_firephp_on=GETPOST('SYSLOG_FIREPHP_ON');
if (! $error) $res = dolibarr_set_const($db,"SYSLOG_FIREPHP_ON",$syslog_firephp_on,'chaine',0,'',0);
}
if (! $error)
{
$db->commit();
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$db->rollback();
if (empty($mesg)) $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
}
// Set level
if ($action == 'setlevel')
{
$level = GETPOST("level");
$res = dolibarr_set_const($db,"SYSLOG_LEVEL",$level,'chaine',0,'',0);
@ -54,75 +132,6 @@ if ($action== 'setlevel')
}
}
if ($action == 'set')
{
$optionlogoutput=GETPOST("optionlogoutput");
$facility=GETPOST("facility");
if ($optionlogoutput == "syslog")
{
if (defined($_POST["facility"]))
{
$db->begin;
// Only LOG_USER supported on Windows
if (! empty($_SERVER["WINDIR"])) $facility='LOG_USER';
$res = dolibarr_del_const($db,"SYSLOG_FILE",0);
if (! $res > 0) $error++;
$res = dolibarr_set_const($db,"SYSLOG_FACILITY",$facility,'chaine',0,'',0);
if (! $res > 0) $error++;
dol_syslog("admin/syslog: facility ".$facility);
if (! $error)
{
$db->commit();
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$db->rollback();
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("ErrorUnknownSyslogConstant",$facility)."</font>";
}
}
if ($optionlogoutput == "file")
{
$filename=GETPOST("filename");
$filelog=GETPOST("filename");
$filelog=preg_replace('/DOL_DATA_ROOT/i',DOL_DATA_ROOT,$filelog);
$file=fopen($filelog,"a+");
if ($file)
{
fclose($file);
$db->begin;
$res = dolibarr_del_const($db,"SYSLOG_FACILITY",0);
if (! $res > 0) $error++;
$res = dolibarr_set_const($db,"SYSLOG_FILE",$filename,'chaine',0,'',0);
if (! $res > 0) $error++;
dol_syslog("admin/syslog: file ".$filename);
if (! $res > 0) $error++;
if (! $error)
{
$db->commit();
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$db->rollback();
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("ErrorFailedToOpenFile",$filename)."</font>";
}
}
}
/*
* View
*/
@ -162,22 +171,49 @@ print '<td>'.$langs->trans("Type").'</td><td>'.$langs->trans("Value").'</td>';
print '<td align="right" colspan="2"><input type="submit" class="button" '.$option.' value="'.$langs->trans("Modify").'"></td>';
print "</tr>\n";
$var=true;
$var=!$var;
print '<tr '.$bc[$var].'><td width="140"><input '.$bc[$var].' type="radio" name="optionlogoutput" '.$option.' value="syslog" '.($syslogfacility?" checked":"").'> '.$langs->trans("SyslogSyslog").'</td>';
print '<td colspan="3">'.$langs->trans("SyslogFacility").': <input type="text" class="flat" name="facility" '.$option.' value="'.$defaultsyslogfacility.'">';
print ' '.img_info('Only LOG_USER supported on Windows');
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td width="140"><input '.$bc[$var].' type="radio" name="optionlogoutput" '.$option.' value="file" '.($syslogfile?" checked":"").'> '.$langs->trans("SyslogSimpleFile").'</td>';
print '<td width="250" nowrap>'.$langs->trans("SyslogFilename").': <input type="text" class="flat" name="filename" '.$option.' size="60" value="'.$defaultsyslogfile.'">';
print '<tr '.$bc[$var].'><td width="140"><input '.$bc[$var].' type="checkbox" name="SYSLOG_FILE_ON" '.$option.' value="1" '.($syslog_file_on?' checked="checked"':'').'> '.$langs->trans("SyslogSimpleFile").'</td>';
print '<td width="250" nowrap="nowrap">'.$langs->trans("SyslogFilename").': <input type="text" class="flat" name="filename" '.$option.' size="60" value="'.$defaultsyslogfile.'">';
print '</td>';
print "<td align=\"left\">".$html->textwithpicto('',$langs->trans("YouCanUseDOL_DATA_ROOT"));
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td width="140"><input '.$bc[$var].' type="checkbox" name="SYSLOG_SYSLOG_ON" '.$option.' value="1" '.($syslog_syslog_on?' checked="checked"':'').'> '.$langs->trans("SyslogSyslog").'</td>';
print '<td width="250" nowrap="nowrap">'.$langs->trans("SyslogFacility").': <input type="text" class="flat" name="facility" '.$option.' value="'.$defaultsyslogfacility.'">';
print '</td>';
print "<td align=\"left\">".$html->textwithpicto('','Only LOG_USER supported on Windows');
print '</td></tr>';
try
{
set_include_path('/usr/share/php/');
@require_once('FirePHPCore/FirePHP.class.php');
restore_include_path();
$var=!$var;
print '<tr '.$bc[$var].'><td width="140"><input '.$bc[$var].' type="checkbox" name="SYSLOG_FIREPHP_ON" '.$option.' value="1" ';
if (! class_exists('FirePHP')) print ' disabled="disabled"';
else print ($syslog_firephp_on?' checked="checked"':"");
print '> '.$langs->trans("FirePHP").'</td>';
print '<td width="250" nowrap="nowrap">';
print '</td>';
print "<td align=\"left\">".$html->textwithpicto('','FirePHP must be installed onto PHP and FirePHP plugin for Firefox must also be installed');
print '</td></tr>';
}
catch(Exception $e)
{
// Do nothing
print '<!-- FirePHP no available into PHP -->'."\n";
}
print "</table>\n";
print "</form>\n";
print '<br>';
print_titre($langs->trans("SyslogLevel"));
// Level
print '<form action="syslog.php" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';

View File

@ -29,8 +29,7 @@ $langs->load("admin");
$langs->load("user");
$langs->load("install");
if (!$user->admin)
accessforbidden();
if (! $user->admin) accessforbidden();
/*
@ -123,6 +122,8 @@ print '<br>';
//print "<br>\n";
print info_admin($langs->trans("SystemInfoDesc")).'<br>';
llxFooter();
$db->close();
?>

View File

@ -25,8 +25,9 @@ include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php');
$langs->load("admin");
if (! $user->admin)
accessforbidden();
$action=GETPOST('action');
if (! $user->admin) accessforbidden();
if ($_GET["msg"]) $message='<div class="error">'.$_GET["msg"].'</div>';

View File

@ -35,6 +35,7 @@ if ( $_SESSION['uid'] <= 0 )
$langs->load("cashdesk");
/*
* View
*/
@ -47,29 +48,6 @@ $arrayofcss=array('/cashdesk/css/style.css');
top_htmlhead($head,$langs->trans("CashDesk"),0,0,$arrayofjs,$arrayofcss);
/*
print '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
print '<html>'."\n";
print '<head>'."\n";
print '<title>'.$langs->trans("CashDesk").'</title>'."\n";
print '<meta name="robots" content="none" />'."\n";
print '<meta name="author" content="Jeremie Ollivier - jeremie.o@laposte.net" />'."\n";
print '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n";
print '<meta http-equiv="Content-Style-Type" content="text/css" />'."\n";
print '<link href="'.DOL_URL_ROOT.'/cashdesk/css/style.css" rel="stylesheet" type="text/css" media="screen" />'."\n";
print '<!-- Import des fichiers necessaires a JsCalendar -->'."\n";
print '<style type="text/css">'."\n";
print '@import url(include/jscalendar/calendar-blue.css);'."\n";
print '</style>'."\n";
print '<script type="text/javascript" src="include/jscalendar/calendar.js"></script>'."\n";
print '<script type="text/javascript" src="include/jscalendar/lang/calendar-fr.js"></script>'."\n";
print '<script type="text/javascript" src="include/jscalendar/calendar-setup.js"></script>'."\n";
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/lib/lib_head.js"></script>'."\n";
print '</head>'."\n";
*/
print '<body>'."\n";
if (!empty($error))

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* Copyright (C) 2008-2009 Laurent Destailleur <eldy@uers.sourceforge.net>
* Copyright (C) 2008-2011 Laurent Destailleur <eldy@uers.sourceforge.net>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
@ -36,9 +36,9 @@ if ( $_GET['filtre'] ) {
$sql.= " WHERE p.tosell = 1";
if(!$conf->global->CASHDESK_SERVICES) $sql.= " AND p.fk_product_type = 0";
$sql.= " AND (p.ref LIKE '%".$_GET['filtre']."%' OR p.label LIKE '%".$_GET['filtre']."%' ";
if ($conf->barcode->enabled) $sql.= " OR p.barcode='".$_GET['filtre']."')";
if ($conf->barcode->enabled) $sql.= " OR p.barcode LIKE '%".$_GET['filtre']."%')";
else $sql.= ")";
$sql.= " ORDER BY label";
dol_syslog("facturation.php sql=".$sql);

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Brice Davoleau <brice.davoleau@gmail.com>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
@ -32,50 +32,47 @@ require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php");
$langs->load("categories");
$langs->load("products");
$socid=GETPOST('socid');
$id=GETPOST('id');
$ref=GETPOST('ref');
$mesg=GETPOST('mesg');
$socid = GETPOST('socid');
$id = GETPOST('id');
$ref = GETPOST('ref');
$type = GETPOST('type');
$mesg = GETPOST('mesg');
$dbtablename = '';
// For categories on third parties
if (! empty($_REQUEST["socid"])) {
$_REQUEST["id"]=$_REQUEST["socid"];
$id=$socid;
}
if (! isset($_REQUEST["type"])) $_REQUEST["type"]=0;
if ($_REQUEST["type"] == 1) $socid=$id;
if ($_REQUEST["type"] == 2) $socid=$id;
if (! empty($socid)) $id = $socid;
if (! isset($type)) $type = 0;
if ($type == 1 || $type == 2) $socid = $id;
if ($_REQUEST["id"] || $_REQUEST["ref"])
if ($id || $ref)
{
if ($_REQUEST["type"] == 0) {
$type = 'product';
if ($type == 0) {
$elementtype = 'product';
$objecttype = 'produit|service&categorie';
$objectid = isset($_REQUEST["id"])?$_REQUEST["id"]:(isset($_REQUEST["ref"])?$_REQUEST["ref"]:'');
$objectid = isset($id)?$id:(isset($ref)?$ref:'');
$dbtablename = 'product';
$fieldid = isset($_REQUEST["ref"])?'ref':'rowid';
$fieldid = isset($ref)?'ref':'rowid';
}
if ($_REQUEST["type"] == 1) {
$type = 'fournisseur';
if ($type == 1) {
$elementtype = 'fournisseur';
$objecttype = 'societe&categorie';
$objectid = isset($_REQUEST["id"])?$_REQUEST["id"]:(isset($_REQUEST["socid"])?$_REQUEST["socid"]:'');
$objectid = isset($id)?$id:(isset($socid)?$socid:'');
$fieldid = 'rowid';
}
if ($_REQUEST["type"] == 2) {
$type = 'societe';
if ($type == 2) {
$elementtype = 'societe';
$objecttype = 'societe&categorie';
$objectid = isset($_REQUEST["id"])?$_REQUEST["id"]:(isset($_REQUEST["socid"])?$_REQUEST["socid"]:'');
$objectid = isset($id)?$id:(isset($socid)?$socid:'');
$fieldid = 'rowid';
}
if ($_REQUEST["type"] == 3) {
$type = 'member';
if ($type == 3) {
$elementtype = 'member';
$objecttype = 'adherent&categorie';
$objectid = isset($_REQUEST["id"])?$_REQUEST["id"]:(isset($_REQUEST["ref"])?$_REQUEST["ref"]:'');
$objectid = isset($id)?$id:(isset($ref)?$ref:'');
$dbtablename = 'adherent';
$fieldid = isset($_REQUEST["ref"])?'ref':'rowid';
$fieldid = isset($ref)?'ref':'rowid';
}
}
@ -91,25 +88,24 @@ $result = restrictedArea($user,$objecttype,$objectid,$dbtablename,'','',$fieldid
//Suppression d'un objet d'une categorie
if ($_REQUEST["removecat"])
{
if ($_REQUEST["type"]==0 && ($user->rights->produit->creer || $user->rights->service->creer))
if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer))
{
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
$object = new Product($db);
if ($_REQUEST["ref"]) $result = $object->fetch('',$_REQUEST["ref"]);
if ($_REQUEST["id"]) $result = $object->fetch($_REQUEST["id"]);
$type = 'product';
$result = $object->fetch($id, $ref);
$elementtype = 'product';
}
if ($_REQUEST["type"]==1 && $user->rights->societe->creer)
if ($type==1 && $user->rights->societe->creer)
{
$object = new Societe($db);
$result = $object->fetch($objectid);
}
if ($_REQUEST["type"]==2 && $user->rights->societe->creer)
if ($type==2 && $user->rights->societe->creer)
{
$object = new Societe($db);
$result = $object->fetch($objectid);
}
if ($_REQUEST["type"] == 3 && $user->rights->adherent->creer)
if ($type == 3 && $user->rights->adherent->creer)
{
require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
$object = new Adherent($db);
@ -118,46 +114,42 @@ if ($_REQUEST["removecat"])
$cat = new Categorie($db);
$result=$cat->fetch($_REQUEST["removecat"]);
$result=$cat->del_type($object,$type);
$result=$cat->del_type($object,$elementtype);
}
// Add object into a category
if (isset($_REQUEST["catMere"]) && $_REQUEST["catMere"]>=0)
{
$_GET["id"]=$_REQUEST["id"];
$_GET["type"]=$_REQUEST["type"];
if ($_REQUEST["type"]==0 && ($user->rights->produit->creer || $user->rights->service->creer))
if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer))
{
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
$object = new Product($db);
if ($_REQUEST["ref"]) $result = $object->fetch('',$_REQUEST["ref"]);
if ($_REQUEST["id"]) $result = $object->fetch($_REQUEST["id"]);
$type = 'product';
$result = $object->fetch($id, $ref);
$elementtype = 'product';
}
if ($_REQUEST["type"]==1 && $user->rights->societe->creer)
if ($type==1 && $user->rights->societe->creer)
{
$object = new Societe($db);
$result = $object->fetch($objectid);
$type = 'fournisseur';
$elementtype = 'fournisseur';
}
if ($_REQUEST["type"]==2 && $user->rights->societe->creer)
if ($type==2 && $user->rights->societe->creer)
{
$object = new Societe($db);
$result = $object->fetch($objectid);
$type = 'societe';
$elementtype = 'societe';
}
if ($_REQUEST["type"]==3 && $user->rights->adherent->creer)
if ($type==3 && $user->rights->adherent->creer)
{
require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
$object = new Adherent($db);
$result = $object->fetch($objectid);
$type = 'member';
$elementtype = 'member';
}
$cat = new Categorie($db);
$result=$cat->fetch($_REQUEST["catMere"]);
$result=$cat->add_type($object,$type);
$result=$cat->add_type($object,$elementtype);
if ($result >= 0)
{
$mesg='<div class="ok">'.$langs->trans("WasAddedSuccessfully",$cat->label).'</div>';
@ -202,7 +194,7 @@ if ($socid)
print '<table class="border" width="100%">';
print '<tr><td width="25%">'.$langs->trans("ThirdPartyName").'</td><td colspan="3">';
print $html->showrefnav($soc,'socid','',($user->societe_id?0:1),'rowid','nom');
print $html->showrefnav($soc,'socid','',($user->societe_id?0:1),'rowid','nom','','&type='.$type);
print '</td></tr>';
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
@ -234,14 +226,15 @@ if ($socid)
}
// Address
print "<tr><td valign=\"top\">".$langs->trans('Address')."</td><td colspan=\"3\">".nl2br($soc->address)."</td></tr>";
print '<tr><td valign="top">'.$langs->trans('Address').'</td><td colspan="3">'.nl2br($soc->address).'</td></tr>';
// Zip / Town
print '<tr><td width="25%">'.$langs->trans('Zip').'</td><td width="25%">'.$soc->cp."</td>";
print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$soc->ville."</td></tr>";
// Country
if ($soc->pays) {
if ($soc->pays)
{
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
$img=picto_from_langcode($soc->pays_code);
print ($img?$img.' ':'');
@ -282,9 +275,9 @@ if ($socid)
if ($soc->fournisseur) formCategory($db,$soc,1);
}
else if ($_GET["id"] || $_GET["ref"])
else if ($id || $ref)
{
if ($_GET["type"] == 0)
if ($type == 0)
{
$langs->load("products");
@ -296,8 +289,7 @@ else if ($_GET["id"] || $_GET["ref"])
// Produit
$product = new Product($db);
if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]);
if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
$result = $product->fetch($id, $ref);
llxHeader("","",$langs->trans("CardProduct".$product->type));
@ -340,7 +332,7 @@ else if ($_GET["id"] || $_GET["ref"])
formCategory($db,$product,0);
}
if ($_GET["type"] == 3)
if ($type == 3)
{
$langs->load("members");
@ -353,8 +345,7 @@ else if ($_GET["id"] || $_GET["ref"])
// Produit
$member = new Adherent($db);
if ($_GET["ref"]) $result = $member->fetch('',$_GET["ref"]);
if ($_GET["id"]) $result = $member->fetch($_GET["id"]);
$result = $member->fetch($id, $ref);
$membert = new AdherentType($db);
$membert->fetch($member->typeid);
@ -382,7 +373,7 @@ else if ($_GET["id"] || $_GET["ref"])
// Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
{
print '<tr><td>'.$langs->trans("Login").'</td><td class="valeur">'.$member->login.'&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$member->login.'&nbsp;</td></tr>';
}
// Morphy

View File

@ -495,24 +495,31 @@ class Propal extends CommonObject
$staticline=new PropaleLigne($this->db);
$staticline->fetch($rowid);
$this->line->oldline = $staticline;
$this->line->rowid=$rowid;
$this->line->desc=$desc;
$this->line->qty=$qty;
$this->line->tva_tx=$txtva;
$this->line->localtax1_tx=$txlocaltax1;
$this->line->localtax2_tx=$txlocaltax2;
$this->line->remise_percent=$remise_percent;
$this->line->subprice=$pu;
$this->line->info_bits=$info_bits;
$this->line->total_ht=$total_ht;
$this->line->total_tva=$total_tva;
$this->line->total_localtax1=$total_localtax1;
$this->line->total_localtax2=$total_localtax2;
$this->line->total_ttc=$total_ttc;
$this->line->special_code=$special_code;
$this->line->fk_parent_line=$fk_parent_line;
$this->line->skip_update_total=$skip_update_total;
// Reorder if fk_parent_line change
if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line)
{
$rangmax = $this->line_max($fk_parent_line);
$this->line->rang = $rangmax + 1;
}
$this->line->rowid = $rowid;
$this->line->desc = $desc;
$this->line->qty = $qty;
$this->line->tva_tx = $txtva;
$this->line->localtax1_tx = $txlocaltax1;
$this->line->localtax2_tx = $txlocaltax2;
$this->line->remise_percent = $remise_percent;
$this->line->subprice = $pu;
$this->line->info_bits = $info_bits;
$this->line->total_ht = $total_ht;
$this->line->total_tva = $total_tva;
$this->line->total_localtax1 = $total_localtax1;
$this->line->total_localtax2 = $total_localtax2;
$this->line->total_ttc = $total_ttc;
$this->line->special_code = $special_code;
$this->line->fk_parent_line = $fk_parent_line;
$this->line->skip_update_total = $skip_update_total;
// TODO deprecated
$this->line->price=$price;
@ -521,6 +528,9 @@ class Propal extends CommonObject
$result=$this->line->update();
if ($result > 0)
{
// Reorder if child line
if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
$this->update_price(1);
$this->fk_propal = $this->id;
@ -2646,8 +2656,9 @@ class PropaleLigne
}
/**
* \brief Mise a jour de l'objet ligne de propale en base
* \return int <0 si ko, >0 si ok
* Mise a jour de l'objet ligne de propale en base
*
* @return int <0 si ko, >0 si ok
*/
function update($notrigger=0)
{
@ -2692,9 +2703,10 @@ class PropaleLigne
$sql.= " , info_bits=".$this->info_bits;
if (strlen($this->special_code)) $sql.= " , special_code=".$this->special_code;
$sql.= " , fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null");
if (! empty($this->rang)) $sql.= ", rang=".$this->rang;
$sql.= " WHERE rowid = ".$this->rowid;
dol_syslog("PropaleLigne::update sql=$sql");
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
@ -2714,7 +2726,7 @@ class PropaleLigne
else
{
$this->error=$this->db->error();
dol_syslog("PropaleLigne::update Error ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::update Error ".$this->error, LOG_ERR);
$this->db->rollback();
return -2;
}

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
*
* This program is free software; you can redistribute it and/or modify
@ -177,16 +177,16 @@ if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_societe as cs";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d on (d.rowid = s.fk_departement)";
$sql.= " WHERE s.fk_stcomm = st.id";
$sql.= " AND s.client in (2, 3)";
$sql.= " AND s.client IN (2, 3)";
$sql.= " AND s.entity = ".$conf->entity;
if ($user->societe_id) $sql.= " AND s.rowid = " .$user->societe_id;
if ($search_sale) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
if ($search_categ) $sql.= " AND s.rowid = cs.fk_societe"; // Join for the needed table to filter by categ
if (isset($stcomm) && $stcomm != '') $sql.= " AND s.fk_stcomm=".$stcomm;
if ($search_nom) $sql .= " AND s.nom like '%".$db->escape(strtolower($search_nom))."%'";
if ($search_ville) $sql .= " AND s.ville like '%".$db->escape(strtolower($search_ville))."%'";
if ($search_departement) $sql .= " AND d.nom like '%".$db->escape(strtolower($search_departement))."%'";
if ($search_nom) $sql .= " AND s.nom LIKE '%".$db->escape(strtolower($search_nom))."%'";
if ($search_ville) $sql .= " AND s.ville LIKE '%".$db->escape(strtolower($search_ville))."%'";
if ($search_departement) $sql .= " AND d.nom LIKE '%".$db->escape(strtolower($search_departement))."%'";
if ($search_datec) $sql .= " AND s.datec LIKE '%".$db->escape($search_datec)."%'";
// Insert levels filters
if ($search_levels)
@ -205,7 +205,7 @@ if ($search_categ)
}
if ($socname)
{
$sql .= " AND s.nom like '%".$db->escape($socname)."%'";
$sql .= " AND s.nom LIKE '%".$db->escape($socname)."%'";
$sortfield = "s.nom";
$sortorder = "ASC";
}
@ -262,7 +262,7 @@ if ($resql)
// Print the search-by-sale and search-by-categ filters
print '<form method="get" action="prospects.php" id="formulaire_recherche">';
print '<form method="get" action="'.$_SERVER["PHP_SELF"].'" id="formulaire_recherche">';
print '<table class="liste" width="100%">';
@ -289,12 +289,12 @@ if ($resql)
}
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Company"),"prospects.php","s.nom","",$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Town"),"prospects.php","s.ville","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("State"),"prospects.php","s.fk_departement","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateCreation"),"prospects.php","s.datec","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("ProspectLevelShort"),"prospects.php","s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("StatusProsp"),"prospects.php","s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","",$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Town"),$_SERVER["PHP_SELF"],"s.ville","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("State"),$_SERVER["PHP_SELF"],"s.fk_departement","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"s.datec","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("ProspectLevelShort"),$_SERVER["PHP_SELF"],"s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("StatusProsp"),$_SERVER["PHP_SELF"],"s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder);
print '<td class="liste_titre">&nbsp;</td>';
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$params,'align="right"',$sortfield,$sortorder);
print "</tr>\n";
@ -377,11 +377,11 @@ if ($resql)
print $prospectstatic->getNomUrl(1,'prospect');
print '</td>';
print "<td>".$obj->ville."&nbsp;</td>";
print "<td align=\"center\">$obj->departement</td>";
print '<td align="center">'.$obj->departement.'</td>';
// Creation date
print "<td align=\"center\">".dol_print_date($db->jdate($obj->datec))."</td>";
print '<td align="center">'.dol_print_date($db->jdate($obj->datec)).'</td>';
// Level
print "<td align=\"center\">";
print '<td align="center">';
print $prospectstatic->LibLevel($obj->fk_prospectlevel);
print "</td>";
// Statut
@ -395,7 +395,7 @@ if ($resql)
{
if ($value <> $obj->fk_stcomm)
{
print '<a href="prospects.php?socid='.$obj->rowid.'&amp;pstcomm='.$value.'&amp;action=cstc&amp;'.$param.($page?'&amp;page='.$page:'').'">';
print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$obj->rowid.'&amp;pstcomm='.$value.'&amp;action=cstc&amp;'.$param.($page?'&amp;page='.$page:'').'">';
print img_action(0,$value);
print '</a>&nbsp;';
}

View File

@ -2222,6 +2222,13 @@ class Commande extends CommonObject
$staticline=new OrderLine($this->db);
$staticline->fetch($rowid);
$this->line->oldline = $staticline;
// Reorder if fk_parent_line change
if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line)
{
$rangmax = $this->line_max($fk_parent_line);
$this->line->rang = $rangmax + 1;
}
$this->line->rowid=$rowid;
$this->line->desc=$desc;
@ -2250,6 +2257,9 @@ class Commande extends CommonObject
$result=$this->line->update();
if ($result > 0)
{
// Reorder if child line
if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
// Mise a jour info denormalisees
$this->update_price(1);
@ -3095,11 +3105,10 @@ class OrderLine
if ($this->date_end) { $sql.= " , date_end='".$this->db->idate($this->date_end)."'"; }
$sql.= " , product_type=".$this->product_type;
$sql.= " , fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null");
if (! empty($this->rang)) $sql.= ", rang=".$this->rang;
$sql.= " WHERE rowid = ".$this->rowid;
dol_syslog("OrderLine::update sql=$sql");
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
@ -3119,7 +3128,7 @@ class OrderLine
else
{
$this->error=$this->db->error();
dol_syslog("OrderLine::update Error ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::update Error ".$this->error, LOG_ERR);
$this->db->rollback();
return -2;
}

View File

@ -79,9 +79,9 @@ $hookmanager=new HookManager($db);
$hookmanager->callHooks(array('invoicecard'));
/******************************************************************************/
/* Actions */
/******************************************************************************/
/*
* Actions
*/
$parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
@ -239,7 +239,7 @@ if ($action == 'setmode')
{
$object->fetch($id);
$result=$object->mode_reglement($_POST['mode_reglement_id']);
if ($result < 0) dol_print_error($object->db,$object->error);
if ($result < 0) dol_print_error($db,$object->error);
}
if ($action == 'setinvoicedate')
@ -248,7 +248,7 @@ if ($action == 'setinvoicedate')
$object->date=dol_mktime(12,0,0,$_POST['invoicedatemonth'],$_POST['invoicedateday'],$_POST['invoicedateyear']);
if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement=$object->date;
$result=$object->update($user);
if ($result < 0) dol_print_error($object->db,$object->error);
if ($result < 0) dol_print_error($db,$object->error);
}
if ($action == 'setpaymentterm')
@ -256,14 +256,14 @@ if ($action == 'setpaymentterm')
$object->fetch($id);
$date_lim_reglement=dol_mktime(12,0,0,$_POST['paymenttermmonth'],$_POST['paymenttermday'],$_POST['paymenttermyear']);
$result=$object->cond_reglement($object->cond_reglement_id,$date_lim_reglement);
if ($result < 0) dol_print_error($object->db,$object->error);
if ($result < 0) dol_print_error($db,$object->error);
}
if ($action == 'setconditions')
{
$object->fetch($id);
$result=$object->cond_reglement($_POST['cond_reglement_id']);
if ($result < 0) dol_print_error($object->db,$object->error);
if ($result < 0) dol_print_error($db,$object->error);
}
if ($action == 'setremisepercent' && $user->rights->facture->creer)
@ -501,7 +501,6 @@ if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->f
}
/*
* Insert new invoice in database
*/

View File

@ -2016,6 +2016,13 @@ class Facture extends CommonObject
$staticline=new FactureLigne($this->db);
$staticline->fetch($rowid);
$this->line->oldline = $staticline;
// Reorder if fk_parent_line change
if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line)
{
$rangmax = $this->line_max($fk_parent_line);
$this->line->rang = $rangmax + 1;
}
$this->line->rowid = $rowid;
$this->line->desc = $desc;
@ -2044,6 +2051,9 @@ class Facture extends CommonObject
$result=$this->line->update();
if ($result > 0)
{
// Reorder if child line
if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
// Mise a jour info denormalisees au niveau facture
$this->update_price(1);
$this->db->commit();
@ -3567,8 +3577,9 @@ class FactureLigne
}
/**
* Update line into database
* @return int <0 if KO, >0 if OK
* Update line into database
*
* @return int <0 if KO, >0 if OK
*/
function update()
{
@ -3621,10 +3632,10 @@ class FactureLigne
$sql.= ",total_localtax1=".price2num($this->total_localtax1)."";
$sql.= ",total_localtax2=".price2num($this->total_localtax2)."";
$sql.= ",fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null");
if (! empty($this->rang)) $sql.= ", rang=".$this->rang;
$sql.= " WHERE rowid = ".$this->rowid;
dol_syslog("FactureLigne::update sql=".$sql);
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
@ -3643,7 +3654,7 @@ class FactureLigne
else
{
$this->error=$this->db->error();
dol_syslog("FactureLigne::update Error ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::update Error ".$this->error, LOG_ERR);
$this->db->rollback();
return -2;
}

View File

@ -54,8 +54,9 @@ class Paiement extends CommonObject
/**
* \brief Constructeur de la classe
* \param DB handler acces base de donnees
* Constructor
*
* @param DoliDB $DB Database handler
*/
function Paiement($DB)
{
@ -64,8 +65,9 @@ class Paiement extends CommonObject
/**
* Load payment from database
* @param id id of payment to get
* @return int <0 if KO, 0 if not found, >0 if OK
*
* @param int $id Id of payment to get
* @return int <0 if KO, 0 if not found, >0 if OK
*/
function fetch($id)
{
@ -120,9 +122,10 @@ class Paiement extends CommonObject
/**
* Create payment of invoices into database.
* Use this->amounts to have list of invoices for the payment
* @param user object user
* @param closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more
* @return int id of created payment, < 0 if error
*
* @param User $user Object user
* @param int $closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more
* @return int id of created payment, < 0 if error
*/
function create($user,$closepaidinvoices=0)
{
@ -252,7 +255,9 @@ class Paiement extends CommonObject
* Supprime un paiement ainsi que les lignes qu'il a genere dans comptes
* Si le paiement porte sur un ecriture compte qui est rapprochee, on refuse
* Si le paiement porte sur au moins une facture a "payee", on refuse
* @return int <0 si ko, >0 si ok
*
* @param int $notrigger No trigger
* @return int <0 si ko, >0 si ok
*/
function delete($notrigger=0)
{
@ -351,13 +356,15 @@ class Paiement extends CommonObject
/**
* A record into bank for payment with links between this bank record and invoices of payment.
* All payment properties must have been set first like after a call to create().
* @param user Object of user making payment
* @param mode 'payment', 'payment_supplier'
* @param label Label to use in bank record
* @param accountid Id of bank account to do link with
* @param emetteur_nom Name of transmitter
* @param emetteur_banque Name of bank
* @return int <0 if KO, bank_line_id if OK
*
* @param User $user Object of user making payment
* @param string $mode 'payment', 'payment_supplier'
* @param string $label Label to use in bank record
* @param int $accountid Id of bank account to do link with
* @param string $emetteur_nom Name of transmitter
* @param string $emetteur_banque Name of bank
* @param int $notrigger No trigger
* @return int <0 if KO, bank_line_id if OK
*/
function addPaymentToBank($user,$mode,$label,$accountid,$emetteur_nom,$emetteur_banque,$notrigger=0)
{
@ -382,15 +389,17 @@ class Paiement extends CommonObject
if ($mode == 'payment_supplier') $totalamount=-$totalamount;
// Insert payment into llx_bank
$bank_line_id = $acc->addline($this->datepaye,
$this->paiementid, // Payment mode id or code ("CHQ or VIR for example")
$label,
$totalamount,
$this->num_paiement,
'',
$user,
$emetteur_nom,
$emetteur_banque);
$bank_line_id = $acc->addline(
$this->datepaye,
$this->paiementid, // Payment mode id or code ("CHQ or VIR for example")
$label,
$totalamount,
$this->num_paiement,
'',
$user,
$emetteur_nom,
$emetteur_banque
);
// Mise a jour fk_bank dans llx_paiement
// On connait ainsi le paiement qui a genere l'ecriture bancaire
@ -433,8 +442,13 @@ class Paiement extends CommonObject
$fac->fetch_thirdparty();
if (! in_array($fac->thirdparty->id,$linkaddedforthirdparty)) // Not yet done for this thirdparty
{
$result=$acc->add_url_line($bank_line_id, $fac->thirdparty->id,
DOL_URL_ROOT.'/comm/fiche.php?socid=', $fac->thirdparty->nom, 'company');
$result=$acc->add_url_line(
$bank_line_id,
$fac->thirdparty->id,
DOL_URL_ROOT.'/comm/fiche.php?socid=',
$fac->thirdparty->nom,
'company'
);
if ($result <= 0) dol_print_error($this->db);
$linkaddedforthirdparty[$fac->thirdparty->id]=$fac->thirdparty->id; // Mark as done for this thirdparty
}
@ -446,8 +460,13 @@ class Paiement extends CommonObject
$fac->fetch_thirdparty();
if (! in_array($fac->thirdparty->id,$linkaddedforthirdparty)) // Not yet done for this thirdparty
{
$result=$acc->add_url_line($bank_line_id, $fac->thirdparty->id,
DOL_URL_ROOT.'/fourn/fiche.php?socid=', $fac->thirdparty->nom, 'company');
$result=$acc->add_url_line(
$bank_line_id,
$fac->thirdparty->id,
DOL_URL_ROOT.'/fourn/fiche.php?socid=',
$fac->thirdparty->nom,
'company'
);
if ($result <= 0) dol_print_error($this->db);
$linkaddedforthirdparty[$fac->thirdparty->id]=$fac->thirdparty->id; // Mark as done for this thirdparty
}
@ -485,7 +504,9 @@ class Paiement extends CommonObject
/**
* Mise a jour du lien entre le paiement et la ligne generee dans llx_bank
* @param id_bank Id compte bancaire
*
* @param int $id_bank Id compte bancaire
* @return int <0 if KO, >0 if OK
*/
function update_fk_bank($id_bank)
{
@ -506,8 +527,72 @@ class Paiement extends CommonObject
}
}
/**
* Updates the payment date
*
* @param timestamp $date New date
* @return int <0 if KO, 0 if OK
*/
function update_date($date)
{
if (!empty($date) && $this->statut!=1)
{
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET datep = ".$this->db->idate($date);
$sql.= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::update_date sql=".$sql);
$result = $this->db->query($sql);
if ($result)
{
$this->datepaye = $date;
$this->date = $date;
return 0;
}
else
{
$this->error='Error -1 '.$this->db->error();
dol_syslog(get_class($this)."::update_date ".$this->error, LOG_ERR);
return -2;
}
}
return -1; //no date given or already validated
}
/**
* Updates the payment number
*
* @param string $num New num
* @return int <0 if KO, 0 if OK
*/
function update_num($num)
{
if(!empty($num) && $this->statut!=1)
{
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET num_paiement = '".$this->db->escape($num)."'";
$sql.= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::update_num sql=".$sql);
$result = $this->db->query($sql);
if ($result)
{
$this->numero = $this->db->escape($num);
return 0;
}
else
{
$this->error='Error -1 '.$this->db->error();
dol_syslog(get_class($this)."::update_num ".$this->error, LOG_ERR);
return -2;
}
}
return -1; //no num given or already validated
}
/**
* Validate payment
*
* @return int <0 if KO, >0 if OK
*/
function valide()
@ -572,9 +657,10 @@ class Paiement extends CommonObject
}
/**
* \brief Retourne la liste des factures sur lesquels porte le paiement
* \param filter Critere de filtre
* \return array Tableau des id de factures
* Retourne la liste des factures sur lesquels porte le paiement
*
* @param string $filter Critere de filtre
* @return array Tableau des id de factures
*/
function getBillsArray($filter='')
{
@ -608,10 +694,11 @@ class Paiement extends CommonObject
/**
* \brief Renvoie nom clicable (avec eventuellement le picto)
* \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
* \param option Sur quoi pointe le lien
* \return string Chaine avec URL
* Renvoie nom clicable (avec eventuellement le picto)
*
* @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
* @param string $option Sur quoi pointe le lien
* @return string Chaine avec URL
*/
function getNomUrl($withpicto=0,$option='')
{
@ -629,9 +716,10 @@ class Paiement extends CommonObject
}
/**
* \brief Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee)
* \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* \return string Libelle
* Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee)
*
* @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 Libelle
*/
function getLibStatut($mode=0)
{
@ -639,14 +727,16 @@ class Paiement extends CommonObject
}
/**
* \brief Renvoi le libelle d'un statut donne
* \param status Statut
* \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* \return string Libelle du statut
* Renvoi le libelle d'un statut donne
*
* @param int $status Statut
* @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 Libelle du statut
*/
function LibStatut($status,$mode=0)
{
global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
$langs->load('compta');
if ($mode == 0)
{

View File

@ -126,6 +126,37 @@ if ($action == 'confirm_valide' && GETPOST('confirm') == 'yes' && $user->rights-
}
}
if ($action == 'setnum' && !empty($_POST['num']))
{
$paiement = new Paiement($db);
$paiement->fetch($id);
$res = $paiement->update_num($_POST['num']);
if ($res === 0)
{
$mesg = '<div class="ok">'.$langs->trans('PaymentNumberUpdateSucceeded').'</div>';
}
else
{
$mesg = '<div class="error">'.$langs->trans('PaymentNumberUpdateFailed').'</div>';
}
}
if ($action == 'setdate' && !empty($_POST['dateday']))
{
$paiement = new Paiement($db);
$paiement->fetch($id);
$datepaye = dol_mktime(12, 0, 0, $_POST['datemonth'], $_POST['dateday'], $_POST['dateyear']);
$res = $paiement->update_date($datepaye);
if ($res === 0)
{
$mesg = '<div class="ok">'.$langs->trans('PaymentDateUpdateSucceeded').'</div>';
}
else
{
$mesg = '<div class="error">'.$langs->trans('PaymentDateUpdateFailed').'</div>';
}
}
/*
* View
@ -185,25 +216,25 @@ dol_htmloutput_mesg($mesg);
print '<table class="border" width="100%">';
// Ref
print '<tr><td valign="top" width="140">'.$langs->trans('Ref').'</td><td colspan="3">'.$paiement->id.'</td></tr>';
print '<tr><td valign="top" width="20%">'.$langs->trans('Ref').'</td><td colspan="3">'.$paiement->id.'</td></tr>';
// Date
print '<tr><td valign="top" width="120">'.$langs->trans('Date').'</td><td colspan="3">'.dol_print_date($paiement->date,'day').'</td></tr>';
// Date payment
print '<tr><td valign="top">'.$html->editfieldkey("Date",'date',$paiement->date,'id',$paiement->id,$user->rights->facture->paiement).'</td><td colspan="3">';
print $html->editfieldval("Date",'date',$paiement->date,'id',$paiement->id,$user->rights->facture->paiement,'day');
print '</td></tr>';
// Payment type (VIR, LIQ, ...)
$labeltype=$langs->trans("PaymentType".$paiement->type_code)!=("PaymentType".$paiement->type_code)?$langs->trans("PaymentType".$paiement->type_code):$paiement->type_libelle;
print '<tr><td valign="top">'.$langs->trans('Mode').'</td><td colspan="3">'.$labeltype.'</td></tr>';
print '<tr><td valign="top">'.$langs->trans('PaymentMode').'</td><td colspan="3">'.$labeltype.'</td></tr>';
// Numero
//if ($paiement->montant)
//{
print '<tr><td valign="top">'.$langs->trans('Numero').'</td><td colspan="3">'.$paiement->numero.'</td></tr>';
//}
// Payment numero
print '<tr><td valign="top">'.$html->editfieldkey("Numero",'num',$paiement->numero,'id',$paiement->id,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td colspan="3">';
print $html->editfieldval("Numero",'num',$paiement->numero,'id',$paiement->id,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer,'string');
print '</td></tr>';
// Amount
print '<tr><td valign="top">'.$langs->trans('Amount').'</td><td colspan="3">'.price($paiement->montant).'&nbsp;'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
// Note
print '<tr><td valign="top">'.$html->editfieldkey("Note",'note',$paiement->note,'id',$paiement->id,$user->rights->facture->paiement).'</td><td colspan="3">';
print $html->editfieldval("Note",'note',$paiement->note,'id',$paiement->id,$user->rights->facture->paiement,'text');

View File

@ -967,6 +967,8 @@ abstract class CommonObject
{
$sql = 'SELECT rang FROM '.MAIN_DB_PREFIX.$this->table_element_line;
$sql.= ' WHERE rowid ='.$rowid;
dol_syslog(get_class($this)."::getRangOfLine sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
@ -1008,13 +1010,18 @@ abstract class CommonObject
$sql = 'SELECT max(rang) FROM '.MAIN_DB_PREFIX.$this->table_element_line;
$sql.= ' WHERE '.$this->fk_element.' = '.$this->id;
$sql.= ' AND fk_parent_line = '.$fk_parent_line;
dol_syslog(get_class($this)."::line_max sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
$row = $this->db->fetch_row($resql);
if (! empty($row[0])) {
if (! empty($row[0]))
{
return $row[0];
} else {
}
else
{
return $this->getRangOfLine($fk_parent_line);
}
}
@ -1024,6 +1031,8 @@ abstract class CommonObject
{
$sql = 'SELECT max(rang) FROM '.MAIN_DB_PREFIX.$this->table_element_line;
$sql.= ' WHERE '.$this->fk_element.' = '.$this->id;
dol_syslog(get_class($this)."::line_max sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
@ -1075,8 +1084,9 @@ abstract class CommonObject
/**
* Update public note of element
* @param note_public New value for note
* @return int <0 if KO, >0 if OK
*
* @param string $note_public New value for note
* @return int <0 if KO, >0 if OK
*/
function update_note_public($note_public)
{
@ -1562,8 +1572,8 @@ abstract class CommonObject
}
else return 0;
}
/**
* Function to check if an object is used by others
*
@ -1609,7 +1619,7 @@ abstract class CommonObject
}
else return 0;
}
// --------------------
// TODO: All functions here must be redesigned and moved as they are not business functions but output functions
@ -1619,7 +1629,7 @@ abstract class CommonObject
/**
*
* Enter description here ...
*
*
* @param unknown_type $objectid
* @param unknown_type $objecttype
* @param unknown_type $withpicto

View File

@ -121,7 +121,7 @@ class Conf
$value=$objp->value;
if ($key)
{
if (! defined("$key")) define ("$key", $value); // In some cases, the constant might be already forced (Example: SYSLOG_FILE during install)
if (! defined("$key")) define ("$key", $value); // In some cases, the constant might be already forced (Example: SYSLOG_FILE_ON and SYSLOG_FILE during install)
$this->global->$key=$value;
if ($value && preg_match('/^MAIN_MODULE_/',$key))

View File

@ -51,11 +51,14 @@ class HookManager
/**
* Init array this->hooks with instantiated controler
* A hook is declared by a module by adding a constant MAIN_MODULE_MYMODULENAME_HOOKS
*
* First, a hook is declared by a module by adding a constant MAIN_MODULE_MYMODULENAME_HOOKS
* with value nameofhookkey1:nameofhookkey2:...:nameofhookkeyn.
* This add into conf->hooks_module an entries ('modulename'=>nameofhookkey)
* After this, this->hooks is defined
* @param arraytype Array list of hooked tab/features. For example: thirdpartytab, ...
* This add into conf->hooks_modules an entrie ('modulename'=>nameofhookkey)
* Then, when this function is called, an array this->hooks is defined with instance of controler
* classes that support the hook called
*
* @param arraytype Array list of searched hooks tab/features. For example: 'thirdpartytab', 'thirdparty',...
* @return int Always 1
*/
function callHooks($arraytype)

View File

@ -97,14 +97,14 @@ class Form
* @param string $preselected Preselected value for parameter
* @param string $paramkey Key of parameter (unique if there is several parameter to show)
* @param boolean $perm Permission to allow button to edit parameter
* @param string $typeofdata Type of data ('string' by default, 'email', 'text', ...)
* @param string $typeofdata Type of data ('string' by default, 'email', 'text', 'day', ...)
* @param string $editvalue Use this value instead $preselected
* @return string HTML edit field
* TODO no GET or POST in class file, use a param
*/
function editfieldval($text,$htmlname,$preselected,$paramkey,$paramvalue,$perm,$typeofdata='string',$editvalue='')
{
global $langs;
global $langs,$db;
$ret='';
if (GETPOST('action') == 'edit'.$htmlname)
{
@ -123,14 +123,20 @@ class Form
{
$ret.='<textarea name="'.$htmlname.'">'.($editvalue?$editvalue:$preselected).'</textarea>';
}
else if ($typeofdata == 'day')
{
$html=new Form($db);
$ret.=$html->form_date($_SERVER['PHP_SELF'].($paramkey?'?'.$paramkey.'='.$paramvalue:''),$preselected,$htmlname);
}
$ret.='</td>';
$ret.='<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
if ($typeofdata != 'day') $ret.='<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
$ret.='</tr></table>'."\n";
$ret.='</form>'."\n";
}
else
{
if ($typeofdata == 'email') $ret.=dol_print_email($preselected,0,0,0,0,1);
if ($typeofdata == 'day') $ret.=dol_print_date($preselected,'day');
else $ret.=$preselected;
}
return $ret;
@ -238,7 +244,7 @@ class Form
/**
* Return combo list of activated countries, into language of user
*
*
* @param selected Id or Code or Label of preselected country
* @param htmlname Name of html select object
* @param htmloption Options html on select object
@ -250,7 +256,7 @@ class Form
/**
* Return combo list of activated countries, into language of user
*
*
* @param selected Id or Code or Label of preselected country
* @param htmlname Name of html select object
* @param htmloption Options html on select object
@ -320,7 +326,7 @@ class Form
/**
* Retourne la liste des types de comptes financiers
*
*
* @param selected Type pre-selectionne
* @param htmlname Nom champ formulaire
*/
@ -356,7 +362,7 @@ class Form
/**
* Return list of social contributions.
* Use mysoc->pays_id or mysoc->pays_code so they must be defined.
*
*
* @param selected Preselected type
* @param htmlname Name of field in form
* @param useempty Set to 1 if we want an empty value
@ -426,7 +432,7 @@ class Form
/**
* Return list of types of lines (product or service)
* Example: 0=product, 1=service, 9=other (for external module)
*
*
* @param selected Preselected type
* @param htmlname Name of field in html form
* @param showempty Add an empty field
@ -517,7 +523,7 @@ class Form
/**
* Output html form to select a third party
*
*
* @param selected Preselected type
* @param htmlname Name of field in form
* @param filter Optionnal filters criteras
@ -532,7 +538,7 @@ class Form
/**
* Output html form to select a third party
*
*
* @param selected Preselected type
* @param htmlname Name of field in form
* @param filter Optionnal filters criteras
@ -608,7 +614,7 @@ class Form
/**
* Return HTML combo list of absolute discounts
*
*
* @param selected Id remise fixe pre-selectionnee
* @param htmlname Nom champ formulaire
* @param filter Criteres optionnels de filtre
@ -674,7 +680,7 @@ class Form
/**
* Return list of all contacts (for a third party or all)
*
*
* @param socid Id ot third party or 0 for all
* @param selected Id contact pre-selectionne
* @param htmlname Name of HTML field ('none' for a not editable field)
@ -900,15 +906,16 @@ class Form
/**
* Return list of products for customer in Ajax if Ajax activated or go to select_produits_do
*
* @param selected Preselected products
* @param htmlname Name of HTML seletc field (must be unique in page)
* @param filtertype Filter on product type (''=nofilter, 0=product, 1=service)
* @param limit Limit on number of returned lines
* @param price_level Level of price to show
* @param status -1=Return all products, 0=Products not on sell, 1=Products on sell
* @param finished 2=all, 1=finished, 0=raw material
* @param $selected_input_value Value of preselected input text (with ajax)
*
* @param int $selected Preselected products
* @param string $htmlname Name of HTML seletc field (must be unique in page)
* @param int $filtertype Filter on product type (''=nofilter, 0=product, 1=service)
* @param int $limit Limit on number of returned lines
* @param int $price_level Level of price to show
* @param int $status -1=Return all products, 0=Products not on sell, 1=Products on sell
* @param int $finished 2=all, 1=finished, 0=raw material
* @param string $selected_input_value Value of preselected input text (with ajax)
* @return void
*/
function select_produits($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$status=1,$finished=2,$selected_input_value='',$hidelabel=0)
{
@ -941,16 +948,16 @@ class Form
/**
* Return list of products for a customer
*
* @param selected Preselected product
* @param htmlname Name of select html
* @param filtertype Filter on product type (''=nofilter, 0=product, 1=service)
* @param limit Limite sur le nombre de lignes retournees
* @param price_level Level of price to show
* @param filterkey Filter on product
* @param status -1=Return all products, 0=Products not on sell, 1=Products on sell
* @param finished Filter on finished field: 2=No filter
* @param disableout Disable print output
* @return array Array of keys for json
* @param int $selected Preselected product
* @param string $htmlname Name of select html
* @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service)
* @param int $limit Limite sur le nombre de lignes retournees
* @param int $price_level Level of price to show
* @param string $filterkey Filter on product
* @param int $status -1=Return all products, 0=Products not on sell, 1=Products on sell
* @param int $finished Filter on finished field: 2=No filter
* @param int $disableout Disable print output
* @return array Array of keys for json
*/
function select_produits_do($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$filterkey='',$status=1,$finished=2,$disableout=0)
{
@ -970,16 +977,16 @@ class Form
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang='". $langs->getDefaultLang() ."'";
}
$sql.= ' WHERE p.entity IN (0,'.(! empty($conf->entities['product']) ? $conf->entities['product'] : $conf->entity).')';
if($finished == 0)
if ($finished == 0)
{
$sql.= " AND p.finished = ".$finished;
}
elseif($finished == 1)
elseif ($finished == 1)
{
$sql.= " AND p.finished = ".$finished;
if ($status >= 0) $sql.= " AND p.tosell = ".$status;
}
elseif($status >= 0)
elseif ($status >= 0)
{
$sql.= " AND p.tosell = ".$status;
}
@ -1200,16 +1207,14 @@ class Form
$langs->load('stocks');
$sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration,";
$sql.= " pf.ref_fourn,";
$sql.= " pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.unitprice,";
$sql.= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.unitprice,";
$sql.= " s.nom";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur as pf ON p.rowid = pf.fk_product";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pf.fk_soc = s.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON pf.rowid = pfp.fk_product_fournisseur";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid";
$sql.= " WHERE p.entity = ".$conf->entity;
$sql.= " AND p.tobuy = 1";
if ($socid) $sql.= " AND pf.fk_soc = ".$socid;
if ($socid) $sql.= " AND pfp.fk_soc = ".$socid;
if (strval($filtertype) != '') $sql.=" AND p.fk_product_type=".$filtertype;
if (! empty($filtre)) $sql.=" ".$filtre;
// Add criteria on ref/label
@ -1217,14 +1222,14 @@ class Form
{
if (! empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE))
{
$sql.=" AND (pf.ref_fourn LIKE '".$filterkey."%' OR p.ref LIKE '".$filterkey."%' OR p.label LIKE '".$filterkey."%')";
$sql.=" AND (pfp.ref_fourn LIKE '".$filterkey."%' OR p.ref LIKE '".$filterkey."%' OR p.label LIKE '".$filterkey."%')";
}
else
{
$sql.=" AND (pf.ref_fourn LIKE '%".$filterkey."%' OR p.ref LIKE '%".$filterkey."%' OR p.label LIKE '%".$filterkey."%')";
$sql.=" AND (pfp.ref_fourn LIKE '%".$filterkey."%' OR p.ref LIKE '%".$filterkey."%' OR p.label LIKE '%".$filterkey."%')";
}
}
$sql.= " ORDER BY pf.ref_fourn DESC";
$sql.= " ORDER BY pfp.ref_fourn DESC";
// Build output string
$outselect='';
@ -1347,17 +1352,16 @@ class Form
$langs->load('stocks');
$sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration,";
$sql.= " pf.ref_fourn,";
$sql.= " pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.unitprice,";
$sql.= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.unitprice,";
$sql.= " s.nom";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur as pf ON p.rowid = pf.fk_product";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = pf.fk_soc";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON pf.rowid = pfp.fk_product_fournisseur";
$sql.= " WHERE p.tobuy = 1";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid";
$sql.= " WHERE p.entity = ".$conf->entity;
$sql.= " AND p.tobuy = 1";
$sql.= " AND s.fournisseur = 1";
$sql.= " AND p.rowid = ".$productid;
$sql.= " ORDER BY s.nom, pf.ref_fourn DESC";
$sql.= " ORDER BY s.nom, pfp.ref_fourn DESC";
dol_syslog("Form::select_product_fourn_price sql=".$sql,LOG_DEBUG);
$result=$this->db->query($sql);
@ -1425,7 +1429,7 @@ class Form
/**
* Return list of delivery address
*
*
* @param string $selected Id contact pre-selectionn
* @param int $socid Id of company
* @param string $htmlname Name of HTML field
@ -1477,7 +1481,7 @@ class Form
/**
* Charge dans cache la liste des conditions de paiements possibles
*
*
* @return int Nb lignes chargees, 0 si deja chargees, <0 si ko
*/
function load_cache_conditions_paiements()
@ -1516,7 +1520,7 @@ class Form
/**
* Charge dans cache la liste des délais de livraison possibles
*
*
* @return int Nb lignes chargees, 0 si deja chargees, <0 si ko
*/
function load_cache_availability()
@ -1555,7 +1559,7 @@ class Form
/**
* Retourne la liste des types de delais de livraison possibles
*
*
* @param selected Id du type de delais pre-selectionne
* @param htmlname Nom de la zone select
* @param filtertype To add a filter
@ -1588,7 +1592,7 @@ class Form
/**
* Load into cache cache_demand_reason, array of input reasons
*
*
* @return int Nb of lines loaded, 0 if already loaded, <0 if ko
*/
function load_cache_demand_reason()
@ -1632,7 +1636,7 @@ class Form
/**
* Return list of events that triggered an object creation
*
*
* @param selected Id du type d'origine pre-selectionne
* @param htmlname Nom de la zone select
* @param exclude To exclude a code value (Example: SRC_PROP)
@ -1667,7 +1671,7 @@ class Form
/**
* Charge dans cache la liste des types de paiements possibles
*
*
* @return int Nb lignes chargees, 0 si deja chargees, <0 si ko
*/
function load_cache_types_paiements()

View File

@ -432,14 +432,14 @@ class FormFile
if ($allowgenifempty && ! is_array($modellist) && empty($modellist) && $modulepart != 'unpaid')
{
$langs->load("errors");
$out.= ' '.img_warning($langs->trans("WarningNoDocumentModelActivated"));
$out.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated"));
}
$out.= '</td>';
$out.= '</tr>';
// Execute hooks
$parameters=array('socid'=>$GLOBALS['socid'],'id'=>$GLOBALS['id']);
$parameters=array('socid'=>$GLOBALS['socid'],'id'=>$GLOBALS['id'],'modulepart'=>$modulepart);
if (is_object($hookmanager)) $out.= $hookmanager->executeHooks('formBuilddocOptions',$parameters);
}

View File

@ -215,7 +215,7 @@ class Translate {
// Using a memcached server
if (! empty($conf->memcached->enabled) && ! empty($conf->global->MEMCACHED_SERVER))
{
$usecachekey=$newdomain.'_'.$langofdir.'_'.dol_hash($file_lang); // Should not contains special chars
$usecachekey=$newdomain.'_'.$langofdir.'_'.md5($file_lang); // Should not contains special chars
}
// Using cache with shmop. Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file)
else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))

View File

@ -36,13 +36,6 @@ $pos = strstr ($uri, '/'); // $pos contient alors url sans nom domaine
if ($pos == '/') $pos = ''; // si $pos vaut /, on le met a ''
define('DOL_URL_ROOT', $pos);
/*
$conf->syslog->enabled=1;
define('SYSLOG_FILE','c:/log/dolibarr/dolibarr.log');
require_once("../../../../../../lib/functions.lib.php");
dol_syslog("eee".$conf->fckeditor->dir_output);
*/
// SECURITY: You must explicitly enable this "connector". (Set it to "true").
// WARNING: don't just set "$Config['Enabled'] = true ;", you must be sure that only
// authenticated users can access this file or use some kind of session checking.

View File

@ -78,12 +78,14 @@ class Fournisseur extends Societe
return $num;
}
/**
* FIXME This returns number of prices, not number of products. Is it what we want ?
*/
function NbProduct()
{
$sql = "SELECT count(pf.rowid)";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur as pf,";
$sql.= " ".MAIN_DB_PREFIX."product_fournisseur_price as ppf";
$sql .= " WHERE fk_soc = ".$this->id." AND ppf.fk_product_fournisseur = pf.rowid";
$sql = "SELECT count(pfp.rowid)";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql .= " WHERE pfp.fk_soc = ".$this->id;
$resql = $this->db->query($sql);
if ( $resql )
@ -163,7 +165,7 @@ class Fournisseur extends Societe
{
$prod = new ProductFournisseur($this->db);
$prod->fetch($fk_product);
$prod->fetch_fourn_data($this->id);
//$prod->fetch_fourn_data($this->id);
$commf->fetch($idc);
$commf->addline("Toto",120,1,$prod->tva, $prod->id, 0, $prod->ref_fourn);
@ -275,11 +277,12 @@ class Fournisseur extends Societe
}
/**
* \brief Renvoie nom clicable (avec eventuellement le picto)
* \param withpicto Inclut le picto dans le lien
* \param option Sur quoi pointe le lien
* \param maxlen Longueur max libelle
* \return string Chaine avec URL
* Return a link on thirdparty (with picto)
*
* @param withpicto Add picto into link (0=No picto, 1=Include picto with link, 2=Picto only)
* @param option Target of link ('', 'customer', 'prospect', 'supplier')
* @param maxlen Max length of text
* @return string String with URL
*/
function getNomUrl($withpicto=0,$option='supplier',$maxlen=0)
{

View File

@ -1822,7 +1822,7 @@ class CommandeFournisseurLigne extends OrderLine
var $libelle; // Label produit
var $product_desc; // Description produit
// From llx_product_fournisseur
// From llx_product_fournisseur_price
var $ref_fourn; // Ref supplier

View File

@ -57,10 +57,10 @@ class FactureFournisseur extends Facture
var $author;
var $libelle;
var $datec;
var $tms;
var $date;
var $date_echeance;
var $datec; // Creation date
var $tms; // Last update date
var $date; // Invoice date
var $date_echeance; // Max payment date
var $amount;
var $remise;
var $tva;
@ -184,17 +184,18 @@ class FactureFournisseur extends Facture
{
$idligne = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det');
$this->updateline($idligne,
$this->lines[$i]->description,
$this->lines[$i]->pu_ht,
$this->lines[$i]->tva_tx,
$this->lines[$i]->localtax1_tx,
$this->lines[$i]->localtax2_tx,
$this->lines[$i]->qty,
$this->lines[$i]->fk_product,
'HT',
$this->lines[$i]->info_bits,
$this->lines[$i]->product_type
$this->updateline(
$idligne,
$this->lines[$i]->description,
$this->lines[$i]->pu_ht,
$this->lines[$i]->tva_tx,
$this->lines[$i]->localtax1_tx,
$this->lines[$i]->localtax2_tx,
$this->lines[$i]->qty,
$this->lines[$i]->fk_product,
'HT',
$this->lines[$i]->info_bits,
$this->lines[$i]->product_type
);
}
}
@ -246,10 +247,12 @@ class FactureFournisseur extends Facture
/**
* Load object in memory from database
* @param id id object
* @return int <0 if KO, >0 if OK
*
* @param int $id Id supplier invoice
* @param string $ref Ref supplier invoice
* @return int <0 if KO, >0 if OK
*/
function fetch($id)
function fetch($id='',$ref='')
{
global $langs;
$sql = "SELECT";
@ -287,7 +290,9 @@ class FactureFournisseur extends Facture
$sql.= " t.import_key,";
$sql.= ' s.nom as socnom, s.rowid as socid';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as t,'.MAIN_DB_PREFIX.'societe as s';
$sql.= ' WHERE t.rowid='.$id.' AND t.fk_soc = s.rowid';
if ($id) $sql.= " WHERE t.rowid=".$id;
if ($ref) $sql.= " WHERE t.rowid='".$this->db->escape($ref)."'"; // ref is id (facnumber is supplier ref)
$sql.= ' AND t.fk_soc = s.rowid';
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
@ -369,8 +374,9 @@ class FactureFournisseur extends Facture
/**
* \brief Load this->lines
* \return int 1 si ok, < 0 si erreur
* Load this->lines
*
* @return int 1 si ok, < 0 si erreur
*/
function fetch_lines()
{
@ -378,10 +384,8 @@ class FactureFournisseur extends Facture
$sql.= ', f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2 ';
$sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type';
$sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc';
//$sql.= ', pf.ref_fourn';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn_det as f';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON f.fk_product = p.rowid';
//$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur as pf ON f.fk_product = pf.fk_product';
$sql.= ' WHERE fk_facture_fourn='.$this->id;
dol_syslog("FactureFournisseur::fetch_lines sql=".$sql, LOG_DEBUG);
@ -433,10 +437,11 @@ class FactureFournisseur extends Facture
/**
* \brief Update database
* \param user User that modify
* \param notrigger 0=launch triggers after, 1=disable triggers
* \return int <0 if KO, >0 if OK
* Update database
*
* @param User $user User that modify
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
function update($user=0, $notrigger=0)
{
@ -486,7 +491,7 @@ class FactureFournisseur extends Facture
$sql.= " fk_soc=".(isset($this->fk_soc)?$this->fk_soc:"null").",";
$sql.= " datec=".(dol_strlen($this->datec)!=0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
$sql.= " datef=".(dol_strlen($this->date)!=0 ? "'".$this->db->idate($this->date)."'" : 'null').",";
$sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
if (dol_strlen($this->tms) != 0) $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
$sql.= " libelle=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
$sql.= " paye=".(isset($this->paye)?$this->paye:"null").",";
$sql.= " amount=".(isset($this->amount)?$this->amount:"null").",";

View File

@ -53,9 +53,9 @@ class ProductFournisseur extends Product
*
* @param DoliDB $DB Database handler
*/
function ProductFournisseur($db)
function ProductFournisseur($DB)
{
$this->db = $db;
$this->db = $DB;
}
@ -63,8 +63,8 @@ class ProductFournisseur extends Product
/**
* Remove all prices for this couple supplier-product
*
* @param id_fourn Supplier Id
* @return int < 0 if error, > 0 if ok
* @param int $id_fourn Supplier Id
* @return int < 0 if error, > 0 if ok
*/
function remove_fournisseur($id_fourn)
{
@ -72,92 +72,36 @@ class ProductFournisseur extends Product
$this->db->begin();
// Search all links
$sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur";
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
$sql.= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn;
dol_syslog(get_class($this)."::remove_fournisseur sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
$resql2=$this->db->query($sql);
if (! $resql2)
{
// For each link, delete price line
while ($obj=$this->db->fetch_object($resql))
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
$sql.= " WHERE fk_product_fournisseur = ".$obj->rowid;
dol_syslog(get_class($this)."::remove_fournisseur sql=".$sql);
$resql2=$this->db->query($sql);
if (! $resql2)
{
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::remove_fournisseur ".$this->error, LOG_ERR);
$ok=0;
}
}
// Now delete all link supplier-product (they have no more childs)
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur";
$sql.= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn;
dol_syslog(get_class($this)."::remove_fournisseur sql=".$sql);
$resql=$this->db->query($sql);
if (! $resql)
{
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::remove_fournisseur ".$this->error, LOG_ERR);
$ok=0;
}
if ($ok)
{
$this->db->commit();
return 1;
}
else
{
$this->db->rollback();
return -1;
}
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::remove_fournisseur ".$this->error, LOG_ERR);
$ok=0;
}
else
{
$this->db->rollback();
dol_print_error($this->db);
return -2;
}
}
/**
* Remove supplier product
*
* @param rowid Product id
* @return int < 0 if error, > 0 if ok
*/
function remove_product_fournisseur($rowid)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur";
$sql.= " WHERE rowid = ".$rowid;
dol_syslog(get_class($this)."::remove_product_fournisseur sql=".$sql);
$resql = $this->db->query($sql);
if ($resql)
if ($ok)
{
$this->db->commit();
return 1;
}
else
{
$this->db->rollback();
return -1;
}
}
/**
* Remove a price for a couple supplier-product
*
* @param rowid Line id of price
* @return int <0 if KO, >0 if OK
* @param int $rowid Line id of price
* @return int <0 if KO, >0 if OK
*/
function remove_product_fournisseur_price($rowid)
{
@ -172,54 +116,8 @@ class ProductFournisseur extends Product
$resql = $this->db->query($sql);
if ($resql)
{
// Remove all entries with no childs
$sql = "SELECT pf.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur as pf";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON pfp.fk_product_fournisseur = pf.rowid";
$sql.= " WHERE pfp.rowid IS NULL";
$sql.= " AND pf.entity = ".$conf->entity;
dol_syslog(get_class($this)."::remove_product_fournisseur_price sql=".$sql);
$resql = $this->db->query($sql);
if ($resql)
{
$ok=1;
while ($obj=$this->db->fetch_object($resql))
{
$rowidpf=$obj->rowid;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur";
$sql.= " WHERE rowid = ".$rowidpf;
dol_syslog(get_class($this)."::remove_product_fournisseur_price sql=".$sql);
$resql2 = $this->db->query($sql);
if (! $resql2)
{
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::remove_product_fournisseur_price ".$this->error,LOG_ERR);
$ok=0;
}
}
if ($ok)
{
$this->db->commit();
return 1;
}
else
{
$this->db->rollback();
return -3;
}
}
else
{
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::remove_product_fournisseur_price ".$this->error,LOG_ERR);
$this->db->rollback();
return -2;
}
$this->db->commit();
return 1;
}
else
{
@ -234,16 +132,18 @@ class ProductFournisseur extends Product
/**
* Modify the purchase price for a supplier
*
* @param qty Min quantity for which price is valid
* @param buyprice Purchase price for the quantity min
* @param user Object user user made changes
* @param price_base_type HT or TTC
* @param fourn Supplier
* @param availability Product availability
* @param int $qty Min quantity for which price is valid
* @param float $buyprice Purchase price for the quantity min
* @param User $user Object user user made changes
* @param string $price_base_type HT or TTC
* @param Societe $fourn Supplier
* @param int $availability Product availability
* @param string $ref_fourn Supplier ref
* @return int >0 if KO, >0 if OK
*/
function update_buyprice($qty, $buyprice, $user, $price_base_type='HT', $fourn, $availability)
function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn)
{
global $mysoc;
global $conf,$mysoc;
// Clean parameter
$buyprice=price2num($buyprice);
@ -259,11 +159,6 @@ class ProductFournisseur extends Product
{
$sql.= " WHERE rowid = ".$this->product_fourn_price_id;
}
else
{
$sql.= " WHERE fk_product_fournisseur = ".$this->product_fourn_id;
$sql.= " AND quantity = ".$qty;
}
$resql=$this->db->query($sql);
if ($resql)
@ -279,14 +174,17 @@ class ProductFournisseur extends Product
// Ajoute prix courant du fournisseur pour cette quantite
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price(";
$sql.= "datec, fk_product_fournisseur, fk_user, price, quantity, unitprice, fk_availability)";
$sql.= "datec, fk_product, fk_soc, ref_fourn, fk_user, price, quantity, unitprice, fk_availability, entity)";
$sql.= " values('".$this->db->idate($now)."',";
$sql.= " ".$this->product_fourn_id.",";
$sql.= " ".$this->id.",";
$sql.= " ".$fourn->id.",";
$sql.= " '".$this->db->escape($ref_fourn)."',";
$sql.= " ".$user->id.",";
$sql.= " ".price2num($buyprice).",";
$sql.= " ".$qty.",";
$sql.= " ".$unitBuyPrice.",";
$sql.= " ".$availability;
$sql.= " ".$availability.",";
$sql.= $conf->entity;
$sql.=")";
dol_syslog(get_class($this)."::update_buyprice sql=".$sql);
@ -295,7 +193,7 @@ class ProductFournisseur extends Product
$error++;
}
if (! $error)
/*if (! $error)
{
// Ajoute modif dans table log
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log(";
@ -313,6 +211,7 @@ class ProductFournisseur extends Product
$error++;
}
}
*/
if (! $error)
{
@ -335,51 +234,13 @@ class ProductFournisseur extends Product
}
/**
* Changes the purchase price for a supplier of the product in the reference supplier
*
* @param id_fourn Supplier ID
* @param product_fourn_ref Supplier ref product
* @param qty Amount for which the price is valid
* @param buyprice Purchase price for the quantity
* @param user Object user user made changes
* @return int <0 if KO, >0 if OK
*/
function UpdateBuyPriceByFournRef($id_fourn, $product_fourn_ref, $qty, $buyprice, $user, $price_base_type='HT')
{
global $conf;
$result=0;
// Recherche id produit pour cette ref et fournisseur
$sql = "SELECT fk_product";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur";
$sql.= " WHERE fk_soc = '".$id_fourn."'";
$sql.= " AND ref_fourn = '".$product_fourn_ref."'";
$sql.= " AND entity = ".$conf->entity;
$resql=$this->db->query($sql);
if ($resql)
{
if ($obj = $this->db->fetch_object($resql))
{
// Met a jour prix pour la qte
$this->id = $obj->fk_product;
$result = $this->update_buyprice($id_fourn, $qty, $buyprice, $user, $price_base_type);
}
}
return $result;
}
/**
* Load information about a provider
*
* @param fournid Supplier ID
* @return int < 0 if error, > 0 if ok
*/
function fetch_fourn_data($fournid)
/*function fetch_fourn_data($fournid)
{
global $conf;
@ -387,7 +248,7 @@ class ProductFournisseur extends Product
if (empty($fournid)) return -1;
$sql = "SELECT rowid, ref_fourn";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur ";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
$sql.= " WHERE fk_product = ".$this->id;
$sql.= " AND fk_soc = ".$fournid;
$sql.= " AND entity = ".$conf->entity;
@ -398,7 +259,7 @@ class ProductFournisseur extends Product
{
$result = $this->db->fetch_array($result);
$this->ref_fourn = $result["ref_fourn"];
$this->product_fourn_id = $result["rowid"];
$this->product_fourn_price_id = $result["rowid"];
return 1;
}
else
@ -407,22 +268,20 @@ class ProductFournisseur extends Product
dol_syslog(get_class($this)."::fetch_fourn_data error=".$this->error, LOG_ERR);
return -1;
}
}
}*/
/**
* Loads the price information of a provider
*
* @param rowid line id
* @return int < 0 if KO, 0 if OK but not found, > 0 if OK
* @param int $rowid Line id
* @return int < 0 if KO, 0 if OK but not found, > 0 if OK
*/
function fetch_product_fournisseur_price($rowid)
{
$sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.fk_availability";
$sql.= ", pf.rowid as product_fourn_id, pf.fk_soc, pf.ref_fourn, pf.fk_product";
$sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.fk_availability,";
$sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.fk_product";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= ", ".MAIN_DB_PREFIX."product_fournisseur as pf";
$sql.= " WHERE pfp.rowid = ".$rowid;
$sql.= " AND pf.rowid = pfp.fk_product_fournisseur";
dol_syslog(get_class($this)."::fetch_product_fournisseur_price sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
@ -432,7 +291,6 @@ class ProductFournisseur extends Product
if ($obj)
{
$this->product_fourn_price_id = $rowid;
$this->product_fourn_id = $obj->product_fourn_id;
$this->fourn_ref = $obj->ref_fourn;
$this->fourn_price = $obj->price;
$this->fourn_qty = $obj->quantity;
@ -459,35 +317,30 @@ class ProductFournisseur extends Product
/**
* List all supplier prices of a product
*
* @param int $rowid id du produit
* @return array Array of ProductFournisseur
* @param int $prodid Id of product
* @return array Array of Products with new properties to define supplier price
*/
function fetch_product_fournisseur($prodid)
function list_product_fournisseur_price($prodid)
{
global $conf;
// Suppliers list
$sql = "SELECT s.nom as supplier_name, ";
$sql.= " s.rowid as fourn_id,";
$sql.= " pf.ref_fourn,";
$sql.= " pfp.rowid as product_fourn_pri_id, ";
$sql.= " pf.rowid as product_fourn_id, ";
$sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,";
$sql.= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn,";
$sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.fk_availability";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."product_fournisseur as pf ON pf.fk_soc = s.rowid ";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= " ON pf.rowid = pfp.fk_product_fournisseur";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= " ON pfp.fk_soc = s.rowid";
$sql.= " WHERE s.entity = ".$conf->entity;
$sql.= " AND pf.fk_product = ".$prodid;
$sql.= " ORDER BY s.nom, pfp.quantity";
$sql.= " AND pfp.fk_product = ".$prodid;
$sql.= " ORDER BY s.nom, pfp.quantity, pfp.price";
dol_syslog(get_class($this)."::fetch_product_fournisseur sql=".$sql, LOG_DEBUG);
dol_syslog(get_class($this)."::list_product_fournisseur_price sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
$prod_fourn = array();
$retarray = array();
while ($record = $this->db->fetch_array($resql))
{
@ -509,7 +362,7 @@ class ProductFournisseur extends Product
{
if ($prodfourn->fourn_qty!=0)
{
$prodfourn->fourn_unitprice = $prodfourn->fourn_price/$prodfourn->fourn_qty;
$prodfourn->fourn_unitprice = price2num($prodfourn->fourn_price/$prodfourn->fourn_qty,'MU');
}
else
{
@ -517,16 +370,16 @@ class ProductFournisseur extends Product
}
}
$prod_fourn[]=$prodfourn;
$retarray[]=$prodfourn;
}
$this->db->free($resql);
return $prod_fourn;
return $retarray;
}
else
{
$this->error=$this->db->error();
dol_syslog(get_class($this)."::fetch_product_fournisseur error=".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::list_product_fournisseur_price error=".$this->error, LOG_ERR);
return -1;
}
}
@ -534,8 +387,8 @@ class ProductFournisseur extends Product
/**
* Load properties for minimum price
*
* @param rowid Product id
* @return int <0 if KO, >0 if OK
* @param int $prodid Product id
* @return int <0 if KO, >0 if OK
*/
function find_min_price_product_fournisseur($prodid)
{
@ -551,18 +404,13 @@ class ProductFournisseur extends Product
$this->fourn_name = '';
$this->id = '';
$sql = "SELECT s.nom as supplier_name, ";
$sql.= " s.rowid as fourn_id,";
$sql.= " pf.ref_fourn,";
$sql.= " pfp.rowid as product_fourn_pri_id, ";
$sql.= " pf.rowid as product_fourn_id, ";
$sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,";
$sql.= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,";
$sql.= " pfp.price, pfp.quantity, pfp.unitprice";
$sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur as pf)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= " ON pf.rowid = pfp.fk_product_fournisseur";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= " WHERE s.entity = ".$conf->entity;
$sql.= " AND pf.fk_product = ".$prodid;
$sql.= " AND pf.fk_soc = s.rowid";
$sql.= " AND pfp.fk_product = ".$prodid;
$sql.= " AND pfp.fk_soc = s.rowid";
$sql.= " ORDER BY pfp.unitprice";
$sql.= $this->db->plimit(1);
@ -572,8 +420,7 @@ class ProductFournisseur extends Product
if ($resql)
{
$record = $this->db->fetch_array($resql);
$this->product_fourn_price_id = $record["product_fourn_pri_id"];
$this->product_fourn_id = $record["product_fourn_id"];
$this->product_fourn_price_id = $record["product_fourn_price_id"];
$this->fourn_ref = $record["ref_fourn"];
$this->fourn_price = $record["price"];
$this->fourn_qty = $record["quantity"];
@ -593,7 +440,10 @@ class ProductFournisseur extends Product
}
/**
* Display supplier of product
*
* @param int $withpicto Add picto
* @return string String with supplier price
*/
function getSocNomUrl($withpicto=0)
{
@ -604,7 +454,9 @@ class ProductFournisseur extends Product
}
/**
* Display price of product
*
* @return string String with supplier price
*/
function display_price_product_fournisseur()
{

View File

@ -55,10 +55,10 @@ class PaiementFourn extends Paiement
// fk_paiement dans llx_paiement_facture est le rowid du paiement
/**
* \brief Constructeur de la classe
* \param DB handler acces base de donnees
* Constructor
*
* @param DoliDB $DB Database handler
*/
function PaiementFourn($DB)
{
$this->db = $DB ;
@ -475,65 +475,5 @@ class PaiementFourn extends Paiement
if ($withpicto != 2) $result.=$lien.$text.$lienfin;
return $result;
}
/**
* \brief Updates the payment number
* \param string New num
* \return int -1 on error, 0 otherwise
*/
function update_num($num)
{
if(!empty($num) && $this->statut!=1)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."paiementfourn";
$sql.= " SET num_paiement = '".$this->db->escape($num)."'";
$sql.= " WHERE rowid = ".$this->id;
dol_syslog("PaiementFourn::update_num sql=".$sql);
$result = $this->db->query($sql);
if ($result)
{
$this->numero = $this->db->escape($num);
return 0;
}
else
{
$this->error='PaiementFourn::update_num Error -1 '.$this->db->error();
dol_syslog('PaiementFourn::update_num error '.$this->error, LOG_ERR);
return -1;
}
}
return -1; //no num given or already validated
}
/**
* \brief Updates the payment date
* \param string New date
* \return int -1 on error, 0 otherwise
*/
function update_date($date)
{
if(!empty($date) && $this->statut!=1)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."paiementfourn";
$sql.= " SET datep = ".$this->db->idate($date);
$sql.= " WHERE rowid = ".$this->id;
dol_syslog("PaiementFourn::update_date sql=".$sql);
$result = $this->db->query($sql);
if ($result)
{
$this->datepaye = $date;
$this-> date = $date;
return 0;
}
else
{
$this->error='PaiementFourn::update_date Error -1 '.$this->db->error();
dol_syslog('PaiementFourn::update_date error '.$this->error, LOG_ERR);
return -1;
}
}
return -1; //no date given or already validated
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -35,18 +35,38 @@ $langs->load('companies');
$langs->load("suppliers");
$mesg='';
$action=GETPOST('action');
$id=GETPOST('id');
/*
* Actions
*/
if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->facture->supprimer)
if ($action == 'setnote' && $user->rights->fournisseur->facture->creer)
{
$db->begin();
$paiement = new PaiementFourn($db);
$paiement->fetch($id);
$result = $paiement->update_note(GETPOST('note'));
if ($result > 0)
{
$db->commit();
$action='';
}
else
{
$mesg='<div class="error">'.$paiement->error.'</div>';
$db->rollback();
}
}
if ($action == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->facture->supprimer)
{
$db->begin();
$paiement = new PaiementFourn($db);
$paiement->fetch($_GET['id']);
$paiement->fetch($id);
$result = $paiement->delete();
if ($result > 0)
{
@ -61,12 +81,12 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user-
}
}
if ($_POST['action'] == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->facture->valider)
if ($action == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->facture->valider)
{
$db->begin();
$paiement = new PaiementFourn($db);
$paiement->id = $_GET['id'];
$paiement->fetch($id);
if ($paiement->valide() >= 0)
{
$db->commit();
@ -80,6 +100,37 @@ if ($_POST['action'] == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user-
}
}
if ($action == 'setnum' && !empty($_POST['num']))
{
$paiement = new PaiementFourn($db);
$paiement->fetch($id);
$res = $paiement->update_num($_POST['num']);
if ($res === 0)
{
$mesg = '<div class="ok">'.$langs->trans('PaymentNumberUpdateSucceeded').'</div>';
}
else
{
$mesg = '<div class="error">'.$langs->trans('PaymentNumberUpdateFailed').'</div>';
}
}
if ($action == 'setdate' && !empty($_POST['dateday']))
{
$paiement = new PaiementFourn($db);
$paiement->fetch($id);
$datepaye = dol_mktime(12, 0, 0, $_POST['datemonth'], $_POST['dateday'], $_POST['dateyear']);
$res = $paiement->update_date($datepaye);
if ($res === 0)
{
$mesg = '<div class="ok">'.$langs->trans('PaymentDateUpdateSucceeded').'</div>';
}
else
{
$mesg = '<div class="error">'.$langs->trans('PaymentDateUpdateFailed').'</div>';
}
}
/*
* View
@ -91,12 +142,12 @@ $html = new Form($db);
$h=0;
$head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$_GET['id'];
$head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$id;
$head[$h][1] = $langs->trans('Card');
$hselected = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/info.php?id='.$_GET['id'];
$head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/info.php?id='.$id;
$head[$h][1] = $langs->trans('Info');
$h++;
@ -104,14 +155,13 @@ $h++;
dol_fiche_head($head, $hselected, $langs->trans('SupplierPayment'), 0, 'payment');
$paiement = new PaiementFourn($db);
$result=$paiement->fetch($_GET['id']);
$result=$paiement->fetch($id);
if ($result > 0)
{
/*
* Confirmation de la suppression du paiement
*/
if ($_GET['action'] == 'delete')
if ($action == 'delete')
{
$ret=$html->form_confirm('fiche.php?id='.$paiement->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete');
if ($ret == 'html') print '<br>';
@ -120,102 +170,31 @@ if ($result > 0)
/*
* Confirmation de la validation du paiement
*/
if ($_GET['action'] == 'valide')
if ($action == 'valide')
{
$ret=$html->form_confirm('fiche.php?id='.$paiement->id, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide');
if ($ret == 'html') print '<br>';
}
if (!empty($_POST['action']) && $_POST['action'] == 'update_num' && !empty($_POST['new_num']))
{
$res = $paiement->update_num($_POST['new_num']);
if ($res === 0) {
$mesg = '<div class="ok">'.$langs->trans('PaymentNumberUpdateSucceeded').'</div>';
} else {
$mesg = '<div class="error">'.$langs->trans('PaymentNumberUpdateFailed').'</div>';
}
}
if (!empty($_POST['action']) && $_POST['action'] == 'update_date' && !empty($_POST['reday']))
{
$datepaye = dol_mktime(12, 0 , 0,
$_POST['remonth'],
$_POST['reday'],
$_POST['reyear']);
$res = $paiement->update_date($datepaye);
if ($res === 0) {
$mesg = '<div class="ok">'.$langs->trans('PaymentDateUpdateSucceeded').'</div>';
} else {
$mesg = '<div class="error">'.$langs->trans('PaymentDateUpdateFailed').'</div>';
}
}
print '<table class="border" width="100%">';
print '<tr>';
print '<td valign="top" width="20%" colspan="2">'.$langs->trans('Ref').'</td><td colspan="3">'.$paiement->id.'</td></tr>';
//switch through edition options for date (only available when statut is -not 1- (=validated))
if (empty($_GET['action']) || $_GET['action']!='edit_date')
{
print '<tr><td colspan="2">';
print '<table class="nobordernopadding" width="100%"><tr><td nowrap="nowrap">';
print $langs->trans('Date');
print '</td>';
if ($paiement->statut == 0 && $_GET['action'] != 'edit_date') print '<td align="right"><a href="'.DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$paiement->id.'&action=edit_date">'.img_edit($langs->trans('Modify')).'</a></td>';
print '</tr></table>';
print '</td>';
print '<td colspan="3">'.dol_print_date($paiement->date,'day').'</td></tr>';
}
else
{
print '<tr>';
print '<td valign="top" colspan="2">'.$langs->trans('Date').'</td>';
print '<td colspan="3">';
print '<form name="formsoc" method="post" action="'.DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$paiement->id.'"><input type="hidden" name="action" value="update_date" />';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
if (!empty($_POST['remonth']) && !empty($_POST['reday']) && !empty($_POST['reyear']))
$sel_date=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
else
$sel_date=$paiement->date;
$html->select_date($sel_date,'','','','',"addpaiement");
print '<input type="submit" class="button" name="submit" value="'.$langs->trans('Validate').'" />';
print '</form>';
print '</td>';
print '</tr>';
}
// Date payment
print '<tr><td valign="top" colspan="2">'.$html->editfieldkey("Date",'date',$paiement->date,'id',$paiement->id,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td colspan="3">';
print $html->editfieldval("Date",'date',$paiement->date,'id',$paiement->id,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer,'day');
print '</td></tr>';
print '<tr><td valign="top" colspan="2">'.$langs->trans('Type').'</td><td colspan="3">'.$paiement->type_libelle.'</td></tr>';
// Payment mode
print '<tr><td valign="top" colspan="2">'.$langs->trans('PaymentMode').'</td><td colspan="3">'.$paiement->type_libelle.'</td></tr>';
//switch through edition options for number (only available when statut is -not 1- (=validated))
if (empty($_GET['action']) || $_GET['action'] != 'edit_num')
{
print '<tr><td colspan="2">';
print '<table class="nobordernopadding" width="100%"><tr><td nowrap="nowrap">';
print $langs->trans('Numero');
print '</td>';
if ($paiement->statut == 0 && $_GET['action'] != 'edit_num') print '<td align="right"><a href="'.DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$paiement->id.'&action=edit_num">'.img_edit($langs->trans('Modify')).'</a></td>';
print '</tr></table>';
print '</td>';
print '<td colspan="3">'.$paiement->numero.'</td></tr>';
}
else
{
print '<tr>';
print '<td valign="top" colspan="2">'.$langs->trans('Numero').'</td>';
print '<td colspan="3">';
print '<form name="formsoc" method="post" action="'.DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$paiement->id.'"><input type="hidden" name="action" value="update_num" />';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
if (!empty($_POST['new_num']))
$num = $this->db->escape($_POST['new_num']);
else
$num = $paiement->numero;
print '<input type="text" name="new_num" value="'.$num.'"/>';
print '<input type="submit" class="button" name="submit" value="'.$langs->trans('Validate').'" />';
print '</form></td>';
print '</tr>';
}
// Payment numero
print '<tr><td valign="top" colspan="2">'.$html->editfieldkey("Numero",'num',$paiement->numero,'id',$paiement->id,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td colspan="3">';
print $html->editfieldval("Numero",'num',$paiement->numero,'id',$paiement->id,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer,'string');
print '</td></tr>';
// Amount
print '<tr><td valign="top" colspan="2">'.$langs->trans('Amount').'</td><td colspan="3">'.price($paiement->montant).'&nbsp;'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
if ($conf->global->BILL_ADD_PAYMENT_VALIDATION)
@ -223,7 +202,10 @@ if ($result > 0)
print '<tr><td valign="top" colspan="2">'.$langs->trans('Status').'</td><td colspan="3">'.$paiement->getLibStatut(4).'</td></tr>';
}
print '<tr><td valign="top" colspan="2">'.$langs->trans('Note').'</td><td colspan="3">'.nl2br($paiement->note).'</td></tr>';
// Note
print '<tr><td valign="top"" colspan="2">'.$html->editfieldkey("Note",'note',$paiement->note,'id',$paiement->id,$user->rights->fournisseur->facture->creer).'</td><td colspan="3">';
print $html->editfieldval("Note",'note',$paiement->note,'id',$paiement->id,$user->rights->fournisseur->facture->creer,'text');
print '</td></tr>';
// Bank account
if ($conf->banque->enabled)
@ -244,7 +226,7 @@ if ($result > 0)
print '</table>';
if ($mesg) print '<br>'.$mesg;
dol_htmloutput_mesg($mesg);
print '<br>';

View File

@ -88,17 +88,15 @@ if ($fourn_id)
}
$sql = "SELECT p.rowid, p.label, p.ref, p.fk_product_type,";
$sql .= " pf.fk_soc, pf.ref_fourn,";
$sql .= " ppf.price as price, ppf.quantity as qty, ppf.unitprice,";
$sql .= " ppf.fk_soc, ppf.ref_fourn, ppf.price as price, ppf.quantity as qty, ppf.unitprice,";
$sql .= " s.rowid as socid, s.nom";
$sql .= " FROM ".MAIN_DB_PREFIX."product as p";
if ($catid)
{
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
}
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur as pf ON p.rowid = pf.fk_product";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = pf.fk_soc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as ppf ON ppf.fk_product_fournisseur = pf.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as ppf ON p.rowid = ppf.fk_product";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ppf.fk_soc = s.rowid";
if ($_POST["mode"] == 'search')
{
@ -118,7 +116,7 @@ else
}
if ($sRefSupplier)
{
$sql .= " AND pf.ref_fourn like '%".$sRefSupplier."%'";
$sql .= " AND ppf.ref_fourn like '%".$sRefSupplier."%'";
}
if ($snom)
{
@ -128,11 +126,10 @@ else
{
$sql .= " AND cp.fk_categorie = ".$catid;
}
}
if ($fourn_id > 0)
{
$sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id;
$sql .= " AND ppf.fk_soc = ".$fourn_id;
}
$sql .= " ORDER BY ".$sortfield." ".$sortorder;
$sql .= $db->plimit($limit + 1 ,$offset);

View File

@ -106,13 +106,6 @@ $pos = strstr ($uri, '/'); // $pos contient alors url sans nom domaine
if ($pos == '/') $pos = ''; // si $pos vaut /, on le met a ''
define('DOL_URL_ROOT', $pos);
/*
$conf->syslog->enabled=1;
define('SYSLOG_FILE','c:/log/dolibarr/dolibarr.log');
require_once("../../../../../../lib/functions.lib.php");
dol_syslog("eee".$conf->fckeditor->dir_output);
*/
// SECURITY: You must explicitelly enable this "connector". (Set it to "true").
$Config['Enabled'] = true ;

View File

@ -451,14 +451,14 @@ class doc_generic_invoice_odt extends ModelePDFFactures
try
{
$listlines = $odfHandler->setSegment('lines');
//var_dump($object->lines);exit;
foreach ($object->lines as $line)
{
$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
foreach($tmparray as $key => $val)
{
try {
$listlines->setVars($key, $val);
try
{
$listlines->setVars($key, $val, true, 'UTF-8');
}
catch(OdfException $e)
{

View File

@ -28,7 +28,7 @@ include_once(DOL_DOCUMENT_ROOT ."/includes/modules/DolibarrModules.class.php");
/**
* \class modSyslog
* \brief Classe de description et activation du module Syslog
* \brief Class to enable/disable module Logs
*/
class modSyslog extends DolibarrModules
{

View File

@ -200,9 +200,10 @@ if (constant('DOL_DATA_ROOT') && file_exists($lockfile))
}
// Forcage du log pour les install et mises a jour
// Force usage of log file for install and upgrades
$conf->syslog->enabled=1;
$conf->global->SYSLOG_LEVEL=constant('LOG_DEBUG');
if (! defined('SYSLOG_FILE_ON')) define('SYSLOG_FILE_ON',1);
if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined
{
if (@is_writable('/tmp')) define('SYSLOG_FILE','/tmp/dolibarr_install.log');
@ -212,10 +213,7 @@ if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant alrea
else if (@is_writable('../../')) define('SYSLOG_FILE','../../dolibarr_install.log'); // For others
//print 'SYSLOG_FILE='.SYSLOG_FILE;exit;
}
if (! defined('SYSLOG_FILE_NO_ERROR'))
{
define('SYSLOG_FILE_NO_ERROR',1);
}
if (! defined('SYSLOG_FILE_NO_ERROR')) define('SYSLOG_FILE_NO_ERROR',1);
// Removed magic_quotes
if (function_exists('get_magic_quotes_gpc')) // magic_quotes_* removed in PHP6
@ -285,9 +283,10 @@ function conf($dolibarr_main_document_root)
if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey='';
$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
// Forcage du log pour les install et mises a jour
// Force usage of log file for install and upgrades
$conf->syslog->enabled=1;
$conf->global->SYSLOG_LEVEL=constant('LOG_DEBUG');
if (! defined('SYSLOG_FILE_ON')) define('SYSLOG_FILE_ON',1);
if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined
{
if (@is_writable('/tmp')) define('SYSLOG_FILE','/tmp/dolibarr_install.log');
@ -297,10 +296,7 @@ function conf($dolibarr_main_document_root)
else if (@is_writable('../../')) define('SYSLOG_FILE','../../dolibarr_install.log'); // For others
//print 'SYSLOG_FILE='.SYSLOG_FILE;exit;
}
if (! defined('SYSLOG_FILE_NO_ERROR'))
{
define('SYSLOG_FILE_NO_ERROR',1);
}
if (! defined('SYSLOG_FILE_NO_ERROR')) define('SYSLOG_FILE_NO_ERROR',1);
return 1;
}

View File

@ -48,3 +48,20 @@ INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active)
INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active) VALUES (220, 'CAP5', 'Format Canadian P5', '140', '215', 'mm', 1);
INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active) VALUES (225, 'CAP6', 'Format Canadian P6', '107', '140', 'mm', 1);
ALTER TABLE llx_product_fournisseur_price ADD COLUMN fk_product integer after tms;
ALTER TABLE llx_product_fournisseur_price ADD COLUMN fk_soc integer after fk_product;
ALTER TABLE llx_product_fournisseur_price ADD COLUMN ref_fourn varchar(30) after fk_soc;
ALTER TABLE llx_product_fournisseur_price ADD COLUMN entity integer DEFAULT 1 NOT NULL;
UPDATE llx_product_fournisseur_price as a, llx_product_fournisseur as b SET a.fk_product = b.fk_product, a.fk_soc = b.fk_soc, a.ref_fourn = b.ref_fourn, a.entity = b.entity WHERE a.fk_product_fournisseur = b.rowid AND (a.fk_product IS NULL OR a.fk_soc IS NULL OR a.fk_product = 0 OR a.fk_soc = 0);
ALTER TABLE llx_product_fournisseur_price DROP INDEX uk_product_fournisseur_price_ref;
ALTER TABLE llx_product_fournisseur_price ADD UNIQUE INDEX uk_product_fournisseur_price_ref (ref_fourn, fk_soc, quantity, entity);
ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fourn_price_fk_product (fk_product, entity);
ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fourn_price_fk_soc (fk_soc, entity);
ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid);
ALTER TABLE llx_product_fournisseur_price DROP FOREIGN KEY fk_product_fournisseur_price_fk_product_fournisseur;

View File

@ -1,27 +0,0 @@
-- ============================================================================
-- Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.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 2 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_product_fournisseur ADD UNIQUE INDEX uk_product_fournisseur_ref (ref_fourn, fk_soc, entity);
ALTER TABLE llx_product_fournisseur ADD INDEX idx_product_fourn_fk_product (fk_product, entity);
ALTER TABLE llx_product_fournisseur ADD INDEX idx_product_fourn_fk_soc (fk_soc, entity);
ALTER TABLE llx_product_fournisseur ADD CONSTRAINT fk_product_fournisseur_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid);

View File

@ -1,39 +0,0 @@
-- ============================================================================
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2009 Regis Houssin <regis@dolibarr.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 2 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_product_fournisseur
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
datec datetime,
tms timestamp,
fk_product integer,
fk_soc integer,
ref_fourn varchar(30),
entity integer DEFAULT 1 NOT NULL, -- multi company id
fk_user_author integer
)ENGINE=innodb;
--
-- List of codes for the field entity
--
-- 1 : first company product
-- 2 : second company product
-- 3 : etc...
--

View File

@ -19,9 +19,16 @@
ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fournisseur_price_fk_user (fk_user);
ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fournisseur_price_fk_product_fournisseur (fk_product_fournisseur);
--ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fournisseur_price_fk_product_fournisseur (fk_product_fournisseur);
ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_fk_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid);
ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_fk_product_fournisseur FOREIGN KEY (fk_product_fournisseur) REFERENCES llx_product_fournisseur (rowid);
--ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_fk_product_fournisseur FOREIGN KEY (fk_product_fournisseur) REFERENCES llx_product_fournisseur (rowid);
-- Added to remove table llx_product_fournisseur
ALTER TABLE llx_product_fournisseur_price ADD UNIQUE INDEX uk_product_fournisseur_price_ref (ref_fourn, fk_soc, quantity, entity);
ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fourn_price_fk_product (fk_product, entity);
ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fourn_price_fk_soc (fk_soc, entity);
ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid);

View File

@ -22,11 +22,14 @@ create table llx_product_fournisseur_price
rowid integer AUTO_INCREMENT PRIMARY KEY,
datec datetime,
tms timestamp,
fk_product_fournisseur integer NOT NULL,
fk_product_fournisseur integer NOT NULL, -- deprecated
fk_product integer,
fk_soc integer,
ref_fourn varchar(30),
fk_availability integer,
price double(24,8) DEFAULT 0,
quantity double,
unitprice double(24,8) DEFAULT 0,
fk_user integer
fk_user integer,
entity integer DEFAULT 1 NOT NULL, -- multi company id
)ENGINE=innodb;

View File

@ -339,7 +339,7 @@ Module30Desc=Gestió de factures i abonaments de clients. Gestió factures de pr
Module40Name=Proveïdors
Module40Desc=Gestió de proveïdors
Module42Name=Syslog
Module42Desc=Utilització de logs (syslog)
Module42Desc=Generació de logs (arxius, syslog,...)
Module49Name=Editors
Module49Desc=Gestió d'editors
Module50Name=Productes

View File

@ -338,8 +338,8 @@ Module30Name=Invoices
Module30Desc=Invoices and credit note's management for customers. Invoice's management for suppliers
Module40Name=Suppliers
Module40Desc=Supplier's management and buying (orders and invoices)
Module42Name=Syslog
Module42Desc=Logging facilities (syslog)
Module42Name=Logs
Module42Desc=Logging facilities (file, syslog, ...)
Module49Name=Editors
Module49Desc=Editor's management
Module50Name=Products
@ -1112,15 +1112,15 @@ UseEcoTaxeAbility=Support Eco-Taxe (WEEE)
SetDefaultBarcodeTypeProducts=Default barcode type to use for products
SetDefaultBarcodeTypeThirdParties=Default barcode type to use for third parties
##### Syslog #####
SyslogSetup=Syslog module setup
SyslogOutput=Log output
SyslogSetup=Logs module setup
SyslogOutput=Logs outputs
SyslogSyslog=Syslog
SyslogFacility=Facility
SyslogLevel=Level
SyslogSimpleFile=File
SyslogFilename=File name and path
YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file.
ErrorUnknownSyslogConstant=Constant %s is not a known syslog constant
ErrorUnknownSyslogConstant=Constant %s is not a known Syslog constant
##### Donations #####
DonationsSetup=Donation module setup
DonationsReceiptModel=Template of donation receipt

View File

@ -339,7 +339,7 @@ Module30Desc=Gestión de facturas y abonos a clientes. Gestión facturas de prov
Module40Name=Proveedores
Module40Desc=Gestión de proveedores
Module42Name=Syslog
Module42Desc=Utilización de logs (syslog)
Module42Desc=Generación de logs (archivos, syslog,...)
Module49Name=Editores
Module49Desc=Gestión de editores
Module50Name=Productos

View File

@ -49,7 +49,7 @@ ConfirmAjax= Utiliser les popups de confirmation Ajax
UseSearchToSelectCompany= Utiliser un champ avec autocomplétion pour choisir un tiers (plutôt qu'une liste déroulante).<br><br>Notez que si vous avez un nombre important de produits ou services (> 100 000), vous pouvez améliorer les performances en définissant la constante SOCIETE_DONOTSEARCH_ANYWHERE à 1 dans Configuration->Divers. La recherche sera alors limitée au début de la chaine.
ActivityStateToSelectCompany= Ajouter une option de filtrage lors des recherches pour afficher/masquer les tiers en exercice ou ayant cessés d'exercer
SearchFilter=Options des filtres de recherche
NumberOfKeyToSearch=Nb caractères déclenchant la recherche: %s
NumberOfKeyToSearch=Nb carac. déclenchant recherche: %s
ViewFullDateActions= Visualiser les dates des actions en entier dans la fiche tiers
NotAvailableWhenAjaxDisabled= Non disponible quand Ajax désactivé
JavascriptDisabled= Javascript désactivé
@ -128,7 +128,7 @@ SystemTools= Outils Système
SystemToolsArea= Espace outils systèmes
SystemToolsAreaDesc= Cet espace offre des fonctions d'administration diverses. Utilisez le menu pour choisir la fonctionnalité recherchée.
PurgeAreaDesc= Cette page vous permet d'effacer tous les fichiers construits ou stockés par Dolibarr (fichiers temporaires ou tous les fichiers du répertoire <b>%s</b>). L'utilisation de cette fonction n'est pas nécessaire. Elle est fournie pour les utilisateurs qui hébergent Dolibarr chez un hébergeur qui n'offre pas les permissions de supprimer les fichiers sauvegardés par le serveur Web.
PurgeDeleteLogFile= Effacer le fichier log <b>%s</b> défini pour le module Syslog (pas de risque de perte de données)
PurgeDeleteLogFile= Effacer le fichier log <b>%s</b> défini pour le module 'Logs et traces' (pas de risque de perte de données)
PurgeDeleteTemporaryFiles= Effacer tous les fichiers temporaires (pas de risque de perte de données)
PurgeDeleteAllFilesInDocumentsDir= Effacer tous les fichiers du répertoire <b>%s</b>. Les fichiers temporaires mais aussi les fichiers dumps de sauvegardes de bases, les fichiers joints aux éléments (tiers, factures, ...) ou fichiers stockés dans le module GED seront irrémédiablement effacés.
PurgeRunNow= Lancer la purge maintenant
@ -339,8 +339,8 @@ Module30Name= Factures et avoirs
Module30Desc= Gestion des factures et avoirs clients. Gestion des factures fournisseurs
Module40Name= Fournisseurs
Module40Desc= Gestion des fournisseurs et achats (commandes et factures)
Module42Name= Syslog
Module42Desc= Utilisation de logs (syslog)
Module42Name= Logs et traces
Module42Desc= Génération de logs (fichiers, syslog, ...)
Module49Name= Éditeurs
Module49Desc= Gestion des éditeurs
Module50Name= Produits
@ -1120,7 +1120,7 @@ UseEcoTaxeAbility= Prise en charge des éco-taxes (DEEE)
SetDefaultBarcodeTypeProducts= Type de code-barres utilisé par défaut pour les produits
SetDefaultBarcodeTypeThirdParties= Type de code-barres utilisé par défaut pour les tiers
##### Syslog #####
SyslogSetup= Configuration du module Syslog
SyslogSetup= Configuration du module Logs et traces
SyslogOutput= Sortie des log
SyslogSyslog= Syslog
SyslogFacility= Facility

View File

@ -19,9 +19,16 @@
/**
* \file htdocs/lib/fourn.lib.php
* \brief Ensemble de fonctions de base pour le module fournisseur
* \brief Functions used by supplier invoice module
* \ingroup supplier
*/
/**
* Initialize the array of tabs for supplier invoice
*
* @param Facture $object Invoice object
* @return array Array of head tabs
*/
function facturefourn_prepare_head($object)
{
global $langs, $conf;
@ -29,7 +36,7 @@ function facturefourn_prepare_head($object)
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$object->id;
$head[$h][1] = $langs->trans('Card');
$head[$h][1] = $langs->trans('CardBill');
$head[$h][2] = 'card';
$h++;

View File

@ -371,20 +371,22 @@ function dol_escape_htmltag($stringtoescape,$keepb=0)
}
/**
* Write log message in a file or to syslog process
* Pour fichier: fichier defined by SYSLOG_FILE
* Pour syslog: facility defined by SYSLOG_FACILITY
* Write log message into outputs. Possible outputs can be:
* A file if SYSLOG_FILE_ON defined: file name is then defined by SYSLOG_FILE
* Syslog if SYSLOG_SYSLOG_ON defined: facility is then defined by SYSLOG_FACILITY
* Warning, les fonctions syslog sont buggues sous Windows et generent des
* fautes de protection memoire. Pour resoudre, utiliser le loggage fichier,
* au lieu du loggage syslog (configuration du module).
* Si SYSLOG_FILE_NO_ERROR defini, on ne gere pas erreur ecriture log
* This function works only if syslog module is enabled.
* This must must not use any call to other function calling dol_syslog (avoid infinite loop).
* On Windows LOG_ERR=4, LOG_WARNING=5, LOG_NOTICE=LOG_INFO=6, LOG_DEBUG=6 si define_syslog_variables ou PHP 5.3+, 7 si dolibarr
* On Linux LOG_ERR=3, LOG_WARNING=4, LOG_INFO=6, LOG_DEBUG=7
* Note: If SYSLOG_FILE_NO_ERROR defined, we never output error message when writing to log fails.
*
* @param string $message Line to log. Ne doit pas etre traduit si level = LOG_ERR
* @param int $level Log level
* This function works only if syslog module is enabled.
* This must not use any call to other function calling dol_syslog (avoid infinite loop).
*
* @param string $message Line to log. Ne doit pas etre traduit si level = LOG_ERR
* @param int $level Log level
* On Windows LOG_ERR=4, LOG_WARNING=5, LOG_NOTICE=LOG_INFO=6, LOG_DEBUG=6 si define_syslog_variables ou PHP 5.3+, 7 si dolibarr
* On Linux LOG_ERR=3, LOG_WARNING=4, LOG_INFO=6, LOG_DEBUG=7
* @return void
*/
function dol_syslog($message, $level=LOG_INFO)
{
@ -421,8 +423,8 @@ function dol_syslog($message, $level=LOG_INFO)
if (is_object($user) && $user->id) $login=$user->login;
$message=sprintf("%-8s",$login)." ".$message;
// Check if log is to a file (SYSLOG_FILE defined) or to syslog
if (defined("SYSLOG_FILE") && SYSLOG_FILE)
// Check if log is to a file (SYSLOG_FILE_ON defined)
if (defined("SYSLOG_FILE_ON") && constant("SYSLOG_FILE_ON"))
{
$filelog=SYSLOG_FILE;
$filelog=preg_replace('/DOL_DATA_ROOT/i',DOL_DATA_ROOT,$filelog);
@ -458,36 +460,48 @@ function dol_syslog($message, $level=LOG_INFO)
}
elseif (! defined("SYSLOG_FILE_NO_ERROR"))
{
// Do not use call to functions that make call to dol_syslog, so no call to langs.
// Do not use here a call to functions that make call to dol_syslog so making call to langs. A simple print is enough.
print "Error, failed to open file ".$filelog."\n";
}
}
else
// Check if log is to syslog (SYSLOG_SYSLOG_ON defined)
if (defined("SYSLOG_SYSLOG_ON") && constant("SYSLOG_SYSLOG_ON"))
{
if (function_exists('openlog')) // This function does not exists on some ISP (Ex: Free in France)
{
$facility = LOG_USER;
if (defined("SYSLOG_FACILITY") && SYSLOG_FACILITY)
if (defined("SYSLOG_FACILITY") && constant("SYSLOG_FACILITY"))
{
// Exemple: SYSLOG_FACILITY vaut LOG_USER qui vaut 8. On a besoin de 8 dans $facility.
$facility = constant("SYSLOG_FACILITY");
}
openlog("dolibarr", LOG_PID | LOG_PERROR, (int) $facility); // (int) is required to avoid error parameter 3 expected to be long
if (! $level)
{
syslog(LOG_ERR, $message);
}
else
{
syslog($level, $message);
}
if (! $level) syslog(LOG_ERR, $message);
else syslog($level, $message);
closelog();
}
}
// Check if log is to syslog (SYSLOG_FIREPHP_ON defined)
if (defined("SYSLOG_FIREPHP_ON") && constant("SYSLOG_FIREPHP_ON"))
{
try
{
// Warning FirePHPCore must be into PHP include path. It is not possible to use into require_once() a constant from
// database or config file because we must be able to log data before database or config file read.
set_include_path('/usr/share/php/');
require_once('FirePHPCore/FirePHP.class.php');
restore_include_path();
ob_start();
$firephp = FirePHP::getInstance(true);
$firephp->log($message);
}
catch(Exception $e)
{
}
}
}
}
@ -609,18 +623,19 @@ function dolibarr_print_date($time,$format='',$to_gmt=false,$outputlangs='',$enc
* Output date in a string format according to outputlangs (or langs if not defined).
* Return charset is always UTF-8, except if encodetoouput is defined. In this cas charset is output charset
*
* @param time GM Timestamps date (or deprecated strings 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS')
* @param format Output date format
* "%d %b %Y",
* "%d/%m/%Y %H:%M",
* "%d/%m/%Y %H:%M:%S",
* "day", "daytext", "dayhour", "dayhourldap", "dayhourtext"
* @param tzoutput true=output or 'gmt' => string is for Greenwich location
* false or 'tzserver' => output string is for local PHP server TZ usage
* 'tzuser' => output string is for local browser TZ usage
* @param outputlangs Object lang that contains language for text translation.
* @param encodetooutput false=no convert into output pagecode
* @return string Formated date or '' if time is null
* @param timestamp $time GM Timestamps date (or deprecated strings 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS')
* @param string $format Output date format
* "%d %b %Y",
* "%d/%m/%Y %H:%M",
* "%d/%m/%Y %H:%M:%S",
* "day", "daytext", "dayhour", "dayhourldap", "dayhourtext"
* @param string $tzoutput true=output or 'gmt' => string is for Greenwich location
* false or 'tzserver' => output string is for local PHP server TZ usage
* 'tzuser' => output string is for local browser TZ usage
* @param Tranlsate $outputlangs Object lang that contains language for text translation.
* @param boolean $encodetooutput false=no convert into output pagecode
* @return string Formated date or '' if time is null
*
* @see dol_mktime, dol_stringtotime, dol_getdate
*/
function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$encodetooutput=false)
@ -756,15 +771,16 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e
/**
* Convert a string date into a GM Timestamps date
*
* @param string Date in a string
* YYYYMMDD
* @param string $string Date in a string
* YYYYMMDD
* YYYYMMDDHHMMSS
* YYYY-MM-DDTHH:MM:SSZ (RFC3339)
* DD/MM/YY or DD/MM/YYYY (this format should not be used anymore)
* DD/MM/YY HH:MM:SS or DD/MM/YYYY HH:MM:SS (this format should not be used anymore)
* 19700101020000 -> 7200
* @param gm 1=Input date is GM date, 0=Input date is local date
* @return date Date
* @param int $gm 1=Input date is GM date, 0=Input date is local date
* @return date Date
*
* @see dol_print_date, dol_mktime, dol_getdate
*/
function dol_stringtotime($string, $gm=1)
@ -808,30 +824,30 @@ function dol_stringtotime($string, $gm=1)
* Return an array with date info
* PHP getdate is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows
*
* @param timestamp Timestamp
* @param fast Fast mode
* @return array Array of informations
* If no fast mode:
* 'seconds' => $secs,
* 'minutes' => $min,
* 'hours' => $hour,
* 'mday' => $day,
* 'wday' => $dow,
* 'mon' => $month,
* 'year' => $year,
* 'yday' => floor($secsInYear/$_day_power),
* 'weekday' => gmdate('l',$_day_power*(3+$dow)),
* 'month' => gmdate('F',mktime(0,0,0,$month,2,1971)),
* If fast mode:
* 'seconds' => $secs,
* 'minutes' => $min,
* 'hours' => $hour,
* 'mday' => $day,
* 'mon' => $month,
* 'year' => $year,
* 'yday' => floor($secsInYear/$_day_power),
* 'leap' => $leaf,
* 'ndays' => $ndays
* @param timestamp $timestamp Timestamp
* @param boolean $fast Fast mode
* @return array Array of informations
* If no fast mode:
* 'seconds' => $secs,
* 'minutes' => $min,
* 'hours' => $hour,
* 'mday' => $day,
* 'wday' => $dow,
* 'mon' => $month,
* 'year' => $year,
* 'yday' => floor($secsInYear/$_day_power),
* 'weekday' => gmdate('l',$_day_power*(3+$dow)),
* 'month' => gmdate('F',mktime(0,0,0,$month,2,1971)),
* If fast mode:
* 'seconds' => $secs,
* 'minutes' => $min,
* 'hours' => $hour,
* 'mday' => $day,
* 'mon' => $month,
* 'year' => $year,
* 'yday' => floor($secsInYear/$_day_power),
* 'leap' => $leaf,
* 'ndays' => $ndays
*/
function dol_getdate($timestamp,$fast=false)
{
@ -1069,13 +1085,13 @@ function dolibarr_print_phone($phone,$country="FR",$cid=0,$socid=0,$addlink=0,$s
/**
* Format phone numbers according to country
*
* @param phone Phone number to format
* @param country Country to use for formatting
* @param cid Id of contact if known
* @param socid Id of third party if known
* @param addlink 0=no link to create action
* @param separ separation between numbers for a better visibility example : xx.xx.xx.xx.xx
* @return string Formated phone number
* @param string $phone Phone number to format
* @param string $country Country code to use for formatting
* @param int $cid Id of contact if known
* @param int $socid Id of third party if known
* @param int $addlink 0=no link to create action
* @param string $separ separation between numbers for a better visibility example : xx.xx.xx.xx.xx
* @return string Formated phone number
*/
function dol_print_phone($phone,$country="FR",$cid=0,$socid=0,$addlink=0,$separ="&nbsp;")
{
@ -1148,9 +1164,9 @@ function dol_print_phone($phone,$country="FR",$cid=0,$socid=0,$addlink=0,$separ=
/**
* Return an IP formated to be shown on screen
*
* @param ip IP
* @param mode 1=return only country/flag,2=return only IP
* @return string Formated IP, with country if GeoIP module is enabled
* @param string $ip IP
* @param int $mode 1=return only country/flag,2=return only IP
* @return string Formated IP, with country if GeoIP module is enabled
*/
function dol_print_ip($ip,$mode=0)
{
@ -1188,7 +1204,7 @@ function dol_print_ip($ip,$mode=0)
* Return country code for current user.
* If software is used inside a local network, detection may fails (we need a public ip)
*
* @return string country code (fr, es, it, us, ...)
* @return string Country code (fr, es, it, us, ...)
*/
function dol_user_country()
{
@ -1213,11 +1229,11 @@ function dol_user_country()
/**
* Format address string
*
* @param address Address
* @param htmlid Html ID
* @param mode thirdparty|contact|member|other
* @param id Id of object
* @param address Address string
* @param string $address Address
* @param int $htmlid Html ID
* @param int $mode thirdparty|contact|member|other
* @param int $id Id of object
* @return void
*/
function dol_print_address($address, $htmlid='gmap', $mode, $id)
{
@ -1308,13 +1324,13 @@ function dol_strlen($string,$stringencoding='UTF-8')
}
/**
* Make a substring. Works even in mbstring module not enabled
* Make a substring. Works even in mbstring module is not enabled.
*
* @param $string
* @param $start
* @param $length
* @param $stringencoding
* @return string
* @param string $string String to scan
* @param string $start Start position
* @param int $length Length
* @param string $stringencoding Page code used for input string encoding
* @return string substring
*/
function dol_substr($string,$start,$length,$stringencoding='')
{
@ -2747,6 +2763,7 @@ function load_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath
* @param totalnboflines Total number of records/lines for all pages (if known)
* @param picto Icon to use before title (should be a 32x32 transparent png file)
* @param pictoisfullpath 1=Icon name is a full absolute url of image
* @return void
*/
function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=0, $picto='title.png', $pictoisfullpath=0)
{
@ -2846,11 +2863,12 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so
/**
* Fonction servant a afficher les fleches de navigation dans les pages de listes
*
* @param page Numero of page
* @param file Lien
* @param options Autres parametres d'url a propager dans les liens ("" par defaut)
* @param nextpage Faut-il une page suivante
* @param betweenarrows HTML Content to show between arrows
* @param int $page Numero of page
* @param string $file Lien
* @param string $options Autres parametres d'url a propager dans les liens ("" par defaut)
* @param int $nextpage Faut-il une page suivante
* @param string $betweenarrows HTML Content to show between arrows
* @return void
*/
function print_fleche_navigation($page,$file,$options='',$nextpage,$betweenarrows='')
{
@ -2871,10 +2889,10 @@ function print_fleche_navigation($page,$file,$options='',$nextpage,$betweenarrow
* Fonction qui retourne un taux de tva formate pour visualisation
* Utilisee dans les pdf et les pages html
*
* @param rate Rate value to format (19.6 19,6 19.6% 19,6%,...)
* @param addpercent Add a percent % sign in output
* @param info_bits Miscellanous information on vat
* @return string Chaine avec montant formate (19,6 ou 19,6% ou 8.5% *)
* @param float $rate Rate value to format (19.6 19,6 19.6% 19,6%,...)
* @param boolean $addpercent Add a percent % sign in output
* @param int $info_bits Miscellanous information on vat
* @return string Chaine avec montant formate (19,6 ou 19,6% ou 8.5% *)
*/
function vatrate($rate,$addpercent=false,$info_bits=0)
{
@ -2900,14 +2918,15 @@ function vatrate($rate,$addpercent=false,$info_bits=0)
* Fonction qui formate un montant pour visualisation
* Fonction utilisee dans les pdf et les pages html
*
* @param amount Montant a formater
* @param html Type de formatage, html ou pas (par defaut)
* @param outlangs Objet langs pour formatage text
* @param trunc 1=Tronque affichage si trop de decimales,0=Force le non troncage
* @param rounding Minimum number of decimal. If not defined we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOTAL)
* @param forcerounding Force the number of decimal
* @return string Chaine avec montant formate
* @see price2num Revert function of price
* @param float $amount Montant a formater
* @param string $html Type de formatage, html ou pas (par defaut)
* @param Translate $outlangs Objet langs pour formatage text
* @param int $trunc 1=Tronque affichage si trop de decimales,0=Force le non troncage
* @param int $rounding Minimum number of decimal. If not defined we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOTAL)
* @param int $forcerounding Force the number of decimal
* @return string Chaine avec montant formate
*
* @see price2num Revert function of price
*/
function price($amount, $html=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1)
{
@ -2974,14 +2993,15 @@ function price($amount, $html=0, $outlangs='', $trunc=1, $rounding=-1, $forcerou
* an amount typed by a user.
* Function to use on each input amount before any numeric test or database insert
*
* @param amount Amount to convert/clean
* @param rounding ''=No rounding
* @param float $amount Amount to convert/clean
* @param string $rounding ''=No rounding
* 'MU'=Round to Max unit price (MAIN_MAX_DECIMALS_UNIT)
* 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT)
* 'MS'=Round to Max Shown (MAIN_MAX_DECIMALS_SHOWN)
* @param alreadysqlnb Put 1 if you know that content is already universal format number
* @return string Amount with universal numeric format (Example: '99.99999')
* @see price Opposite function of price2num
* @param int $alreadysqlnb Put 1 if you know that content is already universal format number
* @return string Amount with universal numeric format (Example: '99.99999')
*
* @see price Opposite function of price2num
*/
function price2num($amount,$rounding='',$alreadysqlnb=0)
{
@ -3059,10 +3079,10 @@ function price2num($amount,$rounding='',$alreadysqlnb=0)
/**
* Return localtaxe rate for a particular tva
*
* @param tva Vat taxe
* @param local Local taxe to search and return
* @param societe_acheteuse Object of buying third party
* @return int 0 if not found, localtax if found
* @param float $tva Vat taxe
* @param int $local Local taxe to search and return
* @param Societe $societe_acheteuse Object of buying third party
* @return int 0 if not found, localtax if found
*/
function get_localtax($tva, $local, $societe_acheteuse="")
{
@ -3081,7 +3101,7 @@ function get_localtax($tva, $local, $societe_acheteuse="")
$sql = "SELECT t.localtax1, t.localtax2";
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
$sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$code_pays."'";
$sql .= " AND t.taux =".$tva." AND t.active = 1";
$sql .= " AND t.taux = ".$tva." AND t.active = 1";
$sql .= " ORDER BY t.localtax1 ASC, t.localtax2 ASC";
$resql=$db->query($sql);
@ -3099,9 +3119,9 @@ function get_localtax($tva, $local, $societe_acheteuse="")
* Return vat rate of a product in a particular selling country or default country
* vat if product is unknown
*
* @param idprod Id of product or 0 if not a predefined product
* @param countrycode Country code (FR, US, IT, ...)
* @return int <0 if KO, Vat rate if OK
* @param int $idprod Id of product or 0 if not a predefined product
* @param string $countrycode Country code (FR, US, IT, ...)
* @return int <0 if KO, Vat rate if OK
* TODO May be this should be better as a method of product class
*/
function get_product_vat_for_country($idprod, $countrycode)
@ -3689,9 +3709,9 @@ function dol_microtime_float()
/**
* Return if a text is a html content
*
* @param msg Content to check
* @param option 0=Full detection, 1=Fast check
* @return boolean true/false
* @param string $msg Content to check
* @param int $option 0=Full detection, 1=Fast check
* @return boolean true/false
*/
function dol_textishtml($msg,$option=0)
{
@ -3726,9 +3746,10 @@ function dol_textishtml($msg,$option=0)
* There is two type of substitions:
* - From $substitutionarray (oldval=>newval)
* - From special constants (__XXX__=>f(objet->xxx)) by substitutions modules
* @param chaine Source string in which we must do substitution
* @param substitutionarray Array with key->val to substitute
* @return string Output string after subsitutions
*
* @param string $chaine Source string in which we must do substitution
* @param array $substitutionarray Array with key->val to substitute
* @return string Output string after subsitutions
*/
function make_substitutions($chaine,$substitutionarray)
{
@ -3745,9 +3766,10 @@ function make_substitutions($chaine,$substitutionarray)
/**
* Complete the $substitutionarray with more entries
*
* @param substitutionarray Array substitution old value => new value value
* @param outputlangs If we want substitution from special constants, we provide a language
* @param object If we want substitution from special constants, we provide data in a source object
* @param array $substitutionarray Array substitution old value => new value value
* @param Translate $outputlangs If we want substitution from special constants, we provide a language
* @param Object $object If we want substitution from special constants, we provide data in a source object
* @return void
*/
function complete_substitutions_array(&$substitutionarray,$outputlangs,$object='')
{
@ -3785,10 +3807,11 @@ function complete_substitutions_array(&$substitutionarray,$outputlangs,$object='
* @param date_end End date
* @param format Output format
* @param outputlangs Output language
* @return void
*/
function print_date_range($date_start,$date_end,$format = '',$outputlangs='')
{
print get_date_range($date_start,$date_end,$format,$outputlangs);
print get_date_range($date_start,$date_end,$format,$outputlangs);
}
/**
@ -3798,6 +3821,7 @@ function print_date_range($date_start,$date_end,$format = '',$outputlangs='')
* @param date_end End date
* @param format Output format
* @param outputlangs Output language
* @return string String
*/
function get_date_range($date_start,$date_end,$format = '',$outputlangs='')
{
@ -3827,11 +3851,12 @@ function get_date_range($date_start,$date_end,$format = '',$outputlangs='')
/**
* Get formated messages to output (Used to show messages on html output).
*
* @param mesgstring Message string
* @param mesgarray Messages array
* @param style Style of message output ('ok' or 'error')
* @param keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify)
* @return string Return html output
* @param string $mesgstring Message string
* @param array $mesgarray Messages array
* @param string $style Style of message output ('ok' or 'error')
* @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify)
* @return string Return html output
*
* @see dol_print_error
* @see dol_htmloutput_errors
*/
@ -3924,10 +3949,11 @@ function get_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb
/**
* Get formated error messages to output (Used to show messages on html output).
*
* @param mesgstring Error message
* @param mesgarray Error messages array
* @param keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify)
* @return html Return html output
* @param string $mesgstring Error message
* @param array $mesgarray Error messages array
* @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify)
* @return string Return html output
*
* @see dol_print_error
* @see dol_htmloutput_mesg
*/
@ -3939,10 +3965,12 @@ function get_htmloutput_errors($mesgstring='', $mesgarray='', $keepembedded=0)
/**
* Print formated messages to output (Used to show messages on html output).
*
* @param mesgstring Message
* @param mesgarray Messages array
* @param style Which style to use ('ok', 'error')
* @param keepembedded Set to 1 if message must be kept embedded into its html place (this disable jnotify)
* @param string $mesgstring Message
* @param array $mesgarray Messages array
* @param string $style Which style to use ('ok', 'error')
* @param int $keepembedded Set to 1 if message must be kept embedded into its html place (this disable jnotify)
* @return void
*
* @see dol_print_error
* @see dol_htmloutput_errors
*/
@ -3988,9 +4016,11 @@ function dol_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb
/**
* Print formated error messages to output (Used to show messages on html output).
*
* @param mesgstring Error message
* @param mesgarray Error messages array
* @param keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify)
* @param string $mesgstring Error message
* @param array $mesgarray Error messages array
* @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify)
* @return void
*
* @see dol_print_error
* @see dol_htmloutput_mesg
*/
@ -4036,8 +4066,8 @@ function dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensiti
/**
* Check if a string is in UTF8
*
* @param $str String to check
* @return boolean True if string is UTF8 or ISO compatible with UTF8, False if not (ISO with special char or Binary)
* @param string $str String to check
* @return boolean True if string is UTF8 or ISO compatible with UTF8, False if not (ISO with special char or Binary)
*/
function utf8_check($str)
{
@ -4064,8 +4094,8 @@ function utf8_check($str)
* Return an UTF-8 string encoded into OS filesystem encoding. This function is used to define
* value to pass to filesystem PHP functions.
*
* @param string $str String to encode (UTF-8)
* @return string Encoded string (UTF-8, ISO-8859-1)
* @param string $str String to encode (UTF-8)
* @return string Encoded string (UTF-8, ISO-8859-1)
*/
function dol_osencode($str)
{
@ -4084,12 +4114,12 @@ function dol_osencode($str)
/**
* Return an id or code from a code or id. Store Code-Id in a cache.
*
* @param db Database handler
* @param key Code to get Id
* @param tablename Table name without prefix
* @param fieldkey Field for code
* @param fieldid Field for id
* @return int Id of code
* @param DoliDB $db Database handler
* @param string $key Code to get Id
* @param string $tablename Table name without prefix
* @param string $fieldkey Field for code
* @param string $fieldid Field for id
* @return int Id of code
*/
function dol_getIdFromCode($db,$key,$tablename,$fieldkey='code',$fieldid='id')
{
@ -4127,8 +4157,8 @@ function dol_getIdFromCode($db,$key,$tablename,$fieldkey='code',$fieldid='id')
/**
* Verify if condition in string is ok or not
*
* @param string $strRights
* @return boolean true or false
* @param string $strRights String with condition to check
* @return boolean true or false
*/
function verifCond($strRights)
{
@ -4156,6 +4186,7 @@ function verifCond($strRights)
* This function is called by verifCond()
*
* @param string $s
* @return void
*/
function dol_eval($s)
{
@ -4172,8 +4203,8 @@ function dol_eval($s)
/**
* Return img flag of country for a language code or country code
*
* @param codelang Language code (en_IN, fr_CA...) or Country code (IN, FR)
* @return string HTML img string with flag.
* @param string $codelang Language code (en_IN, fr_CA...) or Country code (IN, FR)
* @return string HTML img string with flag.
*/
function picto_from_langcode($codelang)
{

View File

@ -981,19 +981,15 @@ function dol_print_reduction($reduction=0,$langs)
/**
* Return OS version
* Return OS version.
* Note that PHP_OS returns only OS (not version) and OS PHP was built on, not
* necessarly OS PHP runs on.
*
* @return string OS version
*/
function version_os()
{
// Get version of OS
ob_start();
phpinfo();
$chaine = ob_get_contents();
ob_end_clean();
preg_match('/System <\/td><td class="v">([^<]*)<\/td>/i',$chaine,$reg);
$osversion=$reg[1];
$osversion=php_uname();
return $osversion;
}

View File

@ -18,10 +18,16 @@
/**
* \file htdocs/lib/invoice.lib.php
* \brief Ensemble de fonctions de base pour le module factures
* \brief Functions used by invoice module
* \ingroup invoice
*/
/**
* Initialize the array of tabs for customer invoice
*
* @param Facture $object Invoice object
* @return array Array of head tabs
*/
function facture_prepare_head($object)
{
global $langs, $conf;

View File

@ -28,7 +28,7 @@
* \brief File that defines environment for Dolibarr pages only (variables not required by scripts)
*/
@ini_set('memory_limit', '64M'); // This may be useless if memory is hard limited by your PHP
//@ini_set('memory_limit', '64M'); // This may be useless if memory is hard limited by your PHP
// For optionnal tuning. Enabled if environment variable DOL_TUNING is defined.
// A call first. Is the equivalent function dol_microtime_float not yet loaded.

View File

@ -21,6 +21,16 @@
* \ingroup paybox
* \brief Library for common paybox functions
*/
/**
* Show header
*
* @param string $title Title of page
* @param string $head Head string to add int head section
* @return void
*/
function llxHeaderPaybox($title, $head = "")
{
global $user, $conf, $langs;
@ -50,6 +60,11 @@ function llxHeaderPaybox($title, $head = "")
print '<body style="margin: 20px;">'."\n";
}
/**
* Show footer
*
* @return void
*/
function llxFooterPayBox()
{
print "</body>\n";
@ -60,13 +75,13 @@ function llxFooterPayBox()
/**
* Create a redirect form to paybox form
*
* @param $PRICE
* @param $CURRENCY
* @param $EMAIL
* @param $urlok
* @param $urlko
* @param $TAG
* @return int 1 if OK, -1 if ERROR
* @param int $PRICE Price
* @param string $CURRENCY Currency
* @param string $EMAIL EMail
* @param string $urlok Url to go back if payment is OK
* @param string $urlko Url to go back if payment is KO
* @param string $TAG Tag
* @return int 1 if OK, -1 if ERROR
*/
function print_paybox_redirect($PRICE,$CURRENCY,$EMAIL,$urlok,$urlko,$TAG)
{
@ -231,8 +246,9 @@ function print_paybox_redirect($PRICE,$CURRENCY,$EMAIL,$urlok,$urlko,$TAG)
/**
* Show footer of company in HTML pages
*
* @param $fromcompany
* @param $langs
* @param Societe $fromcompany Third party
* @param Translate $langs Output language
* @return void
*/
function html_print_paybox_footer($fromcompany,$langs)
{

View File

@ -23,7 +23,13 @@
*/
/**
* Show header
*
* @param string $title
* @param string $head
* @return void
*/
function llxHeaderPaypal($title, $head = "")
{
global $user, $conf, $langs;
@ -53,6 +59,11 @@ function llxHeaderPaypal($title, $head = "")
print '<body style="margin: 20px;">'."\n";
}
/**
* Show footer
*
* @return void
*/
function llxFooterPaypal()
{
print "</body>\n";
@ -63,8 +74,9 @@ function llxFooterPaypal()
/**
* Show footer of company in HTML pages
*
* @param $fromcompany
* @param $langs
* @param Societe $fromcompany Third party
* @param Translate $langs Output language
* @return void
*/
function html_print_paypal_footer($fromcompany,$langs)
{
@ -128,6 +140,7 @@ function html_print_paypal_footer($fromcompany,$langs)
/**
* Define head array for tabs of paypal tools setup pages
*
* @return Array of head
*/
function paypaladmin_prepare_head()
@ -250,12 +263,13 @@ function getPaypalPaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_f
/**
* Send redirect to paypal to browser
*
* @param $paymentAmount
* @param $currencyCodeType
* @param $paymentType
* @param $returnURL
* @param $cancelURL
* @param $tag
* @param float $paymentAmount Amount
* @param string $currencyCodeType Currency code
* @param string $paymentType Payment type
* @param string $returnURL Url to use if payment is OK
* @param string $cancelURL Url to use if payment is KO
* @param string $tag Tag
* @return void
*/
function print_paypal_redirect($paymentAmount,$currencyCodeType,$paymentType,$returnURL,$cancelURL,$tag)
{
@ -295,8 +309,24 @@ function print_paypal_redirect($paymentAmount,$currencyCodeType,$paymentType,$re
}
dol_syslog("expresscheckout redirect with CallSetExpressCheckout $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $landingPage, $solutionType, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum");
$resArray = CallSetExpressCheckout ($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $solutionType, $landingPage,
$shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum);
$resArray = CallSetExpressCheckout(
$paymentAmount,
$currencyCodeType,
$paymentType,
$returnURL,
$cancelURL,
$tag,
$solutionType,
$landingPage,
$shipToName,
$shipToStreet,
$shipToCity,
$shipToState,
$shipToCountryCode,
$shipToZip,
$shipToStreet2,
$phoneNum
);
/* For direct payment with credit card
{
//$resArray = DirectPayment (...);
@ -349,8 +379,7 @@ function print_paypal_redirect($paymentAmount,$currencyCodeType,$paymentType,$re
' phoneNum: the phoneNum entered on the merchant's site
'--------------------------------------------------------------------------------------------------------------------------------------------
*/
function CallSetExpressCheckout( $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $solutionType, $landingPage,
$shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum)
function CallSetExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $solutionType, $landingPage, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum)
{
//------------------------------------------------------------------------------------------------------------------------------------
// Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation
@ -402,17 +431,12 @@ $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $ship
return $resArray;
}
/*
'-------------------------------------------------------------------------------------------
' Purpose: Prepares the parameters for the GetExpressCheckoutDetails API Call.
'
' Inputs:
' None
' Returns:
' The NVP Collection object of the GetExpressCheckoutDetails Call Response.
'-------------------------------------------------------------------------------------------
/**
* Prepares the parameters for the GetExpressCheckoutDetails API Call.
*
* @return array The NVP Collection object of the GetExpressCheckoutDetails Call Response.
*/
function GetDetails( $token )
function GetDetails($token)
{
//'--------------------------------------------------------------
//' At this point, the buyer has completed authorizing the payment
@ -450,12 +474,12 @@ function GetDetails( $token )
}
/*
'-------------------------------------------------------------------------------------------------------------------------------------------
' Purpose: Validate payment
'--------------------------------------------------------------------------------------------------------------------------------------------
/**
* Validate payment
*
* @return void
*/
function ConfirmPayment( $token, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $tag )
function ConfirmPayment($token, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $tag)
{
/* Gather the information to make the final call to
finalize the PayPal payment. The variable nvpstr
@ -486,36 +510,26 @@ function ConfirmPayment( $token, $paymentType, $currencyCodeType, $payerID, $ipa
return $resArray;
}
/*
'-------------------------------------------------------------------------------------------------------------------------------------------
' Purpose: This function makes a DoDirectPayment API call
'
' Inputs:
' paymentType: paymentType has to be one of the following values: Sale or Order or Authorization
' paymentAmount: total value of the shopping cart
' currencyCode: currency code value the PayPal API
' firstName: first name as it appears on credit card
' lastName: last name as it appears on credit card
' street: buyer's street address line as it appears on credit card
' city: buyer's city
' state: buyer's state
' countryCode: buyer's country code
' zip: buyer's zip
' creditCardType: buyer's credit card type (i.e. Visa, MasterCard ... )
' creditCardNumber: buyers credit card number without any spaces, dashes or any other characters
' expDate: credit card expiration date
' cvv2: Card Verification Value
'
'-------------------------------------------------------------------------------------------
'
' Returns:
' The NVP Collection object of the DoDirectPayment Call Response.
'--------------------------------------------------------------------------------------------------------------------------------------------
/**
* This function makes a DoDirectPayment API call
*
* paymentType: paymentType has to be one of the following values: Sale or Order or Authorization
* paymentAmount: total value of the shopping cart
* currencyCode: currency code value the PayPal API
* firstName: first name as it appears on credit card
* lastName: last name as it appears on credit card
* street: buyer's street address line as it appears on credit card
* city: buyer's city
* state: buyer's state
* countryCode: buyer's country code
* zip: buyer's zip
* creditCardType: buyer's credit card type (i.e. Visa, MasterCard ... )
* creditCardNumber: buyers credit card number without any spaces, dashes or any other characters
* expDate: credit card expiration date
* cvv2: Card Verification Value
* @return array The NVP Collection object of the DoDirectPayment Call Response.
*/
function DirectPayment( $paymentType, $paymentAmount, $creditCardType, $creditCardNumber,
$expDate, $cvv2, $firstName, $lastName, $street, $city, $state, $zip,
$countryCode, $currencyCode, $tag )
function DirectPayment($paymentType, $paymentAmount, $creditCardType, $creditCardNumber, $expDate, $cvv2, $firstName, $lastName, $street, $city, $state, $zip, $countryCode, $currencyCode, $tag)
{
//declaring of global variables
global $conf, $langs;
@ -547,9 +561,10 @@ $countryCode, $currencyCode, $tag )
/**
* hash_call: Function to perform the API call to PayPal using API signature
* @param methodName is name of API method.
* @param nvpStr is nvp string.
* @return array returns an associtive array containing the response from the server.
*
* @param string $methodName is name of API method.
* @param string $nvpStr is nvp string.
* @return array returns an associtive array containing the response from the server.
*/
function hash_call($methodName,$nvpStr)
{
@ -606,8 +621,8 @@ function hash_call($methodName,$nvpStr)
{
dol_syslog("Paypal API hash_call set proxy to ".$PROXY_HOST. ":" . $PROXY_PORT." - ".$PROXY_USER. ":" . $PROXY_PASS);
//curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); // Curl 7.10
curl_setopt ($ch, CURLOPT_PROXY, $PROXY_HOST. ":" . $PROXY_PORT);
if ($PROXY_USER) curl_setopt ($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER. ":" . $PROXY_PASS);
curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST. ":" . $PROXY_PORT);
if ($PROXY_USER) curl_setopt($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER. ":" . $PROXY_PASS);
}
//NVPRequest for submitting to server
@ -650,7 +665,9 @@ function hash_call($methodName,$nvpStr)
}
/**
* Get API errors
* Get API errors
*
* @return array Array of errors
*/
function GetApiError()
{
@ -672,12 +689,13 @@ function GetApiError()
}
/*'----------------------------------------------------------------------------------
/**
* This function will take NVPString and convert it to an Associative Array and it will decode the response.
* It is usefull to search for a particular key and displaying arrays.
* @nvpstr is NVPString.
* @nvpArray is Associative Array.
----------------------------------------------------------------------------------
*
* @param string $nvpstr NVPString
* @return array nvpArray = Associative Array
* ----------------------------------------------------------------------------------
*/
function deformatNVP($nvpstr)
{

View File

@ -5,7 +5,7 @@
* Copyright (C) 2007 Auguria SARL <info@auguria.org>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011 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 2 of the License, or
@ -33,12 +33,16 @@ require_once(DOL_DOCUMENT_ROOT."/includes/barcode/html.formbarcode.class.php");
$langs->load("admin");
// Security check
if (!$user->admin)
accessforbidden();
if (! $user->admin) accessforbidden();
$action = GETPOST("action");
$value = GETPOST("value");
/*
* Actions
*/
if ($action == 'nbprod')
{
$res = dolibarr_set_const($db, "PRODUIT_LIMIT_SIZE", $value,'chaine',0,'',$conf->entity);
@ -50,7 +54,7 @@ else if ($action == 'multiprix_num')
if ($action == 'multiprix')
{
$multiprix = GETPOST("activate_multiprix");
$res = dolibarr_set_const($db, "PRODUIT_MULTIPRICES", $multiprix,'chaine',0,'',$conf->entity);
$res =dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", "5",'chaine',0,'',$conf->entity);
}
@ -81,7 +85,6 @@ else if ($action == 'set')
$res = dolibarr_set_const($db, "PRODUIT_USE_ECOTAXE", $ecotaxe,'chaine',0,'',$conf->entity);
}*/
if($action)
{
if (! $res > 0) $error++;
@ -190,7 +193,12 @@ if (! $conf->use_javascript_ajax)
else
{
print '<td width="60" align="right">';
print $html->selectyesno("activate_usesearchtoselectproduct",$conf->global->PRODUIT_USE_SEARCH_TO_SELECT,1);
$arrval=array('0'=>$langs->trans("No"),
'1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",1).')',
'2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')',
'3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')',
);
print $html->selectarray("activate_usesearchtoselectproduct",$arrval,$conf->global->PRODUIT_USE_SEARCH_TO_SELECT);
print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</td>";

View File

@ -79,7 +79,7 @@ class ActionsCardProduct extends Product
$tmpobject = new Product($this->db);
if (! empty($id) || ! empty($ref)) $tmpobject->fetch($id,$ref);
$this->object = $object;
$this->object = $tmpobject;
//parent::assign_values($action);

View File

@ -78,7 +78,7 @@ class ActionsCardService extends Product
$tmpobject = new Product($this->db);
if (! empty($id) || ! empty($ref)) $tmpobject->fetch($id,$ref);
$this->object = $object;
$this->object = $tmpobject;
//parent::assign_values($action);
@ -310,7 +310,7 @@ class ActionsCardService extends Product
if ($_GET["fourn_id"] > 0)
{
$fourn_id = $_GET["fourn_id"];
$sql.= ", ".MAIN_DB_PREFIX."product_fournisseur as pf";
$sql.= ", ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
}
$sql.= " WHERE p.entity = ".$conf->entity;
if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ
@ -335,7 +335,7 @@ class ActionsCardService extends Product
}
if ($fourn_id > 0)
{
$sql.= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id;
$sql.= " AND p.rowid = pfp.fk_product AND pfp.fk_soc = ".$fourn_id;
}
// Insert categ filter
if ($search_categ)

View File

@ -37,7 +37,7 @@ class Product extends CommonObject
public $element='product';
public $table_element='product';
public $fk_element='fk_product';
public $childtables=array('propaldet','commandedet','facturedet','contratdet','product_fournisseur');
public $childtables=array('propaldet','commandedet','facturedet','contratdet','product_fournisseur_price');
protected $isnolinkedbythird = 1; // No field fk_soc
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
@ -45,7 +45,8 @@ class Product extends CommonObject
var $id ;
//! Ref
var $ref;
var $libelle;
var $libelle; // TODO deprecated
var $label;
var $description;
//! Prix de vente
var $price; // Price without tax
@ -68,14 +69,14 @@ class Product extends CommonObject
var $localtax2_tx;
//! Type 0 for regular product, 1 for service (Advanced feature: 2 for assembly kit, 3 for stock kit)
var $type;
var $typestring;
//! Stock
var $stock_reel;
//! Average price value for product entry into stock (PMP)
var $pmp;
//! Stock alert
var $seuil_stock_alerte;
//! Duree de validite du service
var $duration_value;
//! Unite de duree
@ -124,6 +125,10 @@ class Product extends CommonObject
//! Canevas a utiliser si le produit n'est pas un produit generique
var $canvas;
var $import_key;
var $date_creation;
var $date_modification;
//! Id du fournisseur
var $product_fourn_id;
@ -184,9 +189,9 @@ class Product extends CommonObject
/**
* Insert product into database
*
* @param user User making insert
* @param notrigger Disable triggers
* @return int Id of product/service if OK or number of error < 0
* @param User $user User making insert
* @param int $notrigger Disable triggers
* @return int Id of product/service if OK or number of error < 0
*/
function create($user,$notrigger=0)
{
@ -251,6 +256,7 @@ class Product extends CommonObject
dol_syslog("Product::Create ref=".$this->ref." price=".$this->price." price_ttc=".$this->price_ttc." tva_tx=".$this->tva_tx." price_base_type=".$this->price_base_type." Category : ".$this->catid, LOG_DEBUG);
$now=dol_now();
$this->db->begin();
@ -283,7 +289,7 @@ class Product extends CommonObject
$sql.= ", canvas";
$sql.= ", finished";
$sql.= ") VALUES (";
$sql.= $this->db->idate(mktime());
$sql.= $this->db->idate($now);
$sql.= ", ".$conf->entity;
$sql.= ", '".$this->ref."'";
$sql.= ", ".price2num($price_min_ht);
@ -353,7 +359,8 @@ class Product extends CommonObject
else
{
// Product already exists with this ref
$langs->trans("Error")." : ".$langs->trans("ErrorProductAlreadyExists",$this->ref);
$langs->load("products");
$this->error = $langs->transnoentitiesnoconv("ErrorProductAlreadyExists",$this->ref);
}
}
else
@ -387,9 +394,9 @@ class Product extends CommonObject
/**
* Update a record into database
*
* @param id Id of product
* @param user Object user making update
* @return int 1 if OK, -1 if ref already exists, -2 if other error
* @param int $id Id of product
* @param User $user Object user making update
* @return int 1 if OK, -1 if ref already exists, -2 if other error
*/
function update($id, $user)
{
@ -512,11 +519,11 @@ class Product extends CommonObject
$this->db->begin();
// Delete supplier prices log
if (! $error)
/*if (! $error)
{
$sql = 'DELETE pfpl';
$sql.= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price_log as pfpl, '.MAIN_DB_PREFIX.'product_fournisseur as pf';
$sql.= ' WHERE pfpl.fk_product_fournisseur = pf.rowid';
$sql.= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price_log as pfpl, '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp';
$sql.= ' WHERE pfpl.fk_product_fournisseur = pfp.rowid';
$sql.= ' AND pf.fk_product = '.$id;
dol_syslog(get_class($this).'::delete sql='.$sql, LOG_DEBUG);
$result = $this->db->query($sql);
@ -526,15 +533,14 @@ class Product extends CommonObject
$this->error = $this->db->lasterror();
dol_syslog(get_class($this).'::delete error '.$this->error, LOG_ERR);
}
}
}*/
// Delete supplier prices
if (! $error)
{
$sql = 'DELETE pfp';
$sql.= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp, '.MAIN_DB_PREFIX.'product_fournisseur as pf';
$sql.= ' WHERE pfp.fk_product_fournisseur = pf.rowid';
$sql.= ' AND pf.fk_product = '.$id;
$sql.= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp';
$sql.= ' WHERE pfp.fk_product = '.$id;
dol_syslog(get_class($this).'::delete sql='.$sql, LOG_DEBUG);
$result = $this->db->query($sql);
if (! $result)
@ -564,25 +570,23 @@ class Product extends CommonObject
}
}
// Removed extrafields
//$result=$this->deleteExtraFields($this);
//if ($result < 0) $error++;
if (! $error)
{
// Actions on extra fields (by external module or standard code)
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($this->db);
$hookmanager->callHooks(array('product_extrafields'));
$hookmanager->callHooks(array('product'));
$parameters=array(); $action='delete';
$reshook=$hookmanager->executeHooks('deleteExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
$reshook=$hookmanager->executeHooks('deleteProduct',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (! empty($hookmanager->error))
{
$error++;
$this->error=$hookmanager->error;
}
else if (empty($reshook))
{
// TODO
//$result=$this->deleteExtraFields($this);
//if ($result < 0) $error++;
}
}
// Delete product
@ -812,10 +816,9 @@ class Product extends CommonObject
{
$result = 0;
$sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity,";
$sql.= " pf.fk_product, pf.ref_fourn";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product_fournisseur as pf";
$sql.= " WHERE pf.rowid = pfp.fk_product_fournisseur";
$sql.= " AND pfp.rowid = ".$prodfournprice;
$sql.= " pfp.fk_product, pfp.ref_fourn, pfp.fk_soc";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= " WHERE pfp.rowid = ".$prodfournprice;
$sql.= " AND pfp.quantity <= ".$qty;
dol_syslog("Product::get_buyprice sql=".$sql);
@ -834,13 +837,12 @@ class Product extends CommonObject
else
{
// On refait le meme select sur la ref et l'id du produit
$sql = "SELECT pfp.price as price, pfp.quantity as quantity, pf.fk_soc,";
$sql.= " pf.fk_product, pf.ref_fourn";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product_fournisseur as pf";
$sql.= " WHERE pf.rowid = pfp.fk_product_fournisseur";
$sql.= " AND pf.ref_fourn = '".$fourn_ref."'";
$sql.= " AND pf.fk_product = ".$product_id;
$sql.= " AND quantity <= ".$qty;
$sql = "SELECT pfp.price as price, pfp.quantity as quantity, pfp.fk_soc,";
$sql.= " pfp.fk_product, pfp.ref_fourn";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= " WHERE pfp.ref_fourn = '".$fourn_ref."'";
$sql.= " AND pfp.fk_product = ".$product_id;
$sql.= " AND pfp.quantity <= ".$qty;
$sql.= " ORDER BY pfp.quantity DESC";
$sql.= " LIMIT 1";
@ -997,21 +999,21 @@ class Product extends CommonObject
/**
* Load a product in memory from database
*
* @param id Id of product/service to load
* @param ref Ref of product/service to load
* @return int <0 if KO, >0 if OK
* @param int $id Id of product/service to load
* @param string $ref Ref of product/service to load
* @param string $ref_ext Ref ext of product/service to load
* @return int <0 if KO, >0 if OK
*/
function fetch($id='',$ref='')
function fetch($id='',$ref='',$ref_ext='')
{
include_once(DOL_DOCUMENT_ROOT.'/lib/company.lib.php');
global $langs;
global $conf;
global $langs, $conf;
dol_syslog("Product::fetch id=$id ref=$ref");
dol_syslog("Product::fetch id=$id ref=$ref ref_ext=$ref_ext");
// Check parameters
if (! $id && ! $ref)
if (! $id && ! $ref && ! $ref_ext)
{
$this->error=$langs->trans('ErrorWrongParameters');
dol_print_error("Product::fetch ".$this->error, LOG_ERR);
@ -1023,10 +1025,11 @@ class Product extends CommonObject
$sql.= " tobuy, fk_product_type, duration, seuil_stock_alerte, canvas,";
$sql.= " weight, weight_units, length, length_units, surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,";
$sql.= " accountancy_code_buy, accountancy_code_sell, stock, pmp,";
$sql.= " import_key";
$sql.= " datec, tms, import_key";
$sql.= " FROM ".MAIN_DB_PREFIX."product";
if ($id) $sql.= " WHERE rowid = '".$id."'";
else if ($ref) $sql.= " WHERE ref = '".$this->db->escape($ref)."'";
else if ($ref_ext) $sql.= " WHERE ref_ext = '".$this->db->escape($ref_ext)."'";
dol_syslog("Product::fetch sql=".$sql);
$resql = $this->db->query($sql);
@ -1042,6 +1045,11 @@ class Product extends CommonObject
$this->label = $object->label;
$this->description = $object->description;
$this->note = $object->note;
$this->type = $object->fk_product_type;
$this->status = $object->tosell;
$this->status_buy = $object->tobuy;
$this->customcode = $object->customcode;
$this->country_id = $object->fk_country;
$this->country_code = getCountry($this->country_id,2,$this->db);
@ -1057,14 +1065,10 @@ class Product extends CommonObject
$this->localtax1_tx = $object->localtax1_tx;
$this->localtax2_tx = $object->localtax2_tx;
$this->type = $object->fk_product_type;
$this->status = $object->tosell;
$this->status_buy = $object->tobuy;
$this->finished = $object->finished;
$this->duration = $object->duration;
$this->duration_value = substr($object->duration,0,dol_strlen($object->duration)-1);
$this->duration_unit = substr($object->duration,-1);
$this->seuil_stock_alerte = $object->seuil_stock_alerte;
$this->canvas = $object->canvas;
$this->weight = $object->weight;
$this->weight_units = $object->weight_units;
@ -1080,9 +1084,12 @@ class Product extends CommonObject
$this->accountancy_code_buy = $object->accountancy_code_buy;
$this->accountancy_code_sell= $object->accountancy_code_sell;
$this->seuil_stock_alerte = $object->seuil_stock_alerte;
$this->stock_reel = $object->stock;
$this->pmp = $object->pmp;
$this->date_creation = $object->datec;
$this->date_modification = $object->tms;
$this->import_key = $object->import_key;
$this->db->free($resql);
@ -1751,74 +1758,99 @@ class Product extends CommonObject
/**
* Add a supplier reference for the product
* Add a supplier price for the product.
* Note: Duplicate ref is accepted for different quantity only or for different companies.
*
* @param user User that make link
* @param id_fourn Supplier id
* @param ref_fourn Supplier ref
* @return int < 0 if KO, 0 if link already exists for this product, > 0 if OK
* @param User $user User that make link
* @param int $id_fourn Supplier id
* @param string $ref_fourn Supplier ref
* @param float $quantity Quantity minimum for price
* @return int < 0 if KO, 0 if link already exists for this product, > 0 if OK
*/
function add_fournisseur($user, $id_fourn, $ref_fourn)
function add_fournisseur($user, $id_fourn, $ref_fourn, $quantity)
{
global $conf;
$sql = "SELECT rowid, fk_product";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur";
$now=dol_now();
if ($ref_fourn)
{
$sql = "SELECT rowid, fk_product";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
$sql.= " WHERE fk_soc = ".$id_fourn;
$sql.= " AND ref_fourn = '".$ref_fourn."'";
$sql.= " AND fk_product != ".$this->id;
$sql.= " AND entity = ".$conf->entity;
dol_syslog(get_class($this)."::add_fournisseur sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
$obj = $this->db->fetch_object($resql);
if ($obj)
{
// If the supplier ref already exists but for another product (duplicate ref is accepted for different quantity only or different companies)
$this->product_id_already_linked = $obj->fk_product;
return -3;
}
$this->db->free($resql);
}
}
$sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
$sql.= " WHERE fk_soc = ".$id_fourn;
$sql.= " AND ref_fourn = '".$ref_fourn."'";
if ($ref_fourn) $sql.= " AND ref_fourn = '".$ref_fourn."'";
else $sql.= " AND (ref_fourn = '' OR ref_fourn IS NULL)";
$sql.= " AND quantity = '".$quantity."'";
$sql.= " AND fk_product = ".$this->id;
$sql.= " AND entity = ".$conf->entity;
dol_syslog("Product::add_fournisseur sql=".$sql);
dol_syslog(get_class($this)."::add_fournisseur sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
$obj = $this->db->fetch_object($resql);
$obj = $this->db->fetch_object($resql);
// The reference supplier does not exist, we create it for this product.
// The reference supplier does not exist, we create it for this product.
if (! $obj)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur (";
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price(";
$sql.= "datec";
$sql.= ", entity";
$sql.= ", fk_product";
$sql.= ", fk_soc";
$sql.= ", ref_fourn";
$sql.= ", fk_user_author";
$sql.= ", quantity";
$sql.= ", fk_user";
$sql.= ") VALUES (";
$sql.= $this->db->idate(mktime());
$sql.= "'".$this->db->idate($now)."'";
$sql.= ", ".$conf->entity;
$sql.= ", ".$this->id;
$sql.= ", ".$id_fourn;
$sql.= ", '".$ref_fourn."'";
$sql.= ", ".$quantity;
$sql.= ", ".$user->id;
$sql.= ")";
dol_syslog("Product::add_fournisseur sql=".$sql);
if ($this->db->query($sql))
{
$this->product_fourn_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur");
$this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur_price");
return 1;
}
else
{
$this->error=$this->db->lasterror();
dol_syslog("Product::add_fournisseur ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::add_fournisseur ".$this->error, LOG_ERR);
return -1;
}
}
// If the supplier ref already exists for this product
else if ($obj->fk_product == $this->id)
{
$this->product_fourn_id = $obj->rowid;
return 0;
}
// If the supplier ref already exists but for another product
// If the supplier price already exists for this product and quantity
else
{
$this->product_id_already_linked = $obj->fk_product;
return -3;
$this->product_fourn_price_id = $obj->rowid;
return 0;
}
}
else
@ -1840,8 +1872,8 @@ class Product extends CommonObject
$list = array();
$sql = "SELECT fk_soc";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur as p";
$sql = "SELECT p.fk_soc";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as p";
$sql.= " WHERE p.fk_product = ".$this->id;
$sql.= " AND p.entity = ".$conf->entity;
@ -1913,16 +1945,16 @@ class Product extends CommonObject
/**
* Recopie les fournisseurs et prix fournisseurs d'un produit/service sur un autre
*
* @param fromId Id produit source
* @param toId Id produit cible
* @return int < 0 si erreur, > 0 si ok
* @param int $fromId Id produit source
* @param int $toId Id produit cible
* @return int < 0 si erreur, > 0 si ok
*/
function clone_fournisseurs($fromId, $toId)
{
$this->db->begin();
// les fournisseurs
$sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur ("
/*$sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur ("
. " datec, fk_product, fk_soc, ref_fourn, fk_user_author )"
. " SELECT '".$this->db->idate(mktime())."', ".$toId.", fk_soc, ref_fourn, fk_user_author"
. " FROM ".MAIN_DB_PREFIX."product_fournisseur"
@ -1932,7 +1964,7 @@ class Product extends CommonObject
{
$this->db->rollback();
return -1;
}
}*/
// les prix de fournisseurs.
$sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur_price ("
@ -1941,13 +1973,17 @@ class Product extends CommonObject
. " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"
. " WHERE fk_product = ".$fromId;
if ( ! $this->db->query($sql ) )
$resql=$this->db->query($sql);
if (! $resql)
{
$this->db->rollback();
return -1;
}
$this->db->commit();
return 1;
else
{
$this->db->commit();
return 1;
}
}
/**
@ -2905,5 +2941,30 @@ class Product extends CommonObject
}
}
/**
* Initialise an instance with random values.
* Used to build previews or test instances.
* id must be 0 if object instance is a specimen.
*
* @return void
*/
function initAsSpecimen()
{
global $user,$langs,$conf,$mysoc;
$now=dol_now();
// Initialize parameters
$this->id=0;
$this->ref = 'PRODUCT_SPEC';
$this->libelle = 'PRODUCT SPECIMEN';
$this->description = 'PRODUCT SPECIMEN '.dol_print_date($now,'dayhourlog');
$this->specimen=1;
$this->country_id=1;
$this->tosell=1;
$this->tobuy=1;
$this->type=0;
$this->note='This is a comment (private)';
}
}
?>

View File

@ -123,7 +123,7 @@ if ($cancel == $langs->trans("Cancel"))
*/
// action recherche des produits par mot-cle et/ou par categorie
if($action == 'search' )
if ($action == 'search')
{
$current_lang = $langs->getDefaultLang();
@ -174,9 +174,9 @@ dol_fiche_head($head, 'subproduct', $titre, 0, $picto);
if ($id || $ref)
{
if ( $result )
if ($result)
{
if ($action <> 'edit' &&$action <> 'search' && $action <> 're-edit')
if ($action <> 'edit' && $action <> 'search' && $action <> 're-edit')
{
/*
* En mode visu
@ -209,7 +209,7 @@ if ($id || $ref)
// List of subproducts
$prods_arbo = $product->get_arbo_each_prod();
if(count($prods_arbo) > 0)
if (count($prods_arbo) > 0)
{
print '<tr><td colspan="2">';
print '<b>'.$langs->trans("ProductAssociationList").'</b><br>';
@ -236,7 +236,7 @@ if ($id || $ref)
// Number of parent products
print '<tr><td>'.$langs->trans("ParentProductsNumber").'</td><td>'.count($prodsfather).'</td>';
if(count($prodsfather) > 0)
if (count($prodsfather) > 0)
{
print '<tr><td colspan="2">';
print '<b>'.$langs->trans("ProductParentList").'</b><br>';
@ -321,7 +321,7 @@ if ($id || $ref)
// Number of parent products
print '<tr><td>'.$langs->trans("ParentProductsNumber").'</td><td>'.count($prodsfather).'</td>';
if(count($prodsfather) > 0)
if (count($prodsfather) > 0)
{
print '<tr><td colspan="2">';
print '<b>'.$langs->trans("ProductParentList").'</b><br>';
@ -375,7 +375,7 @@ if ($id || $ref)
print '</td></td></table>';
print '</form>';
if($action == 'search')
if ($action == 'search')
{
print '<br>';
print '<form action="'.DOL_URL_ROOT.'/product/composition/fiche.php?id='.$id.'" method="post">';
@ -408,7 +408,7 @@ if ($id || $ref)
if ($prod_arbo->type==2 || $prod_arbo->type==3)
{
$is_pere=0;
$prod_arbo->get_sousproduits_arbo ();
$prod_arbo->get_sousproduits_arbo();
// associations sousproduits
$prods_arbo = $prod_arbo->get_arbo_each_prod();
if (count($prods_arbo) > 0)
@ -421,7 +421,8 @@ if ($id || $ref)
}
}
}
if ($is_pere==1) {
if ($is_pere==1)
{
$i++;
continue;
}
@ -498,8 +499,8 @@ if ($action == '')
print "\n</div>\n";
llxFooter();
$db->close();
llxFooter();
?>

File diff suppressed because it is too large Load Diff

View File

@ -34,6 +34,12 @@ $langs->load("products");
$langs->load("suppliers");
$langs->load("bills");
$action=GETPOST('action');
$id=GETPOST('id','int');
$ref=GETPOST('ref');
$socid=GETPOST('socid');
$error=0; $mesg = '';
// If socid provided by ajax company selector
if (! empty($_REQUEST['search_fourn_id']))
{
@ -43,13 +49,8 @@ if (! empty($_REQUEST['search_fourn_id']))
}
// Security check
if (isset($_GET["id"]) || isset($_GET["ref"]))
{
$id = isset($_GET["id"])?$_GET["id"]:(isset($_GET["ref"])?$_GET["ref"]:'');
}
$fieldid = isset($_GET["ref"])?'ref':'rowid';
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'produit|service&fournisseur',$id,'product','','',$fieldid);
$result=restrictedArea($user, 'produit|service&fournisseur', ($id>0?$id:$ref), 'product', '', '', ($id>0?'rowid':'ref'));
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
@ -57,69 +58,70 @@ $sortorder = GETPOST("sortorder",'alpha');
if (! $sortfield) $sortfield="s.nom";
if (! $sortorder) $sortorder="ASC";
$mesg = '';
/*
* Actions
*/
if ($_GET["action"] == 'remove_pf')
if ($action == 'remove_pf')
{
$product = new ProductFournisseur($db);
if ($product->fetch($_GET["id"]) > 0)
if ($product->fetch($id) > 0)
{
if ($_GET["rowid"])
{
$result=$product->remove_product_fournisseur_price($_GET["rowid"]);
$_GET["action"] = '';
$action = '';
$mesg = '<div class="ok">'.$langs->trans("PriceRemoved").'.</div>';
}
else
{
// Deprecated. Should not occurs
if ($product->remove_fournisseur($_GET["socid"]) > 0)
{
$_GET["action"] = '';
$mesg = '<div class="ok">'.$langs->trans("SupplierRemoved").'.</div>';
}
else
{
$_GET["action"] = '';
}
}
}
}
if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Cancel"))
if ($action == 'updateprice' && $_POST["cancel"] <> $langs->trans("Cancel"))
{
$id_fourn=GETPOST("id_fourn");
if (empty($id_fourn)) $id_fourn=GETPOST("search_id_fourn");
$ref_fourn=GETPOST("ref_fourn");
if (empty($ref_fourn)) $ref_fourn=GETPOST("search_ref_fourn");
$quantity=GETPOST("qty");
if (empty($quantity))
{
$error++;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Qty")).'</div>';
}
if (empty($ref_fourn)) // TODO Why not making this optionnal ?
{
$error++;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("RefSupplier")).'</div>';
}
if ($id_fourn <= 0)
{
$error++;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Supplier")).'</div>';
}
if ($_POST["price"] < 0 || $_POST["price"] == '')
{
$error++;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Price")).'</div>';
}
$product = new ProductFournisseur($db);
$result=$product->fetch(GETPOST("id"));
if ($result > 0)
$result=$product->fetch($id);
if ($result <= 0)
{
$db->begin();
$error++;
$mesg=$product->error;
}
$error=0;
if (! $ref_fourn)
{
$error++;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("RefSupplier")).'</div>';
}
if ($id_fourn <= 0)
{
//print "eee".$_POST["id_fourn"];
$error++;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Supplier")).'</div>';
}
if (! $error)
{
$db->begin();
if (! $error)
{
$ret=$product->add_fournisseur($user, $id_fourn, $ref_fourn);
$ret=$product->add_fournisseur($user, $id_fourn, $ref_fourn, $quantity); // This insert record with no value for price. Values are update later with update_buyprice
if ($ret == -3)
{
$error++;
@ -138,43 +140,27 @@ if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Canc
if (! $error)
{
if ($_POST["qty"])
{
if ($_POST["price"] >= 0)
{
$supplier=new Fournisseur($db);
$result=$supplier->fetch($id_fourn);
$supplier=new Fournisseur($db);
$result=$supplier->fetch($id_fourn);
$ret=$product->update_buyprice($_POST["qty"], $_POST["price"], $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"]);
if ($ret < 0)
{
$error++;
$mesg='<div class="error">'.$product->error.'</div>';
}
}
else
{
$error++;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Price")).'</div>';
}
}
else
$ret=$product->update_buyprice($quantity, $_POST["price"], $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn);
if ($ret < 0)
{
$error++;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Qty")).'</div>';
$mesg='<div class="error">'.$product->error.'</div>';
}
}
if (! $error)
{
$db->commit();
$_POST['action']='';
$action='';
}
else
{
$db->rollback();
}
}
}
}
if ($_POST["cancel"] == $langs->trans("Cancel"))
@ -192,21 +178,19 @@ if ($_POST["cancel"] == $langs->trans("Cancel"))
$html = new Form($db);
if ($_GET["id"] || $_GET["ref"])
if ($id || $ref)
{
if ($_GET["action"] <> 're-edit')
if ($action <> 're-edit')
{
$product = new ProductFournisseur($db);
$result = $product->fetch($_GET["id"],$_GET["ref"]);
$result = $product->fetch_fourn_data($_REQUEST["id_fourn"]);
//print 'eeeee'.$_GET["socid"];exit;
$result = $product->fetch($id,$ref);
//$result = $product->fetch_fourn_data($_REQUEST["id_fourn"]);
llxHeader("","",$langs->trans("CardProduct".$product->type));
}
if ( $result )
if ($result)
{
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
if ($action <> 'edit' && $action <> 're-edit')
{
/*
* En mode visu
@ -255,28 +239,33 @@ if ($_GET["id"] || $_GET["ref"])
// Form to add or update a price
if (($_GET["action"] == 'add_price' || $_POST["action"] == 'updateprice' ) && ($user->rights->produit->creer || $user->rights->service->creer))
if (($action == 'add_price' || $action == 'updateprice' ) && ($user->rights->produit->creer || $user->rights->service->creer))
{
$langs->load("suppliers");
if ($_GET["rowid"]) {
if ($_GET["rowid"])
{
$product->fetch_product_fournisseur_price($_GET["rowid"]);
print_fiche_titre($langs->trans("ChangeSupplierPrice"));
} else {
}
else
{
print_fiche_titre($langs->trans("AddSupplierPrice"));
}
print '<table class="border" width="100%">';
print '<form action="fournisseurs.php?id='.$product->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="updateprice">';
print '<tr><td>'.$langs->trans("Supplier").'</td><td colspan="3">';
print '<table class="border" width="100%">';
print '<tr><td class="fieldrequired">'.$langs->trans("Supplier").'</td><td colspan="3">';
if ($_GET["rowid"])
{
$supplier=new Fournisseur($db);
$supplier->fetch($_GET["socid"]);
$supplier->fetch($socid);
print $supplier->getNomUrl(1);
print '<input type="hidden" name="id_fourn" value="'.$_GET["socid"].'">';
print '<input type="hidden" name="id_fourn" value="'.$socid.'">';
print '<input type="hidden" name="ref_fourn" value="'.$product->fourn_ref.'">';
print '<input type="hidden" name="ref_fourn_price_id" value="'.$_GET["rowid"].'">';
}
@ -288,14 +277,14 @@ if ($_GET["id"] || $_GET["ref"])
print '</td></tr>';
// Ref supplier
print '<tr><td>'.$langs->trans("SupplierRef").'</td><td colspan="3">';
print '<tr><td class="fieldrequired">'.$langs->trans("SupplierRef").'</td><td colspan="3">';
if ($_GET["rowid"])
{
print $product->fourn_ref;
}
else
{
print '<input class="flat" name="ref_fourn" size="12" value="'.($_POST["ref_fourn"]?$_POST["ref_fourn"]:$product->ref_fourn).'">';
print '<input class="flat" name="ref_fourn" size="12" value="'.($_POST["ref_fourn"]?$_POST["ref_fourn"]:'').'">';
}
print '</td>';
print '</tr>';
@ -303,6 +292,7 @@ if ($_GET["id"] || $_GET["ref"])
// Availability
if(!empty($conf->global->FOURN_PRODUCT_AVAILABILITY))
{
$langs->load("propal");
print '<tr><td>'.$langs->trans("Availability").'</td><td colspan="3">';
$html->select_availability($product->fk_availability,"oselDispo",1);
print '</td></tr>'."\n";
@ -310,8 +300,8 @@ if ($_GET["id"] || $_GET["ref"])
// Qty min
print '<tr>';
print '<td>'.$langs->trans("QtyMin").'</td>';
print '<td>';
print '<td class="fieldrequired" width="25%">'.$langs->trans("QtyMin").'</td>';
print '<td width="25%">';
$quantity = $_REQUEST["qty"] ? $_REQUEST["qty"] : "1";
if ($_GET["rowid"])
{
@ -323,19 +313,20 @@ if ($_GET["id"] || $_GET["ref"])
print '<input class="flat" name="qty" size="5" value="'.$quantity.'">';
}
print '</td>';
print '<td>'.$langs->trans("PriceQtyMin").'</td>';
print '<td><input class="flat" name="price" size="8" value="'.($_POST["price"]?$_POST["price"]:price($product->fourn_price)).'">';
print '<td class="fieldrequired" width="25%">'.$langs->trans("PriceQtyMin").'</td>';
print '<td width="25%"><input class="flat" name="price" size="8" value="'.($_POST["price"]?$_POST["price"]:(isset($product->fourn_price)?price($product->fourn_price):'')).'">';
print '&nbsp;';
print $html->select_PriceBaseType(($_POST["price_base_type"]?$_POST["price_base_type"]:$product->price_base_type), "price_base_type");
print '</td>';
print '</tr>';
print '<tr><td colspan="4" align="center"><input class="button" type="submit" value="'.$langs->trans("Save").'">';
print '</table>';
print '<center><input class="button" type="submit" value="'.$langs->trans("Save").'">';
print '&nbsp; &nbsp;';
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
print '</form>';
print '</table>';
}
/* ************************************************************************** */
@ -346,14 +337,13 @@ if ($_GET["id"] || $_GET["ref"])
print "\n<div class=\"tabsAction\">\n";
if ($_GET["action"] != 'add_price') {
if ($action != 'add_price' && $action != 'updateprice')
{
if ($user->rights->produit->creer || $user->rights->service->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$product->id.'&amp;action=add_price">';
print $langs->trans("AddSupplierPrice").'</a>';
}
}
print "\n</div>\n";
@ -371,16 +361,15 @@ if ($_GET["id"] || $_GET["ref"])
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Suppliers"),$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder);
print '<td class="liste_titre">'.$langs->trans("SupplierRef").'</td>';
if(!empty($conf->global->FOURN_PRODUCT_AVAILABILITY))
print_liste_field_titre($langs->trans("Availability"),$_SERVER["PHP_SELF"],"pfp.fk_availability","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("QtyMin"),$_SERVER["PHP_SELF"],"pfp.quantity","",$param,"",$sortfield,$sortorder);
if (!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) print_liste_field_titre($langs->trans("Availability"),$_SERVER["PHP_SELF"],"pfp.fk_availability","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("QtyMin"),$_SERVER["PHP_SELF"],"pfp.quantity","",$param,'align="right"',$sortfield,$sortorder);
print '<td class="liste_titre" align="right">'.$langs->trans("PriceQtyMinHT").'</td>';
print_liste_field_titre($langs->trans("UnitPriceHT"),$_SERVER["PHP_SELF"],"pfp.unitprice","",$param,'align="right"',$sortfield,$sortorder);
print '<td class="liste_titre"></td>';
print "</tr>\n";
$product_fourn = new ProductFournisseur($db);
$product_fourn_list = $product_fourn->fetch_product_fournisseur($product->id);
$product_fourn_list = $product_fourn->list_product_fournisseur_price($product->id);
if (count($product_fourn_list)>0)
{
@ -406,7 +395,7 @@ if ($_GET["id"] || $_GET["ref"])
}
// Quantity
print '<td align="center">';
print '<td align="right">';
print $productfourn->fourn_qty;
print '</td>';

View File

@ -133,8 +133,8 @@ else
$sql.= ') ';
//if ($fourn_id > 0) // The DISTINCT is used to avoid duplicate from this link
//{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur as pf ON p.rowid = pf.fk_product";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON pf.rowid = pfp.fk_product_fournisseur";
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur as pf ON p.rowid = pf.fk_product";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
//}
$sql.= ' WHERE p.entity IN (0,'.(! empty($conf->entities['product']) ? $conf->entities['product'] : $conf->entity).')';
if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ
@ -156,7 +156,7 @@ else
if (dol_strlen($canvas) > 0) $sql.= " AND p.canvas = '".$db->escape($canvas)."'";
if ($catid) $sql.= " AND cp.fk_categorie = ".$catid;
if ($search_categ) $sql.= " AND cp.fk_categorie = ".$search_categ;
if ($fourn_id > 0) $sql.= " AND pf.fk_soc = ".$fourn_id;
if ($fourn_id > 0) $sql.= " AND pfp.fk_soc = ".$fourn_id;
$sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,";
$sql.= " p.fk_product_type, p.tms,";
$sql.= " p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte";
@ -258,7 +258,7 @@ else
print "<tr class=\"liste_titre\">";
print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label",$param,"","",$sortfield,$sortorder);
if ($conf->barcode->enabled) print_liste_field_titre($langs->trans("BarCode"), $_SERVER["PHP_SELF"], "p.barcode",$param,"","",$sortfield,$sortorder);
if ($conf->barcode->enabled) print_liste_field_titre($langs->trans("BarCode"), $_SERVER["PHP_SELF"], "p.barcode",$param,'','',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateModification"), $_SERVER["PHP_SELF"], "p.tms",$param,"",'align="center"',$sortfield,$sortorder);
if ($conf->service->enabled && $type != 0) print_liste_field_titre($langs->trans("Duration"), $_SERVER["PHP_SELF"], "p.duration",$param,"",'align="center"',$sortfield,$sortorder);
if (empty($conf->global->PRODUIT_MULTIPRICES)) print_liste_field_titre($langs->trans("SellingPrice"), $_SERVER["PHP_SELF"], "p.price",$param,"",'align="right"',$sortfield,$sortorder);
@ -368,7 +368,7 @@ else
// Barcode
if ($conf->barcode->enabled)
{
print '<td align="right">'.$objp->barcode.'</td>';
print '<td>'.$objp->barcode.'</td>';
}
// Date

View File

@ -96,12 +96,6 @@ $sql.= ' SUM(s.reel) as stock_physique';
$sql.= ' FROM ('.MAIN_DB_PREFIX.'product as p';
// We'll need this table joined to the select in order to filter by categ
if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_product as cp";
// We disable this because this create duplicate lines
/*if ($_GET["fourn_id"] > 0)
{
$fourn_id = $_GET["fourn_id"];
$sql.= ", ".MAIN_DB_PREFIX."product_fournisseur as pf";
}*/
$sql.= ') LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s on p.rowid = s.fk_product';
$sql.= " WHERE p.entity = ".$conf->entity;
if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ
@ -112,9 +106,12 @@ if ($sall)
// if the type is not 1, we show all products (type = 0,2,3)
if (dol_strlen($type))
{
if ($type==1) {
if ($type==1)
{
$sql.= " AND p.fk_product_type = '1'";
} else {
}
else
{
$sql.= " AND p.fk_product_type <> '1'";
}
}

View File

@ -345,9 +345,10 @@ if ($_GET["id"] || $_GET["ref"])
print '</td>';
print '</tr>';
print '<tr><td colspan="5" align="center"><input type="submit" class="button" value="'.$langs->trans('Save').'">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
print '</table>';
print '<center><input type="submit" class="button" value="'.$langs->trans('Save').'">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
print '</form>';
}
@ -381,9 +382,11 @@ if ($_GET["id"] || $_GET["ref"])
print '</td>';
print '</tr>';
print '<tr><td colspan="6" align="center"><input type="submit" class="button" value="'.$langs->trans('Save').'">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
print '</table>';
print '<center><input type="submit" class="button" value="'.$langs->trans('Save').'">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
print '</form>';
}

View File

@ -299,7 +299,7 @@ class Societe extends CommonObject
$result = 0;
$this->name = trim($this->name);
$this->nom=$this->name; // For backward compatibility
if (! $this->name)
{
$this->errors[] = 'ErrorBadThirdPartyName';
@ -942,25 +942,23 @@ class Societe extends CommonObject
}
}
// Removed extrafields
//$result=$this->deleteExtraFields($this);
//if ($result < 0) $error++;
if (! $error)
{
// Actions on extra fields (by external module or standard code)
// Additionnal action by hooks
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($this->db);
$hookmanager->callHooks(array('thirdparty_extrafields'));
$hookmanager->callHooks(array('thirdparty'));
$parameters=array(); $action='delete';
$reshook=$hookmanager->executeHooks('deleteExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
$reshook=$hookmanager->executeHooks('deleteThirdparty',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (! empty($hookmanager->error))
{
$error++;
$this->error=$hookmanager->error;
}
else if (empty($reshook))
{
// TODO
//$result=$this->deleteExtraFields($this);
//if ($result < 0) $error++;
}
}
// Remove third party
@ -1413,8 +1411,9 @@ class Societe extends CommonObject
/**
* Return a link on thirdparty (with picto)
* @param withpicto Inclut le picto dans le lien (0=No picto, 1=Inclut le picto dans le lien, 2=Picto seul)
* @param option Sur quoi pointe le lien ('', 'customer', 'prospect', 'supplier')
*
* @param withpicto Add picto into link (0=No picto, 1=Include picto with link, 2=Picto only)
* @param option Target of link ('', 'customer', 'prospect', 'supplier')
* @param maxlen Max length of text
* @return string String with URL
*/

View File

@ -101,6 +101,11 @@ print '<br><br>';
print '<u>'.$langs->trans("WSDLCanBeDownloadedHere").':</u><br>';
$url=DOL_MAIN_URL_ROOT.'/webservices/server_other.php?wsdl';
print img_picto('','object_globe.png').' '.'<a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
if ($conf->product->enabled || $conf->service->enabled)
{
$url=DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php?wsdl';
print img_picto('','object_globe.png').' '.'<a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
}
if ($conf->societe->enabled)
{
$url=DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php?wsdl';
@ -123,6 +128,11 @@ print '<br>';
print '<u>'.$langs->trans("EndPointIs").':</u><br>';
$url=DOL_MAIN_URL_ROOT.'/webservices/server_other.php';
print img_picto('','object_globe.png').' '.'<a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
if ($conf->product->enabled || $conf->service->enabled)
{
$url=DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php';
print img_picto('','object_globe.png').' '.'<a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
}
if ($conf->societe->enabled)
{
$url=DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php';

View File

@ -0,0 +1,140 @@
<?php
/* Copyright (C) 2006-2010 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 2 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/webservices/demo_wsclient_productorservice.php
* \brief Demo page to make a client call to Dolibarr WebServices "server_product"
*/
// This is to make Dolibarr working with Plesk
set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs');
require_once("../master.inc.php");
require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php';
//$WS_DOL_URL = 'http://localhost:8080/'; // To test with Soapui mock. If not a page, should end with /
$WS_METHOD1 = 'createProductOrService';
$WS_METHOD2 = 'getProductOrService';
$ns='http://www.dolibarr.org/ns/';
// Set the WebService URL
dol_syslog("Create nusoap_client for URL=".$WS_DOL_URL);
$soapclient1 = new nusoap_client($WS_DOL_URL);
if ($soapclient1)
{
$soapclient1->soap_defencoding='UTF-8';
$soapclient1->decodeUTF8(false);
}
$soapclient2 = new nusoap_client($WS_DOL_URL);
if ($soapclient2)
{
$soapclient2->soap_defencoding='UTF-8';
$soapclient2->decodeUTF8(false);
}
// Call the WebService method and store its result in $result.
$authentication=array(
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
'sourceapplication'=>'DEMO',
'login'=>'admin',
'password'=>'changeme',
'entity'=>'');
// Test url 1
if ($WS_METHOD1)
{
$parameters = array('authentication'=>$authentication,'id'=>1,'ref'=>'');
dol_syslog("Call method ".$WS_METHOD1);
$result1 = $soapclient1->call($WS_METHOD1,$parameters,$ns,'');
if (! $result1)
{
print $soapclient1->error_str;
print "<br>\n\n";
print $soapclient1->request;
print "<br>\n\n";
print $soapclient1->response;
exit;
}
}
// Test url 2
if ($WS_METHOD2)
{
$parameters = array('authentication'=>$authentication,'id'=>1,'ref'=>'');
dol_syslog("Call method ".$WS_METHOD2);
$result2 = $soapclient1->call($WS_METHOD2,$parameters,$ns,'');
if (! $result2)
{
print $soapclient1->error_str;
print "<br>\n\n";
print $soapclient1->request;
print "<br>\n\n";
print $soapclient1->response;
exit;
}
}
/*
* View
*/
header("Content-type: text/html; charset=utf8");
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n";
echo '<html>'."\n";
echo '<head>';
echo '<title>WebService Test: '.$WS_METHOD1.'</title>';
echo '</head>'."\n";
echo '<body>'."\n";
echo "<h2>Request:</h2>";
echo '<h4>Function</h4>';
echo $WS_METHOD1;
echo '<h4>SOAP Message</h4>';
echo '<pre>' . htmlspecialchars($soapclient1->request, ENT_QUOTES) . '</pre>';
echo '<hr>';
echo "<h2>Response:</h2>";
echo '<h4>Result</h4>';
echo '<pre>';
print_r($result1);
echo '</pre>';
echo '<h4>SOAP Message</h4>';
echo '<pre>' . htmlspecialchars($soapclient1->response, ENT_QUOTES) . '</pre>';
print '<hr>';
echo "<h2>Request:</h2>";
echo '<h4>Function</h4>';
echo $WS_METHOD2;
echo '<h4>SOAP Message</h4>';
echo '<pre>' . htmlspecialchars($soapclient2->request, ENT_QUOTES) . '</pre>';
echo '<hr>';
echo "<h2>Response:</h2>";
echo '<h4>Result</h4>';
echo '<pre>';
print_r($result2);
echo '</pre>';
echo '<h4>SOAP Message</h4>';
echo '<pre>' . htmlspecialchars($soapclient2->response, ENT_QUOTES) . '</pre>';
echo '</body>'."\n";;
echo '</html>'."\n";;
?>

View File

@ -52,7 +52,7 @@ $server->configureWSDL('WebServicesDolibarrInvoice',$ns);
$server->wsdl->schemaTargetNamespace=$ns;
// Define WSDL content
// Define WSDL Authentication object
$server->wsdl->addComplexType(
'authentication',
'complexType',
@ -67,7 +67,20 @@ $server->wsdl->addComplexType(
'entity' => array('name'=>'entity','type'=>'xsd:string'),
)
);
// Define WSDL Return object
$server->wsdl->addComplexType(
'result',
'complexType',
'struct',
'all',
'',
array(
'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
)
);
// Define other specific objects
$server->wsdl->addComplexType(
'line',
'complexType',
@ -183,19 +196,6 @@ $server->wsdl->addComplexType(
);
$server->wsdl->addComplexType(
'result',
'complexType',
'struct',
'all',
'',
array(
'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
)
);
// 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped
// Style merely dictates how to translate a WSDL binding to a SOAP message. Nothing more. You can use either style with any programming model.
@ -205,43 +205,49 @@ $styleuse='encoded'; // encoded/literal/literal wrapped
// Better choice is document/literal wrapped but literal wrapped not supported by nusoap.
// Register WSDL
$server->register('getInvoice',
// Entry values
array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
// Exit values
array('result'=>'tns:result','invoice'=>'tns:invoice'),
$ns,
$ns.'#getInvoice',
$styledoc,
$styleuse,
'WS to get a particular invoice'
$server->register(
'getInvoice',
// Entry values
array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
// Exit values
array('result'=>'tns:result','invoice'=>'tns:invoice'),
$ns,
$ns.'#getInvoice',
$styledoc,
$styleuse,
'WS to get a particular invoice'
);
$server->register('getInvoicesForThirdParty',
// Entry values
array('authentication'=>'tns:authentication','idthirdparty'=>'xsd:string'),
// Exit values
array('result'=>'tns:result','invoices'=>'tns:InvoicesArray2'),
$ns,
$ns.'#getInvoicesForThirdParty',
$styledoc,
$styleuse,
'WS to get all invoices of a third party'
$server->register(
'getInvoicesForThirdParty',
// Entry values
array('authentication'=>'tns:authentication','idthirdparty'=>'xsd:string'),
// Exit values
array('result'=>'tns:result','invoices'=>'tns:InvoicesArray2'),
$ns,
$ns.'#getInvoicesForThirdParty',
$styledoc,
$styleuse,
'WS to get all invoices of a third party'
);
$server->register('createInvoice',
// Entry values
array('authentication'=>'tns:authentication','invoice'=>'tns:invoice'),
// Exit values
array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string'),
$ns,
$ns.'#createInvoice',
$styledoc,
$styleuse,
'WS to create an invoice'
$server->register(
'createInvoice',
// Entry values
array('authentication'=>'tns:authentication','invoice'=>'tns:invoice'),
// Exit values
array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string'),
$ns,
$ns.'#createInvoice',
$styledoc,
$styleuse,
'WS to create an invoice'
);
/**
* Get invoice from id, ref or ref_ext
*
* @param array $authentication Array of authentication information
* @return array Array result
*/
function getInvoice($authentication,$id='',$ref='',$ref_ext='')
{
@ -346,6 +352,9 @@ function getInvoice($authentication,$id='',$ref='',$ref_ext='')
/**
* Get list of invoices for third party
*
* @param array $authentication Array of authentication information
* @return array Array result
*/
function getInvoicesForThirdParty($authentication,$idthirdparty)
{
@ -461,7 +470,11 @@ function getInvoicesForThirdParty($authentication,$idthirdparty)
/**
* Get list of invoices for third party
* Create an invoice
*
* @param array $authentication Array of authentication information
* @param Facture $invoice Invoice
* @return array Array result
*/
function createInvoice($authentication,$invoice)
{
@ -469,7 +482,7 @@ function createInvoice($authentication,$invoice)
$now=dol_now();
dol_syslog("Function: createInvoiceForThirdParty login=".$authentication['login']." idthirdparty=".$idthirdparty);
dol_syslog("Function: createInvoiceForThirdParty login=".$authentication['login']);
if ($authentication['entity']) $conf->entity=$authentication['entity'];
@ -482,17 +495,17 @@ function createInvoice($authentication,$invoice)
if (! $error)
{
$newinvoice=new Facture($db);
$newinvoice->socid=$invoice['thirdparty_id'];
$newinvoice->type=$invoice['type'];
$newinvoice->ref_ext=$invoice['ref_ext'];
$newinvoice->date=$invoice['date'];
$newinvoice->date_lim_reglement=$invoice['date_due'];
$newinvoice->note=$invoice['note'];
$newinvoice->note_public=$invoice['note_public'];
$newinvoice->statut=$invoice['status'];
$newinvoice->fk_project=$invoice['project_id'];
$newinvoice->date_creation=$now;
$newobject=new Facture($db);
$newobject->socid=$invoice['thirdparty_id'];
$newobject->type=$invoice['type'];
$newobject->ref_ext=$invoice['ref_ext'];
$newobject->date=$invoice['date'];
$newobject->date_lim_reglement=$invoice['date_due'];
$newobject->note=$invoice['note'];
$newobject->note_public=$invoice['note_public'];
$newobject->statut=$invoice['status'];
$newobject->fk_project=$invoice['project_id'];
$newobject->date_creation=$now;
foreach($invoice['lines'] as $line)
{
$newline=new FactureLigne($db);
@ -511,35 +524,32 @@ function createInvoice($authentication,$invoice)
$db->begin();
$result=$newinvoice->create($user,0,0);
$result=$newobject->create($fuser,0,0);
if ($result < 0)
{
$error++;
}
if ($newinvoice->statut == 1) // We want invoice validated
if ($newobject->statut == 1) // We want invoice validated
{
$newinvoice->validate($user);
$result=$newobject->validate($fuser);
if ($result < 0)
{
$error++;
}
}
$result=$newinvoice->create($user,0,0);
if ($result < 0)
{
$error++;
}
if (! $error)
{
$db->commit();
$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newinvoice->id,'ref'=>$newinvoice->ref);
$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref);
}
else
{
$db->rollback();
$error++;
$errorcode='KO';
$errorlabel=$newinvoice->error;
$errorlabel=$newobject->error;
}
}

View File

@ -52,21 +52,22 @@ $server->configureWSDL('WebServicesDolibarrOther',$ns);
$server->wsdl->schemaTargetNamespace=$ns;
// Define WSDL content
// Define WSDL Authentication object
$server->wsdl->addComplexType(
'authentication',
'complexType',
'struct',
'all',
'',
array(
'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
'login' => array('name'=>'login','type'=>'xsd:string'),
'password' => array('name'=>'password','type'=>'xsd:string'),
'entity' => array('name'=>'entity','type'=>'xsd:string'),
));
'authentication',
'complexType',
'struct',
'all',
'',
array(
'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
'login' => array('name'=>'login','type'=>'xsd:string'),
'password' => array('name'=>'password','type'=>'xsd:string'),
'entity' => array('name'=>'entity','type'=>'xsd:string'),
)
);
// Define WSDL Return object
$server->wsdl->addComplexType(
'result',
'complexType',
@ -76,7 +77,11 @@ $server->wsdl->addComplexType(
array(
'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
));
)
);
// Define other specific objects
// None
// 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped

View File

@ -0,0 +1,360 @@
<?php
/* Copyright (C) 2006-2010 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 2 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/webservices/server_productorservice.php
* \brief File that is entry point to call Dolibarr WebServices
*/
// This is to make Dolibarr working with Plesk
set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs');
require_once("../master.inc.php");
require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP
require_once(DOL_DOCUMENT_ROOT."/lib/ws.lib.php");
require_once(DOL_DOCUMENT_ROOT."/user/class/user.class.php");
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
dol_syslog("Call Dolibarr webservices interfaces");
// Enable and test if module web services is enabled
if (empty($conf->global->MAIN_MODULE_WEBSERVICES))
{
$langs->load("admin");
dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
print $langs->trans("ToActivateModule");
exit;
}
// Create the soap Object
$server = new nusoap_server();
$server->soap_defencoding='UTF-8';
$server->decode_utf8=false;
$ns='http://www.dolibarr.org/ns/';
$server->configureWSDL('WebServicesDolibarrProductOrService',$ns);
$server->wsdl->schemaTargetNamespace=$ns;
// Define WSDL Authentication object
$server->wsdl->addComplexType(
'authentication',
'complexType',
'struct',
'all',
'',
array(
'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
'login' => array('name'=>'login','type'=>'xsd:string'),
'password' => array('name'=>'password','type'=>'xsd:string'),
'entity' => array('name'=>'entity','type'=>'xsd:string'),
)
);
// Define WSDL Return object
$server->wsdl->addComplexType(
'result',
'complexType',
'struct',
'all',
'',
array(
'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
)
);
// Define other specific objects
$server->wsdl->addComplexType(
'product',
'complexType',
'struct',
'all',
'',
array(
'id' => array('name'=>'id','type'=>'xsd:string'),
'ref' => array('name'=>'ref','type'=>'xsd:string'),
'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'),
'type' => array('name'=>'type','type'=>'xsd:string'),
'label' => array('name'=>'label','type'=>'xsd:string'),
'description' => array('name'=>'description','type'=>'xsd:string'),
'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'),
'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'),
'note' => array('name'=>'note','type'=>'xsd:string'),
'status_tobuy' => array('name'=>'status_tobuy','type'=>'xsd:string'),
'status_tosell' => array('name'=>'status_tosell','type'=>'xsd:string'),
'barcode' => array('name'=>'barcode','type'=>'xsd:string'),
'barcode_type' => array('name'=>'barcode_type','type'=>'xsd:string'),
'country_id' => array('name'=>'country_id','type'=>'xsd:string'),
'country_code' => array('name'=>'country_code','type'=>'xsd:string'),
'customcode' => array('name'=>'customcode','type'=>'xsd:string'),
'price_net' => array('name'=>'price_net','type'=>'xsd:string'),
'price' => array('name'=>'price','type'=>'xsd:string'),
'price_base_type' => array('name'=>'price_base_type','type'=>'xsd:string'),
'stock_alert' => array('name'=>'stock_alert','type'=>'xsd:string'),
'stock_real' => array('name'=>'stock_real','type'=>'xsd:string'),
'stock_pmp' => array('name'=>'stock_pmp','type'=>'xsd:string'),
'canvas' => array('name'=>'canvas','type'=>'xsd:string'),
'import_key' => array('name'=>'import_key','type'=>'xsd:string')
)
);
// 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped
// Style merely dictates how to translate a WSDL binding to a SOAP message. Nothing more. You can use either style with any programming model.
// http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
$styledoc='rpc'; // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
$styleuse='encoded'; // encoded/literal/literal wrapped
// Better choice is document/literal wrapped but literal wrapped not supported by nusoap.
// Register WSDL
$server->register(
'getProductOrService',
// Entry values
array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
// Exit values
array('result'=>'tns:result','product'=>'tns:product'),
$ns,
$ns.'#getProductOrService',
$styledoc,
$styleuse,
'WS to get product or service'
);
// Register WSDL
$server->register(
'createProductOrService',
// Entry values
array('authentication'=>'tns:authentication','product'=>'tns:product'),
// Exit values
array('result'=>'tns:result','id'=>'xsd:string'),
$ns,
$ns.'#createProductOrService',
$styledoc,
$styleuse,
'WS to create a product or service'
);
/**
* Get produt or service
*
* @param array $authentication Array of authentication information
*/
function getProductOrService($authentication,$id='',$ref='',$ref_ext='')
{
global $db,$conf,$langs;
dol_syslog("Function: getProductOrService login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
if ($authentication['entity']) $conf->entity=$authentication['entity'];
// Init and check authentication
$objectresp=array();
$errorcode='';$errorlabel='';
$error=0;
$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
// Check parameters
if (! $error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
{
$error++;
$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
}
if (! $error)
{
$fuser->getrights();
if ($fuser->rights->produit->lire || $fuser->rights->service->lire)
{
$product=new Product($db);
$result=$product->fetch($id,$ref,$ref_ext);
if ($result > 0)
{
// Create
$objectresp = array(
'result'=>array('result_code'=>'OK', 'result_label'=>''),
'product'=>array(
'id' => $product->id,
'ref' => $product->ref,
'ref_ext' => $product->ref_ext,
'label' => $product->label,
'description' => $product->description,
'date_creation' => $product->date_creation,
'date_modification' => $product->date_modification,
'note' => $product->note,
'status_tosell' => $product->status,
'status_tobuy' => $product->status_buy,
'type' => $product->type,
'barcode' => $product->barcode,
'barcode_type' => $product->barcode_type,
'country_id' => $product->country_id>0?$product->country_id:'',
'country_code' => $product->country_code,
'custom_code' => $product->customcode,
'price_net' => $product->price,
'price' => ($product->price_ttc-$product->price),
'vat_rate' => $product->tva_tx,
'price_base_type' => $product->price_base_type,
'stock_real' => $product->stock_reel,
'stock_alert' => $product->seuil_stock_alerte,
'pmp' => $product->pmp,
'import_key' => $product->import_key
));
}
else
{
$error++;
$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
}
}
else
{
$error++;
$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
}
}
if ($error)
{
$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
}
return $objectresp;
}
/**
* Create an invoice
*
* @param array $authentication Array of authentication information
* @param Product $product Product
* @return array Array result
*/
function createProductOrService($authentication,$product)
{
global $db,$conf,$langs;
$now=dol_now();
dol_syslog("Function: createProductOrService login=".$authentication['login']);
if ($authentication['entity']) $conf->entity=$authentication['entity'];
// Init and check authentication
$objectresp=array();
$errorcode='';$errorlabel='';
$error=0;
$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
// Check parameters
if ($product['price_net'] > 0) $product['price_base_type']='HT';
if ($product['price'] > 0) $product['price_base_type']='TTC';
if ($product['price_net'] > 0 && $product['price'] > 0)
{
$error++; $errorcode='KO'; $errorlabel="You must choose between price or price_net to provide price.";
}
if (! $error)
{
include_once(DOL_DOCUMENT_ROOT.'/lib/company.lib.php');
$newobject=new Product($db);
$newobject->ref=$product['ref'];
$newobject->ref_ext=$product['ref_ext'];
$newobject->type=$product['type'];
$newobject->libelle=$product['label']; // TODO deprecated
$newobject->label=$product['label'];
$newobject->description=$product['description'];
$newobject->note=$product['note'];
$newobject->status=$product['status_tosell'];
$newobject->status_buy=$product['status_tobuy'];
$newobject->price=$product['price_net'];
$newobject->price_ttc=$product['price'];
$newobject->tva_tx=$product['vat_rate'];
$newobject->price_base_type=$product['price_base_type'];
$newobject->date_creation=$now;
$newobject->stock_reel=$product['stock_real'];
$newobject->pmp=$product['pmp'];
$newobject->seuil_stock_alert=$product['stock_alert'];
$newobject->country_id=$product['country_id'];
if ($product['country_code']) $newobject->country_id=getCountry($product['country_code'],3);
$newobject->customcode=$product['customcode'];
$newobject->canvas=$product['canvas'];
/*foreach($product['lines'] as $line)
{
$newline=new FactureLigne($db);
$newline->type=$line['type'];
$newline->desc=$line['desc'];
$newline->fk_product=$line['fk_product'];
$newline->total_ht=$line['total_net'];
$newline->total_vat=$line['total_vat'];
$newline->total_ttc=$line['total'];
$newline->vat=$line['vat_rate'];
$newline->qty=$line['qty'];
$newline->fk_product=$line['product_id'];
}*/
//var_dump($product['ref_ext']);
//var_dump($product['lines'][0]['type']);
$db->begin();
$result=$newobject->create($fuser,0);
if ($result <= 0)
{
$error++;
}
if (! $error)
{
$db->commit();
$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref);
}
else
{
$db->rollback();
$error++;
$errorcode='KO';
$errorlabel=$newobject->error;
}
}
if ($error)
{
$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
}
return $objectresp;
}
// Return the results.
$server->service($HTTP_RAW_POST_DATA);
?>

View File

@ -52,21 +52,35 @@ $server->configureWSDL('WebServicesDolibarrSupplierInvoice',$ns);
$server->wsdl->schemaTargetNamespace=$ns;
// Define WSDL content
// Define WSDL Authentication object
$server->wsdl->addComplexType(
'authentication',
'complexType',
'struct',
'all',
'',
array(
'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
'login' => array('name'=>'login','type'=>'xsd:string'),
'password' => array('name'=>'password','type'=>'xsd:string'),
'entity' => array('name'=>'entity','type'=>'xsd:string'),
));
'authentication',
'complexType',
'struct',
'all',
'',
array(
'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
'login' => array('name'=>'login','type'=>'xsd:string'),
'password' => array('name'=>'password','type'=>'xsd:string'),
'entity' => array('name'=>'entity','type'=>'xsd:string'),
)
);
// Define WSDL Return object
$server->wsdl->addComplexType(
'result',
'complexType',
'struct',
'all',
'',
array(
'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
)
);
// Define other specific objects
$server->wsdl->addComplexType(
'line',
'element',
@ -163,16 +177,6 @@ $server->wsdl->addComplexType(
'tns:invoice'
);
$server->wsdl->addComplexType(
'result',
'complexType',
'struct',
'all',
'',
array(
'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
));
// 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped
@ -183,27 +187,29 @@ $styleuse='encoded'; // encoded/literal/literal wrapped
// Better choice is document/literal wrapped but literal wrapped not supported by nusoap.
// Register WSDL
$server->register('getSupplierInvoice',
// Entry values
array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
// Exit values
array('result'=>'tns:result','invoice'=>'tns:invoice'),
$ns,
$ns.'#getSupplierInvoice',
$styledoc,
$styleuse,
'WS to get SupplierInvoice'
$server->register(
'getSupplierInvoice',
// Entry values
array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
// Exit values
array('result'=>'tns:result','invoice'=>'tns:invoice'),
$ns,
$ns.'#getSupplierInvoice',
$styledoc,
$styleuse,
'WS to get SupplierInvoice'
);
$server->register('getSupplierInvoicesForThirdParty',
// Entry values
array('authentication'=>'tns:authentication','idthirdparty'=>'xsd:string'),
// Exit values
array('result'=>'tns:result','invoices'=>'tns:invoices'),
$ns,
$ns.'#getSupplierInvoicesForThirdParty',
$styledoc,
$styleuse,
'WS to get SupplierInvoicesForThirdParty'
$server->register(
'getSupplierInvoicesForThirdParty',
// Entry values
array('authentication'=>'tns:authentication','idthirdparty'=>'xsd:string'),
// Exit values
array('result'=>'tns:result','invoices'=>'tns:invoices'),
$ns,
$ns.'#getSupplierInvoicesForThirdParty',
$styledoc,
$styleuse,
'WS to get SupplierInvoicesForThirdParty'
);

View File

@ -52,67 +52,70 @@ $server->configureWSDL('WebServicesDolibarrThirdParty',$ns);
$server->wsdl->schemaTargetNamespace=$ns;
// Define WSDL content
// Define WSDL Authentication object
$server->wsdl->addComplexType(
'authentication',
'complexType',
'struct',
'all',
'',
array(
'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
'login' => array('name'=>'login','type'=>'xsd:string'),
'password' => array('name'=>'password','type'=>'xsd:string'),
'entity' => array('name'=>'entity','type'=>'xsd:string'),
));
'authentication',
'complexType',
'struct',
'all',
'',
array(
'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
'login' => array('name'=>'login','type'=>'xsd:string'),
'password' => array('name'=>'password','type'=>'xsd:string'),
'entity' => array('name'=>'entity','type'=>'xsd:string'),
)
);
// Define WSDL Return object
$server->wsdl->addComplexType(
'result',
'complexType',
'struct',
'all',
'',
array(
'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
)
);
// Define other specific objects
$server->wsdl->addComplexType(
'thirdparty',
'complexType',
'struct',
'all',
'',
array(
'id' => array('name'=>'id','type'=>'xsd:string'),
'ref' => array('name'=>'name','type'=>'xsd:string'),
'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'),
'fk_user_author' => array('name'=>'fk_user_author','type'=>'xsd:string'),
'date' => array('name'=>'date','type'=>'xsd:date'),
'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'),
'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'),
'note' => array('name'=>'note','type'=>'xsd:string'),
'address' => array('name'=>'address','type'=>'xsd:string'),
'zip' => array('name'=>'zip','type'=>'xsd:string'),
'town' => array('name'=>'town','type'=>'xsd:string'),
'province_id' => array('name'=>'province_id','type'=>'xsd:string'),
'country_id' => array('name'=>'country_id','type'=>'xsd:string'),
'country_code' => array('name'=>'country_code','type'=>'xsd:string'),
'country' => array('name'=>'country','type'=>'xsd:string'),
'phone' => array('name'=>'country_id','type'=>'xsd:string'),
'fax' => array('name'=>'country_id','type'=>'xsd:string'),
'email' => array('name'=>'country_id','type'=>'xsd:string'),
'url' => array('name'=>'country_id','type'=>'xsd:string'),
'profid1' => array('name'=>'profid1','type'=>'xsd:string'),
'profid2' => array('name'=>'profid2','type'=>'xsd:string'),
'profid3' => array('name'=>'profid3','type'=>'xsd:string'),
'profid4' => array('name'=>'profid4','type'=>'xsd:string'),
'prefix' => array('name'=>'prefix','type'=>'xsd:string'),
'vat_used' => array('name'=>'vat_used','type'=>'xsd:string'),
'vat_number' => array('name'=>'vat_number','type'=>'xsd:string')
)
);
$server->wsdl->addComplexType(
'result',
'complexType',
'struct',
'all',
'',
array(
'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
));
'thirdparty',
'complexType',
'struct',
'all',
'',
array(
'id' => array('name'=>'id','type'=>'xsd:string'),
'ref' => array('name'=>'name','type'=>'xsd:string'),
'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'),
'fk_user_author' => array('name'=>'fk_user_author','type'=>'xsd:string'),
'date' => array('name'=>'date','type'=>'xsd:date'),
'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'),
'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'),
'note' => array('name'=>'note','type'=>'xsd:string'),
'address' => array('name'=>'address','type'=>'xsd:string'),
'zip' => array('name'=>'zip','type'=>'xsd:string'),
'town' => array('name'=>'town','type'=>'xsd:string'),
'province_id' => array('name'=>'province_id','type'=>'xsd:string'),
'country_id' => array('name'=>'country_id','type'=>'xsd:string'),
'country_code' => array('name'=>'country_code','type'=>'xsd:string'),
'country' => array('name'=>'country','type'=>'xsd:string'),
'phone' => array('name'=>'country_id','type'=>'xsd:string'),
'fax' => array('name'=>'country_id','type'=>'xsd:string'),
'email' => array('name'=>'country_id','type'=>'xsd:string'),
'url' => array('name'=>'country_id','type'=>'xsd:string'),
'profid1' => array('name'=>'profid1','type'=>'xsd:string'),
'profid2' => array('name'=>'profid2','type'=>'xsd:string'),
'profid3' => array('name'=>'profid3','type'=>'xsd:string'),
'profid4' => array('name'=>'profid4','type'=>'xsd:string'),
'prefix' => array('name'=>'prefix','type'=>'xsd:string'),
'vat_used' => array('name'=>'vat_used','type'=>'xsd:string'),
'vat_number' => array('name'=>'vat_number','type'=>'xsd:string')
)
);
// 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped
@ -123,16 +126,17 @@ $styleuse='encoded'; // encoded/literal/literal wrapped
// Better choice is document/literal wrapped but literal wrapped not supported by nusoap.
// Register WSDL
$server->register('getThirdParty',
// Entry values
array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
// Exit values
array('result'=>'tns:result','thirdparty'=>'tns:thirdparty'),
$ns,
$ns.'#getVersions',
$styledoc,
$styleuse,
'WS to get Versions'
$server->register(
'getThirdParty',
// Entry values
array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
// Exit values
array('result'=>'tns:result','thirdparty'=>'tns:thirdparty'),
$ns,
$ns.'#getVersions',
$styledoc,
$styleuse,
'WS to get Versions'
);

View File

@ -45,6 +45,11 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
*/
class AllTests
{
/**
* Function suite to make all PHPUnit tests
*
* @return void
*/
public static function suite()
{
$suite = new PHPUnit_Framework_TestSuite('PHPUnit Framework');
@ -75,6 +80,9 @@ class AllTests
require_once dirname(__FILE__).'/DiscountTest.php';
$suite->addTestSuite('DiscountTest');
require_once dirname(__FILE__).'/ProductTest.php';
$suite->addTestSuite('ProductTest');
require_once dirname(__FILE__).'/CommandeTest.php';
$suite->addTestSuite('CommandeTest');
require_once dirname(__FILE__).'/CommandeFournisseurTest.php';

246
test/phpunit/ProductTest.php Executable file
View File

@ -0,0 +1,246 @@
<?php
/* Copyright (C) 2010 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* \file test/phpunit/ProductTest.php
* \ingroup test
* \brief PHPUnit test
* \remarks To run this script as CLI: phpunit filename.php
*/
global $conf,$user,$langs,$db;
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
require_once 'PHPUnit/Autoload.php';
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
require_once dirname(__FILE__).'/../../htdocs/product/class/product.class.php';
if (empty($user->id))
{
print "Load permissions for admin user nb 1\n";
$user->fetch(1);
$user->getrights();
}
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
*/
class ProductTest extends PHPUnit_Framework_TestCase
{
protected $savconf;
protected $savuser;
protected $savlangs;
protected $savdb;
/**
* Constructor
* We save global variables into local variables
*
* @return ProductTest
*/
function ProductTest()
{
//$this->sharedFixture
global $conf,$user,$langs,$db;
$this->savconf=$conf;
$this->savuser=$user;
$this->savlangs=$langs;
$this->savdb=$db;
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
//print " - db ".$db->db;
print "\n";
}
// Static methods
public static function setUpBeforeClass()
{
global $conf,$user,$langs,$db;
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
print __METHOD__."\n";
}
public static function tearDownAfterClass()
{
global $conf,$user,$langs,$db;
$db->rollback();
print __METHOD__."\n";
}
/**
*/
protected function setUp()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
print __METHOD__."\n";
}
/**
*/
protected function tearDown()
{
print __METHOD__."\n";
}
/**
*/
public function testProductCreate()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new Product($this->savdb);
$localobject->initAsSpecimen();
$result=$localobject->create($user);
print __METHOD__." result=".$result."\n";
$this->assertLessThanOrEqual($result, 0);
return $result;
}
/**
* @depends testProductCreate
* The depends says test is run only if previous is ok
*/
public function testProductFetch($id)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new Product($this->savdb);
$result=$localobject->fetch($id);
print __METHOD__." id=".$id." result=".$result."\n";
$this->assertLessThan($result, 0);
return $localobject;
}
/**
* @depends testProductFetch
* The depends says test is run only if previous is ok
*/
public function testProductUpdate($localobject)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject->note='New note after update';
$result=$localobject->update($localobject->id,$user);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
return $localobject;
}
/**
* @depends testProductUpdate
* The depends says test is run only if previous is ok
*/
public function testProductOther($localobject)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
return $localobject->id;
}
/**
* @depends testProductOther
* The depends says test is run only if previous is ok
*/
public function testProductDelete($id)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new Product($this->savdb);
$result=$localobject->fetch($id);
$result=$localobject->delete($id);
print __METHOD__." id=".$id." result=".$result."\n";
$this->assertLessThan($result, 0);
return $result;
}
/**
*
*/
/*public function testVerifyNumRef()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new Adherent($this->savdb);
$result=$localobject->ref='refthatdoesnotexists';
$result=$localobject->VerifyNumRef();
print __METHOD__." result=".$result."\n";
$this->assertEquals($result, 0);
return $result;
}*/
/**
*/
public function testProductStatic()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new Product($db);
return;
}
}
?>

View File

@ -167,9 +167,42 @@ class SocieteTest extends PHPUnit_Framework_TestCase
$db=$this->savdb;
$localobject->note='New note after update';
$result=$localobject->update($localobject->id,$user);
//$localobject->note_public='New note public after update';
$localobject->name='New name';
$localobject->address='New address';
$localobject->zip='New zip';
$localobject->town='New town';
$localobject->status=0;
$localobject->tel='New tel';
$localobject->fax='New fax';
$localobject->email='New email';
$localobject->url='New url';
$result=$localobject->update($localobject->id,$user);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
$result=$localobject->update_note($localobject->note);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
//$result=$localobject->update_note_public($localobject->note_public);
//print __METHOD__." id=".$localobject->id." result=".$result."\n";
//$this->assertLessThan($result, 0);
$newobject=new Societe($this->savdb);
$result=$newobject->fetch($localobject->id);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
$this->assertEquals($localobject->note, $newobject->note);
//$this->assertEquals($localobject->note_public, $newobject->note_public);
$this->assertEquals($localobject->name, $newobject->name);
$this->assertEquals($localobject->address, $newobject->address);
$this->assertEquals($localobject->zip, $newobject->zip);
$this->assertEquals($localobject->town, $newobject->town);
$this->assertEquals($localobject->status, $newobject->status);
$this->assertEquals($localobject->tel, $newobject->tel);
$this->assertEquals($localobject->fax, $newobject->fax);
$this->assertEquals($localobject->email, $newobject->email);
$this->assertEquals($localobject->url, $newobject->url);
return $localobject;
}
@ -208,7 +241,7 @@ class SocieteTest extends PHPUnit_Framework_TestCase
$result=$localobject->getFullAddress();
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertContains('MyTown', $result);
$this->assertContains("New address\nNew zip New town", $result);
$result=$localobject->isInEEC();
print __METHOD__." id=".$localobject->id." pays_code=".$this->pays_code." result=".$result."\n";

View File

@ -9,7 +9,7 @@
colors="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
syntaxCheck="true">
<filter>
<blacklist>
<directory suffix=".php">../../build/</directory>

View File

@ -55,16 +55,16 @@
<soap:address location="http://localhost/dolibarrnew/webservices/server_other.php"/>
</port>
</service>
</definitions>]]></con:content><con:type>http://schemas.xmlsoap.org/wsdl/</con:type></con:part></con:definitionCache><con:endpoints><con:endpoint>http://localhost/dolibarrnew/webservices/server_other.php</con:endpoint></con:endpoints><con:operation isOneWay="false" action="http://www.dolibarr.org/ns/#getVersions" name="getVersions" bindingOperationName="getVersions" type="Request-Response" inputName="" receivesAttachments="false" sendsAttachments="false" anonymous="optional"><con:settings/><con:call name="Request 1"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers">&lt;xml-fragment/></con:setting></con:settings><con:encoding>UTF-8</con:encoding><con:endpoint>http://localhost/dolibarrnew/webservices/server_other.php</con:endpoint><con:request><![CDATA[<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.dolibarr.org/ns/">
</definitions>]]></con:content><con:type>http://schemas.xmlsoap.org/wsdl/</con:type></con:part></con:definitionCache><con:endpoints><con:endpoint>http://localhostdolibarr/dolibarrnew/webservices/server_other.php</con:endpoint></con:endpoints><con:operation isOneWay="false" action="http://www.dolibarr.org/ns/#getVersions" name="getVersions" bindingOperationName="getVersions" type="Request-Response" inputName="" receivesAttachments="false" sendsAttachments="false" anonymous="optional"><con:settings/><con:call name="Request 1"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers">&lt;xml-fragment/></con:setting></con:settings><con:encoding>UTF-8</con:encoding><con:endpoint>http://localhostdolibarr/dolibarrnew/webservices/server_other.php</con:endpoint><con:request><![CDATA[<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.dolibarr.org/ns/">
<soapenv:Header/>
<soapenv:Body>
<ns:getVersions soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<authentication xsi:type="ns:authentication">
<!--You may enter the following 5 items in any order-->
<dolibarrkey xsi:type="xsd:string">?</dolibarrkey>
<dolibarrkey xsi:type="xsd:string">dolibarrkey</dolibarrkey>
<sourceapplication xsi:type="xsd:string">?</sourceapplication>
<login xsi:type="xsd:string">?</login>
<password xsi:type="xsd:string">?</password>
<login xsi:type="xsd:string">admin</login>
<password xsi:type="xsd:string">admin</password>
<entity xsi:type="xsd:string"></entity>
</authentication>
</ns:getVersions>
@ -341,7 +341,7 @@
<soap:address location="http://localhost/dolibarrnew/webservices/server_invoice.php"/>
</port>
</service>
</definitions>]]></con:content><con:type>http://schemas.xmlsoap.org/wsdl/</con:type></con:part></con:definitionCache><con:endpoints><con:endpoint>http://localhost/dolibarrnew/webservices/server_invoice.php</con:endpoint></con:endpoints><con:operation isOneWay="false" action="http://www.dolibarr.org/ns/#createInvoice" name="createInvoice" bindingOperationName="createInvoice" type="Request-Response" inputName="" receivesAttachments="false" sendsAttachments="false" anonymous="optional"><con:settings/><con:call name="Request 1"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers">&lt;xml-fragment/></con:setting></con:settings><con:encoding>UTF-8</con:encoding><con:endpoint>http://localhost/dolibarrnew/webservices/server_invoice.php</con:endpoint><con:request><![CDATA[<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.dolibarr.org/ns/">
</definitions>]]></con:content><con:type>http://schemas.xmlsoap.org/wsdl/</con:type></con:part></con:definitionCache><con:endpoints><con:endpoint>http://localhostdolibarr/dolibarrnew/webservices/server_invoice.php</con:endpoint></con:endpoints><con:operation isOneWay="false" action="http://www.dolibarr.org/ns/#createInvoice" name="createInvoice" bindingOperationName="createInvoice" type="Request-Response" inputName="" receivesAttachments="false" sendsAttachments="false" anonymous="optional"><con:settings/><con:call name="Request 1"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers">&lt;xml-fragment/></con:setting></con:settings><con:encoding>UTF-8</con:encoding><con:endpoint>http://localhostdolibarr/dolibarrnew/webservices/server_invoice.php</con:endpoint><con:request><![CDATA[<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.dolibarr.org/ns/">
<soapenv:Header/>
<soapenv:Body>
<ns:createInvoice soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
@ -394,13 +394,71 @@
</invoice>
</ns:createInvoice>
</soapenv:Body>
</soapenv:Envelope>]]></con:request><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:wsaConfig mustUnderstand="NONE" version="200508" action="http://www.dolibarr.org/ns/#createInvoice"/><con:wsrmConfig version="1.2"/></con:call></con:operation><con:operation isOneWay="false" action="http://www.dolibarr.org/ns/#getInvoice" name="getInvoice" bindingOperationName="getInvoice" type="Request-Response" inputName="" receivesAttachments="false" sendsAttachments="false" anonymous="optional"><con:settings/><con:call name="Request 1"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers">&lt;xml-fragment/></con:setting></con:settings><con:encoding>UTF-8</con:encoding><con:endpoint>http://localhost/dolibarrnew/webservices/server_invoice.php</con:endpoint><con:request><![CDATA[<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.dolibarr.org/ns/">
</soapenv:Envelope>]]></con:request><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:wsaConfig mustUnderstand="NONE" version="200508" action="http://www.dolibarr.org/ns/#createInvoice"/><con:wsrmConfig version="1.2"/></con:call><con:call name="Request 2"><con:settings/><con:encoding>UTF-8</con:encoding><con:endpoint>http://localhostdolibarr/dolibarrnew/webservices/server_invoice.php</con:endpoint><con:request><![CDATA[<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.dolibarr.org/ns/">
<soapenv:Header/>
<soapenv:Body>
<ns:createInvoice soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<authentication xsi:type="ns:authentication">
<!--You may enter the following 5 items in any order-->
<dolibarrkey xsi:type="xsd:string">?</dolibarrkey>
<sourceapplication xsi:type="xsd:string">?</sourceapplication>
<login xsi:type="xsd:string">?</login>
<password xsi:type="xsd:string">?</password>
<entity xsi:type="xsd:string">?</entity>
</authentication>
<invoice xsi:type="ns:invoice">
<!--You may enter the following 22 items in any order-->
<id xsi:type="xsd:string">?</id>
<ref xsi:type="xsd:string">?</ref>
<ref_ext xsi:type="xsd:string">?</ref_ext>
<thirdparty_id xsi:type="xsd:int">?</thirdparty_id>
<fk_user_author xsi:type="xsd:string">?</fk_user_author>
<fk_user_valid xsi:type="xsd:string">?</fk_user_valid>
<date xsi:type="xsd:date">?</date>
<date_due xsi:type="xsd:date">?</date_due>
<date_creation xsi:type="xsd:dateTime">?</date_creation>
<date_validation xsi:type="xsd:dateTime">?</date_validation>
<date_modification xsi:type="xsd:dateTime">?</date_modification>
<type xsi:type="xsd:int">?</type>
<total_net xsi:type="xsd:double">?</total_net>
<total_vat xsi:type="xsd:double">?</total_vat>
<total xsi:type="xsd:double">?</total>
<note xsi:type="xsd:string">?</note>
<note_public xsi:type="xsd:string">?</note_public>
<status xsi:type="xsd:int">?</status>
<close_code xsi:type="xsd:string">?</close_code>
<close_note xsi:type="xsd:string">?</close_note>
<project_id xsi:type="xsd:string">?</project_id>
<lines xsi:type="ns:LinesArray2">
<!--Zero or more repetitions:-->
<line xsi:type="ns:line">
<!--You may enter the following 14 items in any order-->
<id xsi:type="xsd:string">?</id>
<type xsi:type="xsd:int">?</type>
<desc xsi:type="xsd:string">?</desc>
<total_net xsi:type="xsd:double">?</total_net>
<total_vat xsi:type="xsd:double">?</total_vat>
<total xsi:type="xsd:double">?</total>
<vat_rate xsi:type="xsd:double">?</vat_rate>
<qty xsi:type="xsd:double">?</qty>
<date_start xsi:type="xsd:date">?</date_start>
<date_end xsi:type="xsd:date">?</date_end>
<product_id xsi:type="xsd:int">?</product_id>
<product_ref xsi:type="xsd:string">?</product_ref>
<product_label xsi:type="xsd:string">?</product_label>
<product_desc xsi:type="xsd:string">?</product_desc>
</line>
</lines>
</invoice>
</ns:createInvoice>
</soapenv:Body>
</soapenv:Envelope>]]></con:request><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:wsaConfig mustUnderstand="NONE" version="200508" action="http://www.dolibarr.org/ns/#createInvoice"/><con:wsrmConfig version="1.2"/></con:call></con:operation><con:operation isOneWay="false" action="http://www.dolibarr.org/ns/#getInvoice" name="getInvoice" bindingOperationName="getInvoice" type="Request-Response" inputName="" receivesAttachments="false" sendsAttachments="false" anonymous="optional"><con:settings/><con:call name="Request 1"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers">&lt;xml-fragment/></con:setting></con:settings><con:encoding>UTF-8</con:encoding><con:endpoint>http://localhostdolibarr/dolibarrnew/webservices/server_invoice.php</con:endpoint><con:request><![CDATA[<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.dolibarr.org/ns/">
<soapenv:Header/>
<soapenv:Body>
<ns:getInvoice soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<authentication xsi:type="ns:authentication">
<!--You may enter the following 5 items in any order-->
<dolibarrkey xsi:type="xsd:string">?</dolibarrkey>
<dolibarrkey xsi:type="xsd:string">dolibarrkey</dolibarrkey>
<sourceapplication xsi:type="xsd:string">?</sourceapplication>
<login xsi:type="xsd:string">admin</login>
<password xsi:type="xsd:string">admin</password>
@ -411,7 +469,7 @@
<ref_ext xsi:type="xsd:string"></ref_ext>
</ns:getInvoice>
</soapenv:Body>
</soapenv:Envelope>]]></con:request><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:wsaConfig mustUnderstand="NONE" version="200508" action="http://www.dolibarr.org/ns/#getInvoice"/><con:wsrmConfig version="1.2"/></con:call></con:operation><con:operation isOneWay="false" action="http://www.dolibarr.org/ns/#getInvoicesForThirdParty" name="getInvoicesForThirdParty" bindingOperationName="getInvoicesForThirdParty" type="Request-Response" inputName="" receivesAttachments="false" sendsAttachments="false" anonymous="optional"><con:settings/><con:call name="Request 1"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers">&lt;xml-fragment/></con:setting></con:settings><con:encoding>UTF-8</con:encoding><con:endpoint>http://localhost/dolibarrnew/webservices/server_invoice.php</con:endpoint><con:request><![CDATA[<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.dolibarr.org/ns/">
</soapenv:Envelope>]]></con:request><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:wsaConfig mustUnderstand="NONE" version="200508" action="http://www.dolibarr.org/ns/#getInvoice"/><con:wsrmConfig version="1.2"/></con:call></con:operation><con:operation isOneWay="false" action="http://www.dolibarr.org/ns/#getInvoicesForThirdParty" name="getInvoicesForThirdParty" bindingOperationName="getInvoicesForThirdParty" type="Request-Response" inputName="" receivesAttachments="false" sendsAttachments="false" anonymous="optional"><con:settings/><con:call name="Request 1"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers">&lt;xml-fragment/></con:setting></con:settings><con:encoding>UTF-8</con:encoding><con:endpoint>http://localhostdolibarr/dolibarrnew/webservices/server_invoice.php</con:endpoint><con:request><![CDATA[<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.dolibarr.org/ns/">
<soapenv:Header/>
<soapenv:Body>
<ns:getInvoicesForThirdParty soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
@ -601,4 +659,156 @@
<idthirdparty xsi:type="xsd:string">all</idthirdparty>
</ns:getSupplierInvoicesForThirdParty>
</soapenv:Body>
</soapenv:Envelope>]]></con:request><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:wsaConfig mustUnderstand="NONE" version="200508" action="http://www.dolibarr.org/ns/#getSupplierInvoicesForThirdParty"/><con:wsrmConfig version="1.2"/></con:call></con:operation></con:interface><con:properties/><con:wssContainer/></con:soapui-project>
</soapenv:Envelope>]]></con:request><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:wsaConfig mustUnderstand="NONE" version="200508" action="http://www.dolibarr.org/ns/#getSupplierInvoicesForThirdParty"/><con:wsrmConfig version="1.2"/></con:call></con:operation></con:interface><con:interface xsi:type="con:WsdlInterface" wsaVersion="NONE" name="WebServicesDolibarrProductOrServiceBinding" type="wsdl" bindingName="{http://www.dolibarr.org/ns/}WebServicesDolibarrProductOrServiceBinding" soapVersion="1_1" anonymous="optional" definition="http://localhostdolibarr/dolibarrnew/webservices/server_productorservice.php?wsdl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:settings/><con:definitionCache type="TEXT" rootPart="http://localhostdolibarr/dolibarrnew/webservices/server_productorservice.php?wsdl"><con:part><con:url>http://localhostdolibarr/dolibarrnew/webservices/server_productorservice.php?wsdl</con:url><con:content><![CDATA[<definitions targetNamespace="http://www.dolibarr.org/ns/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://www.dolibarr.org/ns/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<xsd:schema targetNamespace="http://www.dolibarr.org/ns/">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
<xsd:complexType name="authentication">
<xsd:all>
<xsd:element name="dolibarrkey" type="xsd:string"/>
<xsd:element name="sourceapplication" type="xsd:string"/>
<xsd:element name="login" type="xsd:string"/>
<xsd:element name="password" type="xsd:string"/>
<xsd:element name="entity" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="result">
<xsd:all>
<xsd:element name="result_code" type="xsd:string"/>
<xsd:element name="result_label" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="product">
<xsd:all>
<xsd:element name="id" type="xsd:string"/>
<xsd:element name="ref" type="xsd:string"/>
<xsd:element name="ref_ext" type="xsd:string"/>
<xsd:element name="type" type="xsd:string"/>
<xsd:element name="label" type="xsd:string"/>
<xsd:element name="description" type="xsd:string"/>
<xsd:element name="date_creation" type="xsd:dateTime"/>
<xsd:element name="date_modification" type="xsd:dateTime"/>
<xsd:element name="note" type="xsd:string"/>
<xsd:element name="tobuy" type="xsd:string"/>
<xsd:element name="tosell" type="xsd:string"/>
<xsd:element name="barcode" type="xsd:string"/>
<xsd:element name="barcode_type" type="xsd:string"/>
<xsd:element name="country_id" type="xsd:string"/>
<xsd:element name="country_code" type="xsd:string"/>
<xsd:element name="customcode" type="xsd:string"/>
<xsd:element name="price_net" type="xsd:string"/>
<xsd:element name="price_vat" type="xsd:string"/>
<xsd:element name="price" type="xsd:string"/>
<xsd:element name="price_base_type" type="xsd:string"/>
<xsd:element name="stock_alert" type="xsd:string"/>
<xsd:element name="stock_real" type="xsd:string"/>
<xsd:element name="stock_pmp" type="xsd:string"/>
<xsd:element name="canvas" type="xsd:string"/>
<xsd:element name="import_key" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
</xsd:schema>
</types>
<message name="createProductOrServiceRequest">
<part name="authentication" type="tns:authentication"/>
<part name="product" type="tns:product"/>
</message>
<message name="createProductOrServiceResponse">
<part name="result" type="tns:result"/>
<part name="id" type="xsd:string"/>
</message>
<message name="getProductOrServiceRequest">
<part name="authentication" type="tns:authentication"/>
<part name="id" type="xsd:string"/>
<part name="ref" type="xsd:string"/>
<part name="ref_ext" type="xsd:string"/>
</message>
<message name="getProductOrServiceResponse">
<part name="result" type="tns:result"/>
<part name="product" type="tns:product"/>
</message>
<portType name="WebServicesDolibarrProductOrServicePortType">
<operation name="createProductOrService">
<documentation>WS to create a product or service</documentation>
<input message="tns:createProductOrServiceRequest"/>
<output message="tns:createProductOrServiceResponse"/>
</operation>
<operation name="getProductOrService">
<documentation>WS to get product or service</documentation>
<input message="tns:getProductOrServiceRequest"/>
<output message="tns:getProductOrServiceResponse"/>
</operation>
</portType>
<binding name="WebServicesDolibarrProductOrServiceBinding" type="tns:WebServicesDolibarrProductOrServicePortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="createProductOrService">
<soap:operation soapAction="http://www.dolibarr.org/ns/#createProductOrService" style="rpc"/>
<input>
<soap:body use="encoded" namespace="http://www.dolibarr.org/ns/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="http://www.dolibarr.org/ns/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="getProductOrService">
<soap:operation soapAction="http://www.dolibarr.org/ns/#getProductOrService" style="rpc"/>
<input>
<soap:body use="encoded" namespace="http://www.dolibarr.org/ns/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="http://www.dolibarr.org/ns/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="WebServicesDolibarrProductOrService">
<port name="WebServicesDolibarrProductOrServicePort" binding="tns:WebServicesDolibarrProductOrServiceBinding">
<soap:address location="http://localhostdolibarr/dolibarrnew/webservices/server_productorservice.php"/>
</port>
</service>
</definitions>]]></con:content><con:type>http://schemas.xmlsoap.org/wsdl/</con:type></con:part></con:definitionCache><con:endpoints><con:endpoint>http://localhostdolibarr/dolibarrnew/webservices/server_productorservice.php</con:endpoint></con:endpoints><con:operation isOneWay="false" action="http://www.dolibarr.org/ns/#createProductOrService" name="createProductOrService" bindingOperationName="createProductOrService" type="Request-Response" inputName="" receivesAttachments="false" sendsAttachments="false" anonymous="optional"><con:settings/><con:call name="Request 1"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers">&lt;xml-fragment/></con:setting></con:settings><con:encoding>UTF-8</con:encoding><con:endpoint>http://localhostdolibarr/dolibarrnew/webservices/server_productorservice.php</con:endpoint><con:request><![CDATA[<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.dolibarr.org/ns/">
<soapenv:Header/>
<soapenv:Body>
<ns:createProductOrService soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<authentication xsi:type="ns:authentication">
<!--You may enter the following 5 items in any order-->
<dolibarrkey xsi:type="xsd:string">?</dolibarrkey>
<sourceapplication xsi:type="xsd:string">?</sourceapplication>
<login xsi:type="xsd:string">?</login>
<password xsi:type="xsd:string">?</password>
<entity xsi:type="xsd:string">?</entity>
</authentication>
<product xsi:type="ns:product">
<!--You may enter the following 18 items in any order-->
<ref xsi:type="xsd:string">PPP</ref>
<ref_ext xsi:type="xsd:string"></ref_ext>
<label xsi:type="xsd:string">PPP Label</label>
<description xsi:type="xsd:string">Description of PPP</description>
<note xsi:type="xsd:string">xxxxx</note>
<tobuy xsi:type="xsd:string">1</tobuy>
<tosell xsi:type="xsd:string">0</tosell>
<type xsi:type="xsd:string">1</type>
<barcode xsi:type="xsd:string">123456</barcode>
<country_code xsi:type="xsd:string">FR</country_code>
<stock_alert xsi:type="xsd:string">10</stock_alert>
</product>
</ns:createProductOrService>
</soapenv:Body>
</soapenv:Envelope>]]></con:request><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:wsaConfig mustUnderstand="NONE" version="200508" action="http://www.dolibarr.org/ns/#createProductOrService"/><con:wsrmConfig version="1.2"/></con:call></con:operation><con:operation isOneWay="false" action="http://www.dolibarr.org/ns/#getProductOrService" name="getProductOrService" bindingOperationName="getProductOrService" type="Request-Response" inputName="" receivesAttachments="false" sendsAttachments="false" anonymous="optional"><con:settings/><con:call name="Request 1"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers">&lt;xml-fragment/></con:setting></con:settings><con:encoding>UTF-8</con:encoding><con:endpoint>http://localhostdolibarr/dolibarrnew/webservices/server_productorservice.php</con:endpoint><con:request><![CDATA[<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.dolibarr.org/ns/">
<soapenv:Header/>
<soapenv:Body>
<ns:getProductOrService soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<authentication xsi:type="ns:authentication">
<!--You may enter the following 5 items in any order-->
<dolibarrkey xsi:type="xsd:string">dolibarrkey</dolibarrkey>
<sourceapplication xsi:type="xsd:string">?</sourceapplication>
<login xsi:type="xsd:string">admin</login>
<password xsi:type="xsd:string">admin</password>
<entity xsi:type="xsd:string"></entity>
</authentication>
<id xsi:type="xsd:string">1</id>
<ref xsi:type="xsd:string"></ref>
<ref_ext xsi:type="xsd:string"></ref_ext>
</ns:getProductOrService>
</soapenv:Body>
</soapenv:Envelope>]]></con:request><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:wsaConfig mustUnderstand="NONE" version="200508" action="http://www.dolibarr.org/ns/#getProductOrService"/><con:wsrmConfig version="1.2"/></con:call></con:operation></con:interface><con:properties/><con:wssContainer/></con:soapui-project>