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

This commit is contained in:
Laurent Destailleur
2016-05-30 00:52:59 +02:00
14 changed files with 91 additions and 19 deletions

View File

@@ -196,7 +196,7 @@ if ($result > 0)
//print_r($records); //print_r($records);
// Affichage arbre // Affichage arbre
if (count($records) && $records != false && (! isset($records['count']) || $records['count'] > 0)) if ((! is_numeric($records) || $records != 0) && (! isset($records['count']) || $records['count'] > 0))
{ {
if (! is_array($records)) if (! is_array($records))
{ {

View File

@@ -605,7 +605,7 @@ if ($mode != 'marketplace')
else $text.=$langs->trans("No"); else $text.=$langs->trans("No");
$text.='<br><strong>'.$langs->trans("AddMenus").':</strong> '; $text.='<br><strong>'.$langs->trans("AddMenus").':</strong> ';
if (isset($objMod->menu) && is_array($objMod->menu) && $objMod->menu) if (isset($objMod->menu) && is_array($objMod->menu) && ! empty($objMod->menu))
{ {
$text.=$langs->trans("Yes"); $text.=$langs->trans("Yes");
} }

View File

@@ -43,7 +43,6 @@ if (empty($conf->global->MAIN_MODULE_API))
exit; exit;
} }
use \Luracast\Restler\Defaults;
$api = new DolibarrApi($db); $api = new DolibarrApi($db);

View File

@@ -15,9 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
use Luracast\Restler\Restler;
use Luracast\Restler\RestException; use Luracast\Restler\RestException;
use Luracast\Restler\Defaults;
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT.'/api/class/api.class.php'; require_once DOL_DOCUMENT_ROOT.'/api/class/api.class.php';

View File

@@ -55,7 +55,6 @@ if (empty($conf->global->MAIN_MODULE_API))
exit; exit;
} }
use \Luracast\Restler\Defaults;
$api = new DolibarrApi($db); $api = new DolibarrApi($db);

View File

