Fix: Some fix when using fckeditor with notes.

Qual: Uniformize code to use new system for notes.
Qual: Removed duplicate updatenote method into commandefournisseur
class.
This commit is contained in:
Laurent Destailleur
2012-03-18 00:59:24 +01:00
parent d87f14b7ce
commit a7a55645d8
18 changed files with 165 additions and 300 deletions

View File

@@ -157,7 +157,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->
$result = $object->deleteline($lineid); $result = $object->deleteline($lineid);
// reorder lines // reorder lines
if ($result) $object->line_order(true); if ($result) $object->line_order(true);
// Define output language // Define output language
$outputlangs = $langs; $outputlangs = $langs;
$newlang=''; $newlang='';
@@ -173,7 +173,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->
$ret=$object->fetch($id); // Reload to get new records $ret=$object->fetch($id); // Reload to get new records
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
} }
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit; exit;
} }
@@ -249,14 +249,14 @@ else if ($action == 'set_ref_client' && $user->rights->propale->creer)
else if ($action == 'setnote_public' && $user->rights->propale->creer) else if ($action == 'setnote_public' && $user->rights->propale->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note_public(GETPOST('note_public','alpha')); $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
else if ($action == 'setnote' && $user->rights->propale->creer) else if ($action == 'setnote' && $user->rights->propale->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note(GETPOST('note','alpha')); $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
@@ -1049,12 +1049,12 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
if ($action == 'addcontact' && $user->rights->propale->creer) if ($action == 'addcontact' && $user->rights->propale->creer)
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result > 0 && $id > 0) if ($result > 0 && $id > 0)
{ {
$result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); $result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]);
} }
if ($result >= 0) if ($result >= 0)
{ {
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
@@ -1073,7 +1073,7 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
} }
} }
} }
// Bascule du statut d'un contact // Bascule du statut d'un contact
else if ($action == 'swapstatut' && $user->rights->propale->creer) else if ($action == 'swapstatut' && $user->rights->propale->creer)
{ {
@@ -1086,13 +1086,13 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
dol_print_error($db); dol_print_error($db);
} }
} }
// Efface un contact // Efface un contact
else if ($action == 'deletecontact' && $user->rights->propale->creer) else if ($action == 'deletecontact' && $user->rights->propale->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result = $object->delete_contact($lineid); $result = $object->delete_contact($lineid);
if ($result >= 0) if ($result >= 0)
{ {
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
@@ -1537,19 +1537,19 @@ if ($id > 0 || ! empty($ref))
// Statut // Statut
print '<tr><td height="10">'.$langs->trans('Status').'</td><td align="left" colspan="3">'.$object->getLibStatut(4).'</td></tr>'; print '<tr><td height="10">'.$langs->trans('Status').'</td><td align="left" colspan="3">'.$object->getLibStatut(4).'</td></tr>';
print '</table><br>'; print '</table><br>';
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{ {
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$formcompany= new FormCompany($db); $formcompany= new FormCompany($db);
$blocname = 'contacts'; $blocname = 'contacts';
$title = $langs->trans('ContactsAddresses'); $title = $langs->trans('ContactsAddresses');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
} }
if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{ {
$blocname = 'notes'; $blocname = 'notes';

View File

@@ -50,14 +50,14 @@ $object = new Propal($db);
if ($action == 'setnote_public' && $user->rights->propale->creer) if ($action == 'setnote_public' && $user->rights->propale->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note_public(GETPOST('note_public','alpha')); $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
else if ($action == 'setnote' && $user->rights->propale->creer) else if ($action == 'setnote' && $user->rights->propale->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note(GETPOST('note','alpha')); $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
@@ -142,11 +142,11 @@ if ($id > 0 || ! empty($ref))
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print "</table>"; print "</table>";
print '<br>'; print '<br>';
include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'); include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php');
print '</div>'; print '</div>';

View File

@@ -482,14 +482,14 @@ else if ($action == 'setremiseabsolue' && $user->rights->commande->creer)
else if ($action == 'setnote_public' && $user->rights->commande->creer) else if ($action == 'setnote_public' && $user->rights->commande->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note_public(GETPOST('note_public','alpha')); $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
else if ($action == 'setnote' && $user->rights->commande->creer) else if ($action == 'setnote' && $user->rights->commande->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note(GETPOST('note','alpha')); $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
@@ -1196,12 +1196,12 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
if ($action == 'addcontact' && $user->rights->commande->creer) if ($action == 'addcontact' && $user->rights->commande->creer)
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result > 0 && $id > 0) if ($result > 0 && $id > 0)
{ {
$result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); $result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]);
} }
if ($result >= 0) if ($result >= 0)
{ {
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
@@ -1220,7 +1220,7 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
} }
} }
} }
// bascule du statut d'un contact // bascule du statut d'un contact
else if ($action == 'swapstatut' && $user->rights->commande->creer) else if ($action == 'swapstatut' && $user->rights->commande->creer)
{ {
@@ -1233,13 +1233,13 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
dol_print_error($db); dol_print_error($db);
} }
} }
// Efface un contact // Efface un contact
else if ($action == 'deletecontact' && $user->rights->commande->creer) else if ($action == 'deletecontact' && $user->rights->commande->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result = $object->delete_contact($lineid); $result = $object->delete_contact($lineid);
if ($result >= 0) if ($result >= 0)
{ {
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
@@ -2007,20 +2007,20 @@ else
print '<tr><td>'.$langs->trans('Status').'</td>'; print '<tr><td>'.$langs->trans('Status').'</td>';
print '<td colspan="2">'.$object->getLibStatut(4).'</td>'; print '<td colspan="2">'.$object->getLibStatut(4).'</td>';
print '</tr>'; print '</tr>';
print '</table><br>'; print '</table><br>';
print "\n"; print "\n";
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{ {
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$formcompany= new FormCompany($db); $formcompany= new FormCompany($db);
$blocname = 'contacts'; $blocname = 'contacts';
$title = $langs->trans('ContactsAddresses'); $title = $langs->trans('ContactsAddresses');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
} }
if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{ {
$blocname = 'notes'; $blocname = 'notes';

View File

@@ -57,14 +57,14 @@ if (! $object->fetch($id, $ref) > 0)
if ($action == 'setnote_public' && $user->rights->commande->creer) if ($action == 'setnote_public' && $user->rights->commande->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note_public(GETPOST('note_public','alpha')); $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
else if ($action == 'setnote' && $user->rights->commande->creer) else if ($action == 'setnote' && $user->rights->commande->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note(GETPOST('note','alpha')); $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
@@ -106,11 +106,11 @@ if ($id > 0 || ! empty($ref))
// Customer // Customer
print "<tr><td>".$langs->trans("Company")."</td>"; print "<tr><td>".$langs->trans("Company")."</td>";
print '<td colspan="3">'.$soc->getNomUrl(1).'</td></tr>'; print '<td colspan="3">'.$soc->getNomUrl(1).'</td></tr>';
print "</table>"; print "</table>";
print '<br>'; print '<br>';
include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'); include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php');
print '</div>'; print '</div>';

View File

@@ -161,7 +161,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->
{ {
$object->fetch($id); $object->fetch($id);
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$result = $object->deleteline($_GET['lineid'], $user); $result = $object->deleteline($_GET['lineid'], $user);
if ($result > 0) if ($result > 0)
{ {
@@ -313,14 +313,14 @@ else if ($action == 'set_ref_client' && $user->rights->facture->creer)
else if ($action == 'setnote_public' && $user->rights->facture->creer) else if ($action == 'setnote_public' && $user->rights->facture->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note_public(GETPOST('note_public','alpha')); $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
else if ($action == 'setnote' && $user->rights->facture->creer) else if ($action == 'setnote' && $user->rights->facture->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note(GETPOST('note','alpha')); $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
@@ -1511,12 +1511,12 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
if ($action == 'addcontact' && $user->rights->facture->creer) if ($action == 'addcontact' && $user->rights->facture->creer)
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result > 0 && $id > 0) if ($result > 0 && $id > 0)
{ {
$result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); $result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]);
} }
if ($result >= 0) if ($result >= 0)
{ {
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
@@ -1535,7 +1535,7 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
} }
} }
} }
// bascule du statut d'un contact // bascule du statut d'un contact
else if ($action == 'swapstatut' && $user->rights->facture->creer) else if ($action == 'swapstatut' && $user->rights->facture->creer)
{ {
@@ -1548,13 +1548,13 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
dol_print_error($db); dol_print_error($db);
} }
} }
// Efface un contact // Efface un contact
else if ($action == 'deletecontact' && $user->rights->facture->creer) else if ($action == 'deletecontact' && $user->rights->facture->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result = $object->delete_contact($lineid); $result = $object->delete_contact($lineid);
if ($result >= 0) if ($result >= 0)
{ {
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
@@ -2796,18 +2796,18 @@ else
} }
print '</table><br>'; print '</table><br>';
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{ {
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$formcompany= new FormCompany($db); $formcompany= new FormCompany($db);
$blocname = 'contacts'; $blocname = 'contacts';
$title = $langs->trans('ContactsAddresses'); $title = $langs->trans('ContactsAddresses');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
} }
if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{ {
$blocname = 'notes'; $blocname = 'notes';

View File

@@ -52,14 +52,14 @@ $object->fetch($id);
if ($action == 'setnote_public' && $user->rights->facture->creer) if ($action == 'setnote_public' && $user->rights->facture->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note_public(GETPOST('note_public','alpha')); $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
else if ($action == 'setnote' && $user->rights->facture->creer) else if ($action == 'setnote' && $user->rights->facture->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note(GETPOST('note','alpha')); $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }

View File

@@ -52,7 +52,7 @@ if ($_POST["action"] == 'update_public' && $user->rights->contrat->creer)
{ {
$db->begin(); $db->begin();
$res=$contrat->update_note_public($_POST["note_public"],$user); $res=$contrat->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($res < 0) if ($res < 0)
{ {
$mesg='<div class="error">'.$contrat->error.'</div>'; $mesg='<div class="error">'.$contrat->error.'</div>';
@@ -68,7 +68,7 @@ if ($_POST["action"] == 'update' && $user->rights->contrat->creer)
{ {
$db->begin(); $db->begin();
$res=$contrat->update_note($_POST["note"],$user); $res=$contrat->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($res < 0) if ($res < 0)
{ {
$mesg='<div class="error">'.$contrat->error.'</div>'; $mesg='<div class="error">'.$contrat->error.'</div>';

View File

@@ -861,7 +861,7 @@ abstract class CommonObject
return -1; return -1;
} }
} }
/** /**
* Change the payments methods * Change the payments methods
* *
@@ -876,11 +876,11 @@ abstract class CommonObject
// TODO uniformize field name // TODO uniformize field name
$fieldname = 'fk_mode_reglement'; $fieldname = 'fk_mode_reglement';
if ($this->element == 'societe') $fieldname = 'mode_reglement'; if ($this->element == 'societe') $fieldname = 'mode_reglement';
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET '.$fieldname.' = '.$id; $sql .= ' SET '.$fieldname.' = '.$id;
$sql .= ' WHERE rowid='.$this->id; $sql .= ' WHERE rowid='.$this->id;
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$this->mode_reglement_id = $id; $this->mode_reglement_id = $id;
@@ -901,7 +901,7 @@ abstract class CommonObject
return -2; return -2;
} }
} }
/** /**
* Change the payments terms * Change the payments terms
* *
@@ -916,11 +916,11 @@ abstract class CommonObject
// TODO uniformize field name // TODO uniformize field name
$fieldname = 'fk_cond_reglement'; $fieldname = 'fk_cond_reglement';
if ($this->element == 'societe') $fieldname = 'cond_reglement'; if ($this->element == 'societe') $fieldname = 'cond_reglement';
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET '.$fieldname.' = '.$id; $sql .= ' SET '.$fieldname.' = '.$id;
$sql .= ' WHERE rowid='.$this->id; $sql .= ' WHERE rowid='.$this->id;
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$this->cond_reglement_id = $id; $this->cond_reglement_id = $id;
@@ -941,7 +941,7 @@ abstract class CommonObject
return -2; return -2;
} }
} }
/** /**
* Define delivery address * Define delivery address
* *
@@ -952,10 +952,10 @@ abstract class CommonObject
{ {
$fieldname = 'fk_adresse_livraison'; $fieldname = 'fk_adresse_livraison';
if ($this->element == 'delivery' || $this->element == 'shipping') $fieldname = 'fk_address'; if ($this->element == 'delivery' || $this->element == 'shipping') $fieldname = 'fk_address';
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ".$fieldname." = ".$id; $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ".$fieldname." = ".$id;
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$this->fk_delivery_address = $id; $this->fk_delivery_address = $id;
@@ -968,7 +968,7 @@ abstract class CommonObject
return -1; return -1;
} }
} }
/** /**
* Set last model used by doc generator * Set last model used by doc generator
* *
@@ -1390,7 +1390,8 @@ abstract class CommonObject
dol_syslog(get_class($this)."::update_note sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::update_note sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$this->note = $note; $this->note = $note; // deprecated
$this->note_private = $note;
return 1; return 1;
} }
else else
@@ -1574,7 +1575,7 @@ abstract class CommonObject
{ {
$origin = (! empty($origin) ? $origin : $this->origin); $origin = (! empty($origin) ? $origin : $this->origin);
$origin_id = (! empty($origin_id) ? $origin_id : $this->origin_id); $origin_id = (! empty($origin_id) ? $origin_id : $this->origin_id);
$this->db->begin(); $this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
@@ -1826,7 +1827,7 @@ abstract class CommonObject
{ {
$elementId = (!empty($elementId)?$elementId:$this->id); $elementId = (!empty($elementId)?$elementId:$this->id);
$elementTable = (!empty($elementType)?$elementType:$this->table_element); $elementTable = (!empty($elementType)?$elementType:$this->table_element);
$this->db->begin(); $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable; $sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable;
@@ -2127,7 +2128,7 @@ abstract class CommonObject
dol_syslog(get_class($this).'::hasProductsOrServices we found '.$nb.' qualified lines of products/servcies'); dol_syslog(get_class($this).'::hasProductsOrServices we found '.$nb.' qualified lines of products/servcies');
return $nb; return $nb;
} }
/** /**
* Set extra parameters * Set extra parameters
* *
@@ -2136,11 +2137,11 @@ abstract class CommonObject
function setExtraParameters() function setExtraParameters()
{ {
$this->db->begin(); $this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= ' SET extraparams = "'.$this->db->escape(dol_json_encode($this->extraparams)).'"'; $sql.= ' SET extraparams = "'.$this->db->escape(dol_json_encode($this->extraparams)).'"';
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;
dol_syslog(get_class($this)."::setExtraParameters sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::setExtraParameters sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) if (! $resql)
@@ -2156,7 +2157,7 @@ abstract class CommonObject
return 1; return 1;
} }
} }
// -------------------- // --------------------
// TODO: All functions here must be redesigned and moved as they are not business functions but output functions // TODO: All functions here must be redesigned and moved as they are not business functions but output functions

View File

@@ -3178,7 +3178,7 @@ function picto_required()
function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8') function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8')
{ {
$pattern = "/<[^>]+>/"; $pattern = "/<[^>]+>/";
$temp = dol_entity_decode($StringHtml,$pagecodeto); $temp = dol_html_entity_decode($StringHtml,ENT_COMPAT,$pagecodeto);
$temp = preg_replace($pattern,"",$temp); $temp = preg_replace($pattern,"",$temp);
// Supprime aussi les retours // Supprime aussi les retours
@@ -3283,19 +3283,6 @@ function dol_htmlcleanlastbr($stringtodecode)
return $ret; return $ret;
} }
/**
* This function is called to decode a string with HTML entities (it decodes entities tags)
*
* @param string $stringhtml stringhtml
* @param string $pagecodeto Encoding of input string
* @return string decodestring
*/
function dol_entity_decode($stringhtml,$pagecodeto='UTF-8')
{
$ret=dol_html_entity_decode($stringhtml,ENT_COMPAT,$pagecodeto);
return $ret;
}
/** /**
* Replace html_entity_decode functions to manage errors * Replace html_entity_decode functions to manage errors
* *
@@ -3304,7 +3291,7 @@ function dol_entity_decode($stringhtml,$pagecodeto='UTF-8')
* @param string $c Operand c * @param string $c Operand c
* @return string String decoded * @return string String decoded
*/ */
function dol_html_entity_decode($a,$b,$c) function dol_html_entity_decode($a,$b,$c='UTF-8')
{ {
// We use @ to avoid warning on PHP4 that does not support entity decoding to UTF8; // We use @ to avoid warning on PHP4 that does not support entity decoding to UTF8;
$ret=@html_entity_decode($a,$b,$c); $ret=@html_entity_decode($a,$b,$c);
@@ -3319,7 +3306,7 @@ function dol_html_entity_decode($a,$b,$c)
* @param string $c Operand c * @param string $c Operand c
* @return string String encoded * @return string String encoded
*/ */
function dol_htmlentities($a,$b,$c) function dol_htmlentities($a,$b,$c='UTF-8')
{ {
// We use @ to avoid warning on PHP4 that does not support entity decoding to UTF8; // We use @ to avoid warning on PHP4 that does not support entity decoding to UTF8;
$ret=@htmlentities($a,$b,$c); $ret=@htmlentities($a,$b,$c);

View File

@@ -19,8 +19,14 @@
$module = $object->element; $module = $object->element;
$note_public = 'note_public'; $note_public = 'note_public';
$note_private = 'note'; $note_private = 'note';
if ($module == 'propal') $module = 'propale'; $colwidth=(empty($colwidth)?25:$colwidth);
else if ($module == 'fichinter') { $module = 'ficheinter'; $note_private = 'note_private'; } $permission=$user->rights->$module->creer;
// Special cases
if ($module == 'propal') { $module = 'propale'; }
elseif ($module == 'fichinter') { $module = 'ficheinter'; $note_private = 'note_private'; }
elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer; }
elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer; }
if (! empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $typeofdata='ckeditor:dolibarr_notes:100%:200:1:12:100'; if (! empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $typeofdata='ckeditor:dolibarr_notes:100%:200:1:12:100';
else $typeofdata='textarea:12:100'; else $typeofdata='textarea:12:100';
@@ -29,13 +35,13 @@ else $typeofdata='textarea:12:100';
<!-- BEGIN PHP TEMPLATE NOTES --> <!-- BEGIN PHP TEMPLATE NOTES -->
<div class="table-border"> <div class="table-border">
<div class="table-border-row"> <div class="table-border-row">
<div class="table-key-border-col"><?php echo $form->editfieldkey("NotePublic",$note_public,$object->note_public,$object,$user->rights->$module->creer,$typeofdata); ?></div> <div class="table-key-border-col"<?php echo ' style="width: '.$colwidth.'%"'; ?>><?php echo $form->editfieldkey("NotePublic",$note_public,$object->note_public,$object,$permission,$typeofdata); ?></div>
<div class="table-val-border-col"><?php echo $form->editfieldval("NotePublic",$note_public,$object->note_public,$object,$user->rights->$module->creer,$typeofdata); ?></div> <div class="table-val-border-col"><?php echo $form->editfieldval("NotePublic",$note_public,$object->note_public,$object,$permission,$typeofdata); ?></div>
</div> </div>
<?php if (! $user->societe_id) { ?> <?php if (! $user->societe_id) { ?>
<div class="table-border-row"> <div class="table-border-row">
<div class="table-key-border-col"><?php echo $form->editfieldkey("NotePrivate",$note_private,$object->note_private,$object,$user->rights->$module->creer,$typeofdata); ?></div> <div class="table-key-border-col"<?php echo ' style="width: '.$colwidth.'%"'; ?>><?php echo $form->editfieldkey("NotePrivate",$note_private,$object->note_private,$object,$permission,$typeofdata); ?></div>
<div class="table-val-border-col"><?php echo $form->editfieldval("NotePrivate",$note_private,$object->note_private,$object,$user->rights->$module->creer,$typeofdata); ?></div> <div class="table-val-border-col"><?php echo $form->editfieldval("NotePrivate",$note_private,$object->note_private,$object,$permission,$typeofdata); ?></div>
</div> </div>
<?php } ?> <?php } ?>
</div> </div>

View File

@@ -207,7 +207,7 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fich
{ {
$object->fetch($id); $object->fetch($id);
$object->delete($user); $object->delete($user);
Header('Location: '.DOL_URL_ROOT.'/fichinter/list.php?leftmenu=ficheinter'); Header('Location: '.DOL_URL_ROOT.'/fichinter/list.php?leftmenu=ficheinter');
exit; exit;
} }
@@ -221,13 +221,13 @@ else if ($action == 'setdescription' && $user->rights->ficheinter->creer)
else if ($action == 'setnote_public' && $user->rights->ficheinter->creer) else if ($action == 'setnote_public' && $user->rights->ficheinter->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note_public(GETPOST('note_public','alpha')); $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
else if ($action == 'setnote_private' && $user->rights->ficheinter->creer) else if ($action == 'setnote_private' && $user->rights->ficheinter->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note(GETPOST('note_private','alpha')); $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
@@ -366,13 +366,13 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->
exit; exit;
} }
$result=$objectline->deleteline(); $result=$objectline->deleteline();
if ($object->fetch($objectline->fk_fichinter) <= 0) if ($object->fetch($objectline->fk_fichinter) <= 0)
{ {
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
// Define output language // Define output language
$outputlangs = $langs; $outputlangs = $langs;
$newlang=''; $newlang='';
@@ -626,12 +626,12 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
if ($action == 'addcontact' && $user->rights->ficheinter->creer) if ($action == 'addcontact' && $user->rights->ficheinter->creer)
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result > 0 && $id > 0) if ($result > 0 && $id > 0)
{ {
$result = $object->add_contact(GETPOST('contactid','int'), GETPOST('type','int'), GETPOST('source','alpha')); $result = $object->add_contact(GETPOST('contactid','int'), GETPOST('type','int'), GETPOST('source','alpha'));
} }
if ($result >= 0) if ($result >= 0)
{ {
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
@@ -650,7 +650,7 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
} }
} }
} }
// bascule du statut d'un contact // bascule du statut d'un contact
else if ($action == 'swapstatut' && $user->rights->ficheinter->creer) else if ($action == 'swapstatut' && $user->rights->ficheinter->creer)
{ {
@@ -663,13 +663,13 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
dol_print_error($db); dol_print_error($db);
} }
} }
// Efface un contact // Efface un contact
else if ($action == 'deletecontact' && $user->rights->ficheinter->creer) else if ($action == 'deletecontact' && $user->rights->ficheinter->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result = $object->delete_contact(GETPOST('lineid','int')); $result = $object->delete_contact(GETPOST('lineid','int'));
if ($result >= 0) if ($result >= 0)
{ {
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
@@ -914,15 +914,15 @@ else if ($id > 0 || ! empty($ref))
// Statut // Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>'; print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
print "</table><br>"; print "</table><br>";
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{ {
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$formcompany= new FormCompany($db); $formcompany= new FormCompany($db);
$blocname = 'contacts'; $blocname = 'contacts';
$title = $langs->trans('ContactsAddresses'); $title = $langs->trans('ContactsAddresses');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');

View File

@@ -46,14 +46,14 @@ $object = new Fichinter($db);
if ($action == 'setnote_public' && $user->rights->ficheinter->creer) if ($action == 'setnote_public' && $user->rights->ficheinter->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note_public(GETPOST('note_public','alpha')); $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
else if ($action == 'setnote' && $user->rights->ficheinter->creer) else if ($action == 'setnote' && $user->rights->ficheinter->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note(GETPOST('note','alpha')); $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
@@ -84,13 +84,13 @@ if ($id > 0)
// Company // Company
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$societe->getNomUrl(1).'</td></tr>'; print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$societe->getNomUrl(1).'</td></tr>';
print "</table>"; print "</table>";
print '<br>'; print '<br>';
include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'); include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php');
print '</div>'; print '</div>';
} }
} }

View File

@@ -111,7 +111,7 @@ class CommandeFournisseur extends Commande
$sql = "SELECT c.rowid, c.ref, c.date_creation, c.fk_soc, c.fk_user_author, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva,"; $sql = "SELECT c.rowid, c.ref, c.date_creation, c.fk_soc, c.fk_user_author, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva,";
$sql.= " c.localtax1, c.localtax2, "; $sql.= " c.localtax1, c.localtax2, ";
$sql.= " c.date_commande as date_commande, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_projet as fk_project, c.remise_percent, c.source, c.fk_methode_commande,"; $sql.= " c.date_commande as date_commande, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_projet as fk_project, c.remise_percent, c.source, c.fk_methode_commande,";
$sql.= " c.note, c.note_public, c.model_pdf,"; $sql.= " c.note as note_private, c.note_public, c.model_pdf,";
$sql.= " cm.libelle as methode_commande,"; $sql.= " cm.libelle as methode_commande,";
$sql.= " cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle,"; $sql.= " cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle,";
$sql.= " p.code as mode_reglement_code, p.libelle as mode_reglement_libelle"; $sql.= " p.code as mode_reglement_code, p.libelle as mode_reglement_libelle";
@@ -162,7 +162,8 @@ class CommandeFournisseur extends Commande
$this->mode_reglement_id = $obj->fk_mode_reglement; $this->mode_reglement_id = $obj->fk_mode_reglement;
$this->mode_reglement_code = $obj->mode_reglement_code; $this->mode_reglement_code = $obj->mode_reglement_code;
$this->mode_reglement = $obj->mode_reglement_libelle; $this->mode_reglement = $obj->mode_reglement_libelle;
$this->note = $obj->note; $this->note = $obj->note_private; // deprecated
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
@@ -271,7 +272,7 @@ class CommandeFournisseur extends Commande
else else
{ {
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
dol_syslog("FournisseurCommande::log ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::log ".$this->error, LOG_ERR);
return -1; return -1;
} }
} }
@@ -1404,46 +1405,6 @@ class CommandeFournisseur extends Commande
return 1; return 1;
} }
/**
* Update notes
*
* @param User $user Object user
* @param string $note Private note
* @param string $note_public Public note
* @return int <0 if KO, >=0 if OK
*
* TODO Use instead update_note_public and update_note
*/
function UpdateNote($user, $note, $note_public)
{
// Clean parameters
$note=trim($note);
$note_public=trim($note_public);
$result = 0;
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur";
$sql.= " SET note ='".$this->db->escape($note)."',";
$sql.= " note_public ='".$this->db->escape($note_public)."'";
$sql.= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::UpdateNote sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
$result = 0;
}
else
{
$this->error=$this->db->error();
dol_syslog(get_class($this)."::UpdateNote ".$this->error, LOG_ERR);
$result = -1;
}
return $result ;
}
/** /**
* Tag order with a particular status * Tag order with a particular status
* *
@@ -1462,7 +1423,7 @@ class CommandeFournisseur extends Commande
$sql.= ' SET fk_statut='.$status; $sql.= ' SET fk_statut='.$status;
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;
dol_syslog("CommandeFournisseur::setStatus sql=".$sql); dol_syslog(get_class($this)."::setStatus sql=".$sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
@@ -1472,7 +1433,7 @@ class CommandeFournisseur extends Commande
{ {
$error++; $error++;
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
dol_syslog("CommandeFournisseur::setStatus ".$this->error); dol_syslog(get_class($this)."::setStatus ".$this->error);
} }
if (! $error) if (! $error)
@@ -1505,7 +1466,7 @@ class CommandeFournisseur extends Commande
*/ */
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0) function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0)
{ {
dol_syslog("CommandeFournisseur::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type"); dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type");
include_once(DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'); include_once(DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php');
if ($this->brouillon) if ($this->brouillon)

View File

@@ -283,7 +283,7 @@ class FactureFournisseur extends Facture
$sql.= " t.fk_projet,"; $sql.= " t.fk_projet,";
$sql.= " t.fk_cond_reglement,"; $sql.= " t.fk_cond_reglement,";
$sql.= " t.date_lim_reglement,"; $sql.= " t.date_lim_reglement,";
$sql.= " t.note,"; $sql.= " t.note as note_private,";
$sql.= " t.note_public,"; $sql.= " t.note_public,";
$sql.= " t.model_pdf,"; $sql.= " t.model_pdf,";
$sql.= " t.import_key,"; $sql.= " t.import_key,";
@@ -336,7 +336,8 @@ class FactureFournisseur extends Facture
$this->fk_project = $obj->fk_projet; $this->fk_project = $obj->fk_projet;
$this->fk_cond_reglement = $obj->fk_cond_reglement; $this->fk_cond_reglement = $obj->fk_cond_reglement;
$this->date_echeance = $this->db->jdate($obj->date_lim_reglement); $this->date_echeance = $this->db->jdate($obj->date_lim_reglement);
$this->note = $obj->note; $this->note = $obj->note_private;
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->model_pdf = $obj->model_pdf; $this->model_pdf = $obj->model_pdf;
$this->import_key = $obj->import_key; $this->import_key = $obj->import_key;

View File

@@ -32,27 +32,31 @@ $langs->load("suppliers");
$langs->load("companies"); $langs->load("companies");
$langs->load('stocks'); $langs->load('stocks');
$id = GETPOST('facid','int')?GETPOST('facid','int'):GETPOST('id','int');
$ref = GETPOST('ref');
$action = GETPOST('action');
// Security check // Security check
$id = isset($_GET["id"])?$_GET["id"]:'';
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'commande_fournisseur', $id,''); $result = restrictedArea($user, 'commande_fournisseur', $id,'');
$object = new CommandeFournisseur($db);
$object->fetch($id, $ref);
/* /*
* Actions * Actions
*/ */
if ($_POST["action"] == 'updatenote' && $user->rights->fournisseur->commande->creer) if ($action == 'setnote_public' && $user->rights->fournisseur->commande->creer)
{ {
$commande = new CommandeFournisseur($db); $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
$commande->fetch($_GET["id"]); if ($result < 0) dol_print_error($db,$object->error);
}
$result = $commande->UpdateNote($user, $_POST["note"], $_POST["note_public"]); elseif ($action == 'setnote' && $user->rights->fournisseur->commande->creer)
if ($result >= 0) {
{ $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
Header("Location: note.php?id=".$_GET["id"]); if ($result < 0) dol_print_error($db,$object->error);
exit;
}
} }
@@ -72,21 +76,17 @@ $form = new Form($db);
$now=dol_now(); $now=dol_now();
$id = $_GET['id'];
$ref= $_GET['ref'];
if ($id > 0 || ! empty($ref)) if ($id > 0 || ! empty($ref))
{ {
$commande = new CommandeFournisseur($db);
$result=$commande->fetch($_GET["id"],$_GET['ref']);
if ($result >= 0) if ($result >= 0)
{ {
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($commande->socid); $soc->fetch($object->socid);
$author = new User($db); $author = new User($db);
$author->fetch($commande->user_author_id); $author->fetch($object->user_author_id);
$head = ordersupplier_prepare_head($commande); $head = ordersupplier_prepare_head($object);
$title=$langs->trans("SupplierOrder"); $title=$langs->trans("SupplierOrder");
dol_fiche_head($head, 'note', $title, 0, 'order'); dol_fiche_head($head, 'note', $title, 0, 'order');
@@ -95,16 +95,12 @@ if ($id > 0 || ! empty($ref))
/* /*
* Commande * Commande
*/ */
print '<form action="note.php?id='.$commande->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="updatenote">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
print '<tr><td width="20%">'.$langs->trans("Ref").'</td>'; print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
print '<td colspan="2">'; print '<td colspan="2">';
print $form->showrefnav($commande,'ref','',1,'ref','ref'); print $form->showrefnav($object,'ref','',1,'ref','ref');
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@@ -117,55 +113,36 @@ if ($id > 0 || ! empty($ref))
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("Status").'</td>'; print '<td>'.$langs->trans("Status").'</td>';
print '<td colspan="2">'; print '<td colspan="2">';
print $commande->getLibStatut(4); print $object->getLibStatut(4);
print "</td></tr>"; print "</td></tr>";
// Date // Date
if ($commande->methode_commande_id > 0) if ($object->methode_commande_id > 0)
{ {
print '<tr><td>'.$langs->trans("Date").'</td><td colspan="2">'; print '<tr><td>'.$langs->trans("Date").'</td><td colspan="2">';
if ($commande->date_commande) if ($object->date_commande)
{ {
print dol_print_date($commande->date_commande,"dayhourtext")."\n"; print dol_print_date($object->date_commande,"dayhourtext")."\n";
} }
print "</td></tr>"; print "</td></tr>";
if ($commande->methode_commande) if ($object->methode_commande)
{ {
print '<tr><td>'.$langs->trans("Method").'</td><td colspan="2">'.$commande->methode_commande.'</td></tr>'; print '<tr><td>'.$langs->trans("Method").'</td><td colspan="2">'.$object->methode_commande.'</td></tr>';
} }
} }
// Auteur // Author
print '<tr><td>'.$langs->trans("AuthorRequest").'</td>'; print '<tr><td>'.$langs->trans("AuthorRequest").'</td>';
print '<td colspan="2">'.$author->getNomUrl(1).'</td>'; print '<td colspan="2">'.$author->getNomUrl(1).'</td>';
print '</tr>'; print '</tr>';
print '<tr><td valign="top">'.$langs->trans("NotePublic").'</td>';
print '<td colspan="2">';
if ($user->rights->fournisseur->commande->creer) print '<textarea cols="90" rows="'.ROWS_4.'" name="note_public">';
print $commande->note_public;
if ($user->rights->fournisseur->commande->creer) print '</textarea>';
print '</td></tr>';
if (! $user->societe_id)
{
print '<tr><td valign="top">'.$langs->trans("NotePrivate").'</td>';
print '<td colspan="2">';
if ($user->rights->fournisseur->commande->creer) print '<textarea cols="90" rows="'.ROWS_8.'" name="note">';
print $commande->note;
if ($user->rights->fournisseur->commande->creer) print '</textarea>';
print '</td></tr>';
}
print "</table>"; print "</table>";
if ($user->rights->fournisseur->commande->creer) print '<br>';
{
print '<center><br><input type="submit" class="button" value="'.$langs->trans("Save").'"></center>';
}
print "</form>"; $colwidth=20;
include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php');
dol_fiche_end(); dol_fiche_end();
} }
@@ -178,7 +155,7 @@ if ($id > 0 || ! empty($ref))
} }
$db->close();
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@@ -31,15 +31,16 @@ require_once(DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php');
$langs->load('bills'); $langs->load('bills');
$langs->load("companies"); $langs->load("companies");
$facid = GETPOST('facid','int')?GETPOST('facid','int'):GETPOST('id','int'); $id = GETPOST('facid','int')?GETPOST('facid','int'):GETPOST('id','int');
$ref = GETPOST('ref');
$action = GETPOST('action'); $action = GETPOST('action');
// Security check // Security check
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'fournisseur', $facid, 'facture_fourn', 'facture'); $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture');
$object = new FactureFournisseur($db); $object = new FactureFournisseur($db);
$object->fetch($facid); $object->fetch($id,$ref);
@@ -47,42 +48,20 @@ $object->fetch($facid);
/* Actions */ /* Actions */
/******************************************************************************/ /******************************************************************************/
if ($action == 'update_public' && $user->rights->facture->creer) if ($action == 'setnote_public' && $user->rights->fournisseur->facture->creer)
{ {
$db->begin(); $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
$res=$object->update_note_public($_POST["note_public"],$user);
if ($res < 0)
{
$mesg='<div class="error">'.$object->error.'</div>';
$db->rollback();
}
else
{
$db->commit();
}
} }
elseif ($action == 'setnote' && $user->rights->fournisseur->facture->creer)
if ($action == 'update' && $user->rights->fournisseur->facture->creer)
{ {
$db->begin(); $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
$res=$object->update_note($_POST["note"],$user);
if ($res < 0)
{
$mesg='<div class="error">'.$object->error.'</div>';
$db->rollback();
}
else
{
$db->commit();
}
} }
// Set label // Set label
if ($action == 'setlabel' && $user->rights->fournisseur->facture->creer) if ($action == 'setlabel' && $user->rights->fournisseur->facture->creer)
{ {
$object->fetch($facid);
$object->label=$_POST['label']; $object->label=$_POST['label'];
$result=$object->update($user); $result=$object->update($user);
if ($result < 0) dol_print_error($db); if ($result < 0) dol_print_error($db);
@@ -97,7 +76,7 @@ $form = new Form($db);
llxHeader(); llxHeader();
if ($facid) if ($id)
{ {
$object->fetch_thirdparty(); $object->fetch_thirdparty();
@@ -142,12 +121,12 @@ if ($facid)
{ {
print ' ('.$langs->transnoentities("InvoiceHasAvoir"); print ' ('.$langs->transnoentities("InvoiceHasAvoir");
$i=0; $i=0;
foreach($facidavoir as $id) foreach($facidavoir as $fid)
{ {
if ($i==0) print ' '; if ($i==0) print ' ';
else print ','; else print ',';
$facavoir=new FactureFournisseur($db); $facavoir=new FactureFournisseur($db);
$facavoir->fetch($id); $facavoir->fetch($fid);
print $facavoir->getNomUrl(1); print $facavoir->getNomUrl(1);
} }
print ')'; print ')';
@@ -165,65 +144,18 @@ if ($facid)
print $form->editfieldval("Label",'label',$object->label,$object,0); print $form->editfieldval("Label",'label',$object->label,$object,0);
print '</td>'; print '</td>';
// Note public
print '<tr><td valign="top">'.$langs->trans("NotePublic").' :</td>';
print '<td valign="top" colspan="3">';
if ($_GET["action"] == 'edit')
{
print '<form method="post" action="note.php?facid='.$object->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update_public">';
print '<textarea name="note_public" cols="80" rows="8">'.$object->note_public."</textarea><br>";
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '</form>';
}
else
{
print ($object->note_public?nl2br($object->note_public):"&nbsp;");
}
print "</td></tr>";
// Note private
if (! $user->societe_id)
{
print '<tr><td valign="top">'.$langs->trans("NotePrivate").' :</td>';
print '<td valign="top" colspan="3">';
if ($_GET["action"] == 'edit')
{
print '<form method="post" action="note.php?facid='.$object->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<textarea name="note" cols="80" rows="8">'.$object->note."</textarea><br>";
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '</form>';
}
else
{
print ($object->note?nl2br($object->note):"&nbsp;");
}
print "</td></tr>";
}
print "</table>"; print "</table>";
print '<br>';
$colwidth=20;
include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php');
dol_fiche_end(); dol_fiche_end();
/*
* Buttons
*/
print '<div class="tabsAction">';
if ($user->rights->fournisseur->facture->creer && $_GET["action"] <> 'edit')
{
print "<a class=\"butAction\" href=\"note.php?facid=$object->id&amp;action=edit\">".$langs->trans('Modify')."</a>";
}
print "</div>";
} }
$db->close();
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@@ -52,7 +52,7 @@ if ($action == 'update_public' && $user->rights->projet->creer)
$db->begin(); $db->begin();
$res=$project->update_note_public($_POST["note_public"],$user); $res=$project->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($res < 0) if ($res < 0)
{ {
$mesg='<div class="error">'.$project->error.'</div>'; $mesg='<div class="error">'.$project->error.'</div>';
@@ -71,7 +71,7 @@ if ($action == 'update_private' && $user->rights->projet->creer)
$db->begin(); $db->begin();
$res=$project->update_note($_POST["note_private"],$user); $res=$project->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES));
if ($res < 0) if ($res < 0)
{ {
$mesg='<div class="error">'.$project->error.'</div>'; $mesg='<div class="error">'.$project->error.'</div>';

View File

@@ -54,7 +54,7 @@ if ($action == 'update_public' && $user->rights->projet->creer)
$db->begin(); $db->begin();
$res=$task->update_note_public($_POST["note_public"],$user); $res=$task->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($res < 0) if ($res < 0)
{ {
$mesg='<div class="error">'.$task->error.'</div>'; $mesg='<div class="error">'.$task->error.'</div>';
@@ -73,7 +73,7 @@ if ($action == 'update_private' && $user->rights->projet->creer)
$db->begin(); $db->begin();
$res=$task->update_note($_POST["note_private"],$user); $res=$task->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES));
if ($res < 0) if ($res < 0)
{ {
$mesg='<div class="error">'.$task->error.'</div>'; $mesg='<div class="error">'.$task->error.'</div>';