Fix: add note public and private during create

This commit is contained in:
Regis Houssin 2011-10-27 16:04:50 +02:00
parent 892de8a3d2
commit 5899fa6eb7
2 changed files with 49 additions and 26 deletions

View File

@ -87,14 +87,14 @@ class Fichinter extends CommonObject
{ {
global $conf; global $conf;
dol_syslog("Fichinter.class::create ref=".$this->ref); dol_syslog(get_class($this)."::create ref=".$this->ref);
// Check parameters // Check parameters
if (! is_numeric($this->duree)) { $this->duree = 0; } if (! is_numeric($this->duree)) { $this->duree = 0; }
if ($this->socid <= 0) if ($this->socid <= 0)
{ {
$this->error='ErrorBadParameterForFunc'; $this->error='ErrorBadParameterForFunc';
dol_syslog("Fichinter::create ".$this->error,LOG_ERR); dol_syslog(get_class($this)."::create ".$this->error,LOG_ERR);
return -1; return -1;
} }
// on verifie si la ref n'est pas utilisee // on verifie si la ref n'est pas utilisee
@ -106,14 +106,14 @@ class Fichinter extends CommonObject
if ($result > 0) if ($result > 0)
{ {
$this->error='ErrorRefAlreadyExists'; $this->error='ErrorRefAlreadyExists';
dol_syslog("Fichinter::create ".$this->error,LOG_WARNING); dol_syslog(get_class($this)."::create ".$this->error,LOG_WARNING);
$this->db->rollback(); $this->db->rollback();
return -3; return -3;
} }
else if ($result < 0) else if ($result < 0)
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
dol_syslog("Fichinter::create ".$this->error,LOG_ERR); dol_syslog(get_class($this)."::create ".$this->error,LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
} }
@ -133,6 +133,8 @@ class Fichinter extends CommonObject
$sql.= ", model_pdf"; $sql.= ", model_pdf";
$sql.= ", fk_projet"; $sql.= ", fk_projet";
$sql.= ", fk_statut"; $sql.= ", fk_statut";
$sql.= ", note_private";
$sql.= ", note_public";
$sql.= ") "; $sql.= ") ";
$sql.= " VALUES ("; $sql.= " VALUES (";
$sql.= $this->socid; $sql.= $this->socid;
@ -144,9 +146,11 @@ class Fichinter extends CommonObject
$sql.= ", '".$this->modelpdf."'"; $sql.= ", '".$this->modelpdf."'";
$sql.= ", ".($this->fk_project ? $this->fk_project : 0); $sql.= ", ".($this->fk_project ? $this->fk_project : 0);
$sql.= ", ".$this->statut; $sql.= ", ".$this->statut;
$sql.= ", ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null");
$sql.= ", ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null");
$sql.= ")"; $sql.= ")";
dol_syslog("Fichinter::create sql=".$sql); dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
$result=$this->db->query($sql); $result=$this->db->query($sql);
if ($result) if ($result)
{ {
@ -157,7 +161,7 @@ class Fichinter extends CommonObject
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
dol_syslog("Fichinter::create ".$this->error,LOG_ERR); dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
@ -170,30 +174,32 @@ class Fichinter extends CommonObject
*/ */
function update($user) function update($user)
{ {
global $conf;
if (! is_numeric($this->duree)) { $this->duree = 0; } if (! is_numeric($this->duree)) { $this->duree = 0; }
if (! dol_strlen($this->fk_project)) { $this->fk_project = 0; } if (! dol_strlen($this->fk_project)) { $this->fk_project = 0; }
/* $this->db->begin();
* Insertion dans la base
*/
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter SET "; $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter SET ";
$sql.= ", description = '".$this->db->escape($this->description)."'"; $sql.= ", description = '".$this->db->escape($this->description)."'";
$sql.= ", duree = ".$this->duree; $sql.= ", duree = ".$this->duree;
$sql.= ", fk_projet = ".$this->fk_project; $sql.= ", fk_projet = ".$this->fk_project;
$sql.= ", note_private = ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null");
$sql.= ", note_public = ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null");
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
$sql.= " AND entity = ".$conf->entity;
dol_syslog("Fichinter::update sql=".$sql); dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
if (! $this->db->query($sql)) if ($this->db->query($sql))
{
$this->db->commit();
return 1;
}
else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
dol_syslog("Fichinter::update error ".$this->error,LOG_ERR); dol_syslog(get_class($this)."::update error ".$this->error, LOG_ERR);
$this->db->rollback();
return -1; return -1;
} }
return 1;
} }
/** /**
@ -213,7 +219,7 @@ class Fichinter extends CommonObject
if ($ref) $sql.= " WHERE f.ref='".$ref."'"; if ($ref) $sql.= " WHERE f.ref='".$ref."'";
else $sql.= " WHERE f.rowid=".$rowid; else $sql.= " WHERE f.rowid=".$rowid;
dol_syslog("Fichinter::fetch sql=".$sql); dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -252,7 +258,7 @@ class Fichinter extends CommonObject
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
dol_syslog("Fichinter::fetch ".$this->error,LOG_ERR); dol_syslog(get_class($this)."::fetch ".$this->error,LOG_ERR);
return -1; return -1;
} }
} }

View File

@ -118,8 +118,6 @@ if ($action == 'confirm_modify' && $confirm == 'yes')
if ($action == 'add') if ($action == 'add')
{ {
$object = new Fichinter($db);
$object->socid = $socid; $object->socid = $socid;
$object->duree = $_POST["duree"]; $object->duree = $_POST["duree"];
$object->fk_project = $_POST["projectid"]; $object->fk_project = $_POST["projectid"];
@ -127,6 +125,8 @@ if ($action == 'add')
$object->description = $_POST["description"]; $object->description = $_POST["description"];
$object->ref = $ref; $object->ref = $ref;
$object->modelpdf = $_POST["model"]; $object->modelpdf = $_POST["model"];
$object->note_private = $_POST["note_private"];
$object->note_public = $_POST["note_public"];
if ($object->socid > 0) if ($object->socid > 0)
{ {
@ -668,6 +668,12 @@ if ($action == 'create')
// Ref // Ref
print '<tr><td class="fieldrequired">'.$langs->trans("Ref").'</td>'; print '<tr><td class="fieldrequired">'.$langs->trans("Ref").'</td>';
print '<td><input name="ref" value="'.$numpr.'"></td></tr>'."\n"; print '<td><input name="ref" value="'.$numpr.'"></td></tr>'."\n";
// Description (must be a textarea and not html must be allowed (used in list view)
print '<tr><td valign="top">'.$langs->trans("Description").'</td>';
print '<td>';
print '<textarea name="description" cols="80" rows="'.ROWS_3.'"></textarea>';
print '</td></tr>';
// Project // Project
if ($conf->projet->enabled) if ($conf->projet->enabled)
@ -690,12 +696,23 @@ if ($action == 'create')
$liste=ModelePDFFicheinter::liste_modeles($db); $liste=ModelePDFFicheinter::liste_modeles($db);
print $html->selectarray('model',$liste,$conf->global->FICHEINTER_ADDON_PDF); print $html->selectarray('model',$liste,$conf->global->FICHEINTER_ADDON_PDF);
print "</td></tr>"; print "</td></tr>";
// Description (must be a textarea and not html must be allowed (used in list view) // Public note
print '<tr><td valign="top">'.$langs->trans("Description").'</td>'; print '<tr>';
print '<td>'; print '<td class="border" valign="top">'.$langs->trans('NotePublic').'</td>';
print '<textarea name="description" wrap="soft" cols="80" rows="'.ROWS_3.'"></textarea>'; print '<td valign="top" colspan="2">';
print '<textarea name="note_public" cols="80" rows="'.ROWS_3.'"></textarea>';
print '</td></tr>'; print '</td></tr>';
// Private note
if (! $user->societe_id)
{
print '<tr>';
print '<td class="border" valign="top">'.$langs->trans('NotePrivate').'</td>';
print '<td valign="top" colspan="2">';
print '<textarea name="note_private" cols="80" rows="'.ROWS_3.'"></textarea>';
print '</td></tr>';
}
print '</table>'; print '</table>';