@@ -478,9 +478,20 @@ class Commande extends CommonOrder
} }
} }
if (!$error) {
// Call trigger
$result=$this->call_trigger('ORDER_SETDRAFT',$user);
if ($result < 0) $error++;
}
if (!$error) {
$this->statut=self::STATUS_DRAFT; $this->statut=self::STATUS_DRAFT;
$this->db->commit(); $this->db->commit();
return 1; return 1;
}else {
$this->db->rollback();
return -1;
}
} }
else else
{ {

View File

@@ -761,6 +761,8 @@ class FactureRec extends CommonInvoice
$nownotime=dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); $nownotime=dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']);
$prodids = array(); $prodids = array();
$num_prods = 0;
$sql = "SELECT rowid"; $sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."product"; $sql.= " FROM ".MAIN_DB_PREFIX."product";
$sql.= " WHERE entity IN (".getEntity('product', 1).")"; $sql.= " WHERE entity IN (".getEntity('product', 1).")";

View File

@@ -175,7 +175,7 @@ if ($result > 0)
//var_dump($records); //var_dump($records);
// Affichage arbre // Affichage arbre
if (count($records) && $records != false && (! isset($records['count']) || $records['count'] > 0)) if ((! is_numeric($records) || $records != 0) && (! isset($records['count']) || $records['count'] > 0))
{ {
if (! is_array($records)) if (! is_array($records))
{ {

View File

@@ -823,7 +823,7 @@ class Ldap
* *
* @param string $dn DN entry key * @param string $dn DN entry key
* @param string $filter Filter * @param string $filter Filter
* @return int|false|array <0 or false if KO, array if OK * @return int|array <0 or false if KO, array if OK
*/ */
function getAttribute($dn,$filter) function getAttribute($dn,$filter)
{ {
@@ -848,7 +848,7 @@ class Ldap
{ {
$this->ldapErrorCode = -1; $this->ldapErrorCode = -1;
$this->ldapErrorText = "Couldn't find entry"; $this->ldapErrorText = "Couldn't find entry";
return false; // Couldn't find entry... return 0; // Couldn't find entry...
} }
// Get values // Get values
@@ -856,7 +856,7 @@ class Ldap
{ {
$this->ldapErrorCode = ldap_errno($this->connection); $this->ldapErrorCode = ldap_errno($this->connection);
$this->ldapErrorText = ldap_error($this->connection); $this->ldapErrorText = ldap_error($this->connection);
return false; // No matching attributes return 0; // No matching attributes
} }
// Return an array containing the attributes. // Return an array containing the attributes.

View File

@@ -2778,7 +2778,7 @@ function dol_print_error($db='',$error='',$errors=null)
if (empty($msg)) continue; if (empty($msg)) continue;
if ($_SERVER['DOCUMENT_ROOT']) // Mode web if ($_SERVER['DOCUMENT_ROOT']) // Mode web
{ {
$out.="<b>".$langs->trans("Message").":</b> ".$msg."<br>\n" ; $out.="<b>".$langs->trans("Message").":</b> ".dol_escape_htmltag($msg)."<br>\n" ;
} }
else // Mode CLI else // Mode CLI
{ {

View File

@@ -119,6 +119,7 @@ class InterfaceDemo extends DolibarrTriggers
case 'ORDER_CANCEL': case 'ORDER_CANCEL':
case 'ORDER_SENTBYMAIL': case 'ORDER_SENTBYMAIL':
case 'ORDER_CLASSIFY_BILLED': case 'ORDER_CLASSIFY_BILLED':
case 'ORDER_SETDRAFT':
case 'LINEORDER_INSERT': case 'LINEORDER_INSERT':
case 'LINEORDER_UPDATE': case 'LINEORDER_UPDATE':
case 'LINEORDER_DELETE': case 'LINEORDER_DELETE':
@@ -258,6 +259,9 @@ class InterfaceDemo extends DolibarrTriggers
case 'SHIPPING_MODIFY': case 'SHIPPING_MODIFY':
case 'SHIPPING_VALIDATE': case 'SHIPPING_VALIDATE':
case 'SHIPPING_SENTBYMAIL': case 'SHIPPING_SENTBYMAIL':
case 'SHIPPING_BILLED':
case 'SHIPPING_CLOSED':
case 'SHIPPING_REOPEN':
case 'SHIPPING_DELETE': case 'SHIPPING_DELETE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
break; break;

View File

@@ -1801,6 +1801,10 @@ class Expedition extends CommonObject
function setClosed() function setClosed()
{ {
$error=0;
$this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2';
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0';
@@ -1809,11 +1813,27 @@ class Expedition extends CommonObject
{ {
// TODO: Add option/checkbox to set order billed if 100% of order is shipped // TODO: Add option/checkbox to set order billed if 100% of order is shipped
$this->statut=2; $this->statut=2;
// Call trigger
$result=$this->call_trigger('SHIPPING_CLOSED',$user);
if ($result < 0) {
$error++;
}
} else {
$error++;
$this->errors[]=$this->db->lasterror;
}
if (empty($error)) {
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->db->rollback();
dol_print_error($this->db); dol_print_error($this->db);
return -1; return -1;
} }
} }
@@ -1825,6 +1845,9 @@ class Expedition extends CommonObject
*/ */
function set_billed() function set_billed()
{ {
$error=0;
$this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2, billed=1'; // TODO Update only billed $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2, billed=1'; // TODO Update only billed
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0';
@@ -1834,11 +1857,27 @@ class Expedition extends CommonObject
{ {
$this->statut=2; $this->statut=2;
$this->billed=1; $this->billed=1;
// Call trigger
$result=$this->call_trigger('SHIPPING_BILLED',$user);
if ($result < 0) {
$error++;
}
} else {
$error++;
$this->errors[]=$this->db->lasterror;
}
if (empty($error)) {
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->db->rollback();
dol_print_error($this->db); dol_print_error($this->db);
return -1; return -1;
} }
} }
@@ -1851,6 +1890,10 @@ class Expedition extends CommonObject
function reOpen() function reOpen()
{ {
$error=0;
$this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=1'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=1';
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0';
@@ -1859,11 +1902,27 @@ class Expedition extends CommonObject
{ {
$this->statut=1; $this->statut=1;
$this->billed=0; $this->billed=0;
// Call trigger
$result=$this->call_trigger('SHIPPING_REOPEN',$user);
if ($result < 0) {
$error++;
}
} else {
$error++;
$this->errors[]=$this->db->lasterror;
}
if (empty($error)) {
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->db->rollback();
dol_print_error($this->db); dol_print_error($this->db);
return -1; return -1;
} }
} }

View File

@@ -177,7 +177,7 @@ if ($result > 0)
//var_dump($records); //var_dump($records);
// Affichage arbre // Affichage arbre
if (count($records) && $records != false && (! isset($records['count']) || $records['count'] > 0)) if ((! is_numeric($records) || $records != 0) && (! isset($records['count']) || $records['count'] > 0))
{ {
if (! is_array($records)) if (! is_array($records))
{ {

View File

@@ -186,7 +186,7 @@ if ($result > 0)
//print_r($records); //print_r($records);
// Affichage arbre // Affichage arbre
if (count($records) && $records != false && (! isset($records['count']) || $records['count'] > 0)) if ((! is_numeric($records) || $records != 0) && (! isset($records['count']) || $records['count'] > 0))
{ {
if (! is_array($records)) if (! is_array($records))
{ {