Merge pull request #1045 from FHenry/3.4

Fix [ bug #934 ] Impossible de créer une facture prédéfinie (pgsql)
This commit is contained in:
Laurent Destailleur 2013-06-13 16:05:01 -07:00
commit b3e81afae4
3 changed files with 32 additions and 14 deletions

View File

@ -125,8 +125,8 @@ class FactureRec extends Facture
$sql.= ", '".$facsrc->socid."'";
$sql.= ", ".$conf->entity;
$sql.= ", ".$this->db->idate($now);
$sql.= ", '".$facsrc->amount."'";
$sql.= ", '".$facsrc->remise."'";
$sql.= ", ".(!empty($facsrc->amount)?$facsrc->amount:'0');
$sql.= ", ".(!empty($facsrc->remise)?$this->remise:'0');
$sql.= ", ".(!empty($this->note_private)?("'".$this->db->escape($this->note_private)."'"):"NULL");
$sql.= ", ".(!empty($this->note_public)?("'".$this->db->escape($this->note_public)."'"):"NULL");
$sql.= ", '".$user->id."'";

View File

@ -1286,7 +1286,6 @@ class Project extends CommonObject
*/
function select_element($Tablename)
{
global $db;
$projectkey="fk_projet";
switch ($Tablename)
@ -1316,25 +1315,27 @@ class Project extends CommonObject
}
$sql.= " ORDER BY ref DESC";
dol_syslog("Project.Lib::select_element sql=".$sql);
dol_syslog(get_class($this).'::select_element sql='.$sql,LOG_DEBUG);
$resql=$db->query($sql);
$resql=$this->db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$num = $this->db->num_rows($resql);
$i = 0;
if ($num > 0)
{
$sellist = '<select class="flat" name="elementselect">';
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$obj = $this->db->fetch_object($resql);
$sellist .='<option value="'.$obj->rowid.'">'.$obj->ref.'</option>';
$i++;
}
$sellist .='</select>';
}
return $sellist ;
$this->db->free($resql);
}
}
@ -1347,8 +1348,8 @@ class Project extends CommonObject
*/
function update_element($TableName, $ElementSelectId)
{
global $db;
$sql="update ".MAIN_DB_PREFIX.$TableName;
$sql="UPDATE ".MAIN_DB_PREFIX.$TableName;
if ($TableName=="actioncomm")
{
$sql.= " SET fk_project=".$this->id;
@ -1359,7 +1360,17 @@ class Project extends CommonObject
$sql.= " SET fk_projet=".$this->id;
$sql.= " WHERE rowid=".$ElementSelectId;
}
$resql=$db->query($sql);
dol_syslog(get_class($this)."::update_element sql=" . $sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql) {
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::update_element error : " . $this->error, LOG_ERR);
return -1;
}else {
return 1;
}
}
}

View File

@ -46,8 +46,10 @@ if (! empty($conf->commande->enabled)) $langs->load("orders");
if (! empty($conf->propal->enabled)) $langs->load("propal");
if (! empty($conf->ficheinter->enabled)) $langs->load("interventions");
$projectid=GETPOST('id');
$ref=GETPOST('ref');
$projectid=GETPOST('id','int');
$ref=GETPOST('ref','alpha');
$action=GETPOST('action','alpha');
if ($projectid == '' && $ref == '')
{
dol_print_error('','Bad parameter');
@ -62,6 +64,8 @@ if ($ref)
{
$project->fetch(0,$ref);
$projectid=$project->id;
}else {
$project->fetch($projectid);
}
// Security check
@ -82,7 +86,7 @@ $form = new Form($db);
$userstatic=new User($db);
$project = new Project($db);
$project->fetch($_GET["id"],$_GET["ref"]);
$project->fetch($projectid,$ref);
$project->societe->fetch($project->societe->id);
// To verify role of users
@ -191,7 +195,10 @@ if ($action=="addelement")
{
$tablename = GETPOST("tablename");
$elementselectid = GETPOST("elementselect");
$project->update_element($tablename, $elementselectid);
$result=$project->update_element($tablename, $elementselectid);
if ($result<0) {
setEventMessage($mailchimp->error,'errors');
}
}
foreach ($listofreferent as $key => $value)