diff --git a/build.xml b/build.xml index 0394e263846..2c2dfb0c64c 100644 --- a/build.xml +++ b/build.xml @@ -2,7 +2,7 @@ - + @@ -43,6 +43,7 @@ "; print ''; - - /* - * Lignes de contacts - */ + print '
'; + // Contacts lines include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'); } diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index 8bc2d5f7eea..410ce6c8c09 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -143,21 +143,12 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; + print ""; + + print '
'; + include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'); - print ""; - - print ''; - - /* - * Actions - */ - - print '
'; - if ($user->rights->propale->creer && $action <> 'edit') - { - print ''.$langs->trans('Modify').''; - } print '
'; } } diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 4cc027acf0b..eeca19cce3c 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -90,7 +90,7 @@ else if ($action == 'swapstatut' && $user->rights->commande->creer) } // Efface un contact -else if ($action == 'deleteline' && $user->rights->commande->creer) +else if ($action == 'deletecontact' && $user->rights->commande->creer) { $object->fetch($id); $result = $object->delete_contact($_GET["lineid"]); @@ -199,187 +199,11 @@ if ($id > 0 || ! empty($ref)) print ''; - /* - * Lignes de contacts - */ - echo '
'; + print '
'; + + // Contacts lines + include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'); - /* - * Ajouter une ligne de contact - * Non affiche en mode modification de ligne - */ - if ($action != 'editline' && $user->rights->commande->creer) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $var = false; - - print ''; - print ''; - print ''; - print ''; - print ''; - - // Ligne ajout pour contact interne - print ''; - - print ''; - - print ''; - - print ''; - print ''; - print ''; - print ''; - - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - - // Ligne ajout pour contact externe - $var=!$var; - print ''; - - print ''; - - print ''; - - print ''; - print ''; - print ''; - print ''; - - print ""; - - print ''; - } - - // List of linked contacts - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $companystatic=new Societe($db); - $var = true; - - foreach(array('internal','external') as $source) - { - $tab = $object->liste_contact(-1,$source); - $num=count($tab); - - $i = 0; - while ($i < $num) - { - $var = !$var; - - print ''; - - // Source - print ''; - - // Societe - print ''; - - // Contact - print ''; - - // Type de contact - print ''; - - // Statut - print ''; - - // Icon update et delete - print ''; - - print "\n"; - - $i ++; - } - } - print "
'.$langs->trans("Source").''.$langs->trans("Company").''.$langs->trans("Contacts").''.$langs->trans("ContactType").'  
'; - print img_object('','user').' '.$langs->trans("Users"); - print ''; - print $conf->global->MAIN_INFO_SOCIETE_NOM; - print ''; - //$userAlreadySelected = $object->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionne car on doit pouvoir le selectionner une deuxieme fois pour un autre type - $form->select_users($user->id,'contactid',0,$userAlreadySelected); - print ''; - $formcompany->selectTypeContact($object, '', 'type','internal'); - print '
'; - print img_object('','contact').' '.$langs->trans("ThirdPartyContacts"); - print ''; - $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$object->client->id; - $selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany'); - print ''; - $nbofcontacts=$form->select_contacts($selectedCompany, '', 'contactid'); - if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); - print ''; - $formcompany->selectTypeContact($object, '', 'type','external'); - print '
 
'.$langs->trans("Source").''.$langs->trans("Company").''.$langs->trans("Contacts").''.$langs->trans("ContactType").''.$langs->trans("Status").' 
'; - if ($tab[$i]['source']=='internal') print $langs->trans("User"); - if ($tab[$i]['source']=='external') print $langs->trans("ThirdPartyContact"); - print ''; - if ($tab[$i]['socid'] > 0) - { - $companystatic->fetch($tab[$i]['socid']); - print $companystatic->getNomUrl(1); - } - if ($tab[$i]['socid'] < 0) - { - print $conf->global->MAIN_INFO_SOCIETE_NOM; - } - if (! $tab[$i]['socid']) - { - print ' '; - } - print ''; - if ($tab[$i]['source']=='internal') - { - $userstatic->id=$tab[$i]['id']; - $userstatic->lastname=$tab[$i]['lastname']; - $userstatic->firstname=$tab[$i]['firstname']; - print $userstatic->getNomUrl(1); - } - if ($tab[$i]['source']=='external') - { - $contactstatic->id=$tab[$i]['id']; - $contactstatic->lastname=$tab[$i]['lastname']; - $contactstatic->firstname=$tab[$i]['firstname']; - print $contactstatic->getNomUrl(1); - } - print ''.$tab[$i]['libelle'].''; - // Activation desativation du contact - if ($object->statut >= 0) print ''; - print $contactstatic->LibStatut($tab[$i]['status'],3); - if ($object->statut >= 0) print ''; - print ''; - if ($object->statut < 5 && $user->rights->commande->creer) - { - print ' '; - print ''; - print img_delete(); - print ''; - } - print '
"; } else { diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index e373ea6e987..2175e262a9e 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1191,6 +1191,66 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P } } +if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) +{ + if ($action == 'addcontact' && $user->rights->commande->creer) + { + $result = $object->fetch($id); + + if ($result > 0 && $id > 0) + { + $result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); + } + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $langs->load("errors"); + $mesg = '
'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
'; + } + else + { + $mesg = '
'.$object->error.'
'; + } + } + } + + // bascule du statut d'un contact + else if ($action == 'swapstatut' && $user->rights->commande->creer) + { + if ($object->fetch($id)) + { + $result=$object->swapContactStatus(GETPOST('ligne')); + } + else + { + dol_print_error($db); + } + } + + // Efface un contact + else if ($action == 'deletecontact' && $user->rights->commande->creer) + { + $object->fetch($id); + $result = $object->delete_contact($lineid); + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else { + dol_print_error($db); + } + } +} + /* * View @@ -1951,9 +2011,21 @@ else print '
'; print "\n"; - if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { - include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'); + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); + $formcompany= new FormCompany($db); + + $blocname = 'contacts'; + $title = $langs->trans('ContactsAddresses'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); + } + + if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + $blocname = 'notes'; + $title = $langs->trans('Notes'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); } /* diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php index 17d71af6cb7..d2bc4fafd33 100644 --- a/htdocs/commande/note.php +++ b/htdocs/commande/note.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * * 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 @@ -27,25 +27,24 @@ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'); require_once(DOL_DOCUMENT_ROOT ."/commande/class/commande.class.php"); -$socid=isset($_GET["socid"])?$_GET["socid"]:isset($_POST["socid"])?$_POST["socid"]:""; - -if (!$user->rights->commande->lire) accessforbidden(); $langs->load("companies"); $langs->load("bills"); $langs->load("orders"); +$id = GETPOST('id','int'); +$ref=GETPOST('ref','alpha'); +$socid=GETPOST('socid','int'); +$action=GETPOST('action','alpha'); + // Security check $socid=0; -$comid = isset($_GET["id"])?$_GET["id"]:''; if ($user->societe_id) $socid=$user->societe_id; -$result=restrictedArea($user,'commande',$comid,''); +$result=restrictedArea($user,'commande',$id,''); -$id = $_GET['id']; -$ref= $_GET['ref']; -$commande = new Commande($db); -if (! $commande->fetch($_GET['id'],$_GET['ref']) > 0) +$object = new Commande($db); +if (! $object->fetch($id, $ref) > 0) { dol_print_error($db); } @@ -55,25 +54,19 @@ if (! $commande->fetch($_GET['id'],$_GET['ref']) > 0) * Actions */ -if ($_POST["action"] == 'update' && $user->rights->commande->creer) +if ($action == 'setnote_public' && $user->rights->commande->creer) { - $db->begin(); - - $resPrivateNote=$commande->update_note($_POST["note"]); - $resPublicNote=$commande->update_note_public($_POST["note_public"]); - - if ($resPrivateNote < 0 || $resPublicNote < 0) - { - $mesg='
'.$commande->error.'
'; - $db->rollback(); - } - else - { - $db->commit(); - } + $object->fetch($id); + $result=$object->update_note_public(GETPOST('note_public','alpha')); + if ($result < 0) dol_print_error($db,$object->error); } - +else if ($action == 'setnote' && $user->rights->commande->creer) +{ + $object->fetch($id); + $result=$object->update_note(GETPOST('note','alpha')); + if ($result < 0) dol_print_error($db,$object->error); +} /* * View @@ -86,17 +79,17 @@ $form = new Form($db); if ($id > 0 || ! empty($ref)) { $soc = new Societe($db); - $soc->fetch($commande->socid); + $soc->fetch($object->socid); - $head = commande_prepare_head($commande); + $head = commande_prepare_head($object); dol_fiche_head($head, 'note', $langs->trans("CustomerOrder"), 0, 'order'); print ''; // Ref - print '"; // Ref commande client @@ -106,72 +99,24 @@ if ($id > 0 || ! empty($ref)) print ''; print '
'.$langs->trans("Ref").''; - print $form->showrefnav($commande,'ref','',1,'ref','ref'); + print '
'.$langs->trans("Ref").''; + print $form->showrefnav($object,'ref','',1,'ref','ref'); print "
'; print ''; - print $commande->ref_client; + print $object->ref_client; print ''; print ''; // Customer print "".$langs->trans("Company").""; print ''.$soc->getNomUrl(1).''; - - // Note publique - print ''.$langs->trans("NotePublic").' :'; - print ''; - if ($_GET["action"] == 'edit') - { - print '
'; - print ''; - print ''; - print '
"; - } - else - { - print ($commande->note_public?nl2br($commande->note_public):" "); - } - print ""; - - // Note private - if (! $user->societe_id) - { - print ''.$langs->trans("NotePrivate").' :'; - print ''; - if ($_GET["action"] == 'edit') - { - print '
"; - } - else - { - print ($commande->note?nl2br($commande->note):" "); - } - print ""; - } + print ""; - - if ($_GET["action"] == 'edit') - { - print '
'; - print ' '; - print '
'; - print '
'; - } + + print '
'; + + include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'); print ''; - - /* - * Actions - */ - - print '
'; - - if ($user->rights->commande->creer && $_GET["action"] <> 'edit') - { - print "id."&action=edit\">".$langs->trans('Modify').""; - } - - print "
"; } -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php index f972903844e..09cb5c2166a 100644 --- a/htdocs/compta/deplacement/fiche.php +++ b/htdocs/compta/deplacement/fiche.php @@ -498,7 +498,9 @@ else if ($id) print "
"; // Notes - include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'); + $blocname = 'notes'; + $title = $langs->trans('Notes'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); print ''; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 15c1404c347..c09b02e05ba 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1506,6 +1506,65 @@ else if ($action == 'builddoc') // En get ou en post } } +if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) +{ + if ($action == 'addcontact' && $user->rights->facture->creer) + { + $result = $object->fetch($id); + + if ($result > 0 && $id > 0) + { + $result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); + } + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $langs->load("errors"); + $mesg = '
'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
'; + } + else + { + $mesg = '
'.$object->error.'
'; + } + } + } + + // bascule du statut d'un contact + else if ($action == 'swapstatut' && $user->rights->facture->creer) + { + if ($object->fetch($id)) + { + $result=$object->swapContactStatus(GETPOST('ligne')); + } + else + { + dol_print_error($db); + } + } + + // Efface un contact + else if ($action == 'deletecontact' && $user->rights->facture->creer) + { + $object->fetch($id); + $result = $object->delete_contact($lineid); + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else { + dol_print_error($db); + } + } +} /* @@ -2738,9 +2797,22 @@ else print '
'; + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"); + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); + $formcompany= new FormCompany($db); + + $blocname = 'contacts'; + $title = $langs->trans('ContactsAddresses'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); + } + if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { - include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'); + $blocname = 'notes'; + $title = $langs->trans('Notes'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); } /* @@ -3392,7 +3464,7 @@ else } } -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 5e5bc8892f4..044c39c6495 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -136,7 +136,8 @@ class Facture extends CommonObject // Clean parameters if (empty($this->type)) $this->type = 0; $this->ref_client=trim($this->ref_client); - $this->note=trim($this->note); + $this->note=(isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated + $this->note_private=(isset($this->note_private) ? trim($this->note_private) : trim($this->note)); $this->note_public=trim($this->note_public); if (! $this->cond_reglement_id) $this->cond_reglement_id = 0; if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; @@ -219,7 +220,7 @@ class Facture extends CommonObject $sql.= ",".($this->remise_absolue>0?$this->remise_absolue:'NULL'); $sql.= ",".($this->remise_percent>0?$this->remise_percent:'NULL'); $sql.= ", '".$this->db->idate($this->date)."'"; - $sql.= ",".($this->note?"'".$this->db->escape($this->note)."'":"null"); + $sql.= ",".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null"); $sql.= ",".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); $sql.= ",".($this->ref_client?"'".$this->db->escape($this->ref_client)."'":"null"); $sql.= ",".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null"); @@ -820,8 +821,8 @@ class Facture extends CommonObject $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; $this->fk_project = $obj->fk_projet; $this->fk_facture_source = $obj->fk_facture_source; - $this->note = $obj->note_private; - $this->note_private = $obj->note_private; // deprecated + $this->note = $obj->note_private; // deprecated + $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->user_author = $obj->fk_user_author; $this->user_valid = $obj->fk_user_valid; @@ -964,7 +965,8 @@ class Facture extends CommonObject if (isset($this->increment)) $this->increment=trim($this->increment); if (isset($this->close_code)) $this->close_code=trim($this->close_code); if (isset($this->close_note)) $this->close_note=trim($this->close_note); - if (isset($this->note)) $this->note=trim($this->note); + if (isset($this->note) || isset($this->note_private)) $this->note=(isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated + if (isset($this->note) || isset($this->note_private)) $this->note_private=(isset($this->note_private) ? trim($this->note_private) : trim($this->note)); if (isset($this->note_public)) $this->note_public=trim($this->note_public); if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf); if (isset($this->import_key)) $this->import_key=trim($this->import_key); @@ -1002,7 +1004,7 @@ class Facture extends CommonObject $sql.= " fk_cond_reglement=".(isset($this->cond_reglement_id)?$this->cond_reglement_id:"null").","; $sql.= " fk_mode_reglement=".(isset($this->mode_reglement_id)?$this->mode_reglement_id:"null").","; $sql.= " date_lim_reglement=".(strval($this->date_lim_reglement)!='' ? "'".$this->db->idate($this->date_lim_reglement)."'" : 'null').","; - $sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").","; + $sql.= " note=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").","; $sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").","; $sql.= " model_pdf=".(isset($this->modelpdf)?"'".$this->db->escape($this->modelpdf)."'":"null").","; $sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").""; @@ -3077,6 +3079,7 @@ class Facture extends CommonObject $this->mode_reglement_id = 7; $this->mode_reglement_code = 'CHQ'; $this->note_public='This is a comment (public)'; + $this->note_private='This is a comment (private)'; $this->note='This is a comment (private)'; if (empty($option) || $option != 'nolines') diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 8e34d0aa48f..59b61483541 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -1,6 +1,7 @@ * Copyright (C) 2005-2009 Destailleur Laurent + * Copyright (C) 2005-2012 Regis Houssin * * 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 @@ -32,56 +33,56 @@ require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); $langs->load("bills"); $langs->load("companies"); -$facid = GETPOST('facid'); -$id = GETPOST('facid'); -$ref= GETPOST('ref'); +$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility +$ref = GETPOST('ref'); +$socid=GETPOST('socid','int'); +$action=GETPOST('action','alpha'); // Security check if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'facture', $facid); +$result = restrictedArea($user, 'facture', $id); + +$object = new Facture($db); /* * Ajout d'un nouveau contact */ -if ($_POST["action"] == 'addcontact' && $user->rights->facture->creer) +if ($action == 'addcontact' && $user->rights->facture->creer) { - $result = 0; - $facture = new Facture($db); - $result = $facture->fetch($facid); + $result = $object->fetch($id); - if ($result > 0 && $facid > 0) + if ($result > 0 && $id > 0) { - $result = $facture->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); + $result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); } if ($result >= 0) { - Header("Location: contact.php?facid=".$facture->id); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { - if ($facture->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); $mesg = '
'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
'; } else { - $mesg = '
'.$facture->error.'
'; + $mesg = '
'.$object->error.'
'; } } } // bascule du statut d'un contact -if ($_GET["action"] == 'swapstatut' && $user->rights->facture->creer) +else if ($action == 'swapstatut' && $user->rights->facture->creer) { - $facture = new Facture($db); - if ($facture->fetch($facid)) + if ($object->fetch($id)) { - $result=$facture->swapContactStatus(GETPOST('ligne')); + $result=$object->swapContactStatus(GETPOST('ligne')); } else { @@ -90,15 +91,14 @@ if ($_GET["action"] == 'swapstatut' && $user->rights->facture->creer) } // Efface un contact -if ($_GET["action"] == 'deleteline' && $user->rights->facture->creer) +else if ($action == 'deletecontact' && $user->rights->facture->creer) { - $facture = new Facture($db); - $facture->fetch($facid); - $result = $facture->delete_contact($_GET["lineid"]); + $object->fetch($id); + $result = $object->delete_contact($_GET["lineid"]); if ($result >= 0) { - Header("Location: contact.php?facid=".$facture->id); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { @@ -128,12 +128,11 @@ dol_htmloutput_mesg($mesg); if ($id > 0 || ! empty($ref)) { - $facture = new Facture($db); - if ($facture->fetch($id, $ref) > 0) + if ($object->fetch($id, $ref) > 0) { - $facture->fetch_thirdparty(); + $object->fetch_thirdparty(); - $head = facture_prepare_head($facture); + $head = facture_prepare_head($object); dol_fiche_head($head, 'contact', $langs->trans('InvoiceCustomer'), 0, 'bill'); @@ -147,7 +146,7 @@ if ($id > 0 || ! empty($ref)) print ''; $morehtmlref=''; $discount=new DiscountAbsolute($db); - $result=$discount->fetch(0,$facture->id); + $result=$discount->fetch(0,$object->id); if ($result > 0) { $morehtmlref=' ('.$langs->trans("CreditNoteConvertedIntoDiscount",$discount->getNomUrl(1,'discount')).')'; @@ -156,198 +155,20 @@ if ($id > 0 || ! empty($ref)) { dol_print_error('',$discount->error); } - print $form->showrefnav($facture,'ref','',1,'facnumber','ref',$morehtmlref); + print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref); print ''; // Customer print "".$langs->trans("Company").""; - print ''.$facture->client->getNomUrl(1,'compta').''; + print ''.$object->client->getNomUrl(1,'compta').''; print ""; print ''; - - /* - * Lignes de contacts - */ - echo '
'; - - /* - * Ajouter une ligne de contact - * Non affiche en mode modification de ligne - */ - if ($_GET["action"] != 'editline' && $user->rights->facture->creer) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $var = false; - - print ''; - print ''; - print ''; - print ''; - print ''; - - // Line to add an internal contact - print ""; - - print ''; - - print ''; - - print ''; - print ''; - print ''; - print ''; - - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - - // Line to add an external contact - $var=!$var; - print ""; - - print ''; - - print ''; - - print ''; - print ''; - print ''; - print ''; - - print ""; - - print ''; - } - - // List of linked contacts - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $companystatic = new Societe($db); - $var = true; - - foreach(array('internal','external') as $source) - { - $tab = $facture->liste_contact(-1,$source); - $num=count($tab); - - $i = 0; - while ($i < $num) - { - $var = !$var; - - print ''; - - // Source - print ''; - - // Third party - print ''; - - // Contact - print ''; - - // Type of contact - print ''; - - // Status - print ''; - - // Icon update et delete - print ''; - - print "\n"; - - $i ++; - } - } - print "
'.$langs->trans("Source").''.$langs->trans("Company").''.$langs->trans("Contacts").''.$langs->trans("ContactType").' 
'; - print img_object('','user').' '.$langs->trans("Users"); - print ''; - print $mysoc->name; - print ''; - // Ge get ids of alreadey selected users - //$userAlreadySelected = $facture->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type - $form->select_users($user->id,'contactid',0,$userAlreadySelected); - print ''; - $formcompany->selectTypeContact($facture, '', 'type','internal'); - print '
'; - print img_object('','contact').' '.$langs->trans("ThirdPartyContacts"); - print ''; - $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$facture->client->id; - $selectedCompany = $formcompany->selectCompaniesForNewContact($facture, 'facid', $selectedCompany, $htmlname = 'newcompany'); - print ''; - $nbofcontacts=$form->select_contacts($selectedCompany, '', 'contactid'); - if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); - print ''; - $formcompany->selectTypeContact($facture, '', 'type','external'); - print '
 
'.$langs->trans("Source").''.$langs->trans("Company").''.$langs->trans("Contacts").''.$langs->trans("ContactType").''.$langs->trans("Status").' 
'; - if ($tab[$i]['source']=='internal') print $langs->trans("User"); - if ($tab[$i]['source']=='external') print $langs->trans("ThirdPartyContact"); - print ''; - if ($tab[$i]['socid'] > 0) - { - $companystatic->fetch($tab[$i]['socid']); - print $companystatic->getNomUrl(1); - } - if ($tab[$i]['socid'] < 0) - { - print $mysoc->name; - } - if (! $tab[$i]['socid']) - { - print ' '; - } - print ''; - if ($tab[$i]['source']=='internal') - { - $userstatic->id=$tab[$i]['id']; - $userstatic->lastname=$tab[$i]['lastname']; - $userstatic->firstname=$tab[$i]['firstname']; - print $userstatic->getNomUrl(1); - } - if ($tab[$i]['source']=='external') - { - $contactstatic->id=$tab[$i]['id']; - $contactstatic->lastname=$tab[$i]['lastname']; - $contactstatic->firstname=$tab[$i]['firstname']; - print $contactstatic->getNomUrl(1); - } - print ''.$tab[$i]['libelle'].''; - // Activate/Unactivate contact - if ($facture->statut >= 0) print ''; - print $contactstatic->LibStatut($tab[$i]['status'],3); - if ($facture->statut >= 0) print ''; - print ''; - if ($user->rights->facture->creer) - { - print ' '; - print ''; - print img_delete(); - print ''; - } - print '
"; + print '
'; + + // Contacts lines + include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'); } else { @@ -356,7 +177,7 @@ if ($id > 0 || ! empty($ref)) } } -$db->close(); llxFooter(); +$db->close(); ?> \ No newline at end of file diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index ea22971c1bf..a388cbd1276 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -1,6 +1,7 @@ * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin * * 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 @@ -27,64 +28,42 @@ require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); require_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'); -$socid=isset($_GET["socid"])?$_GET["socid"]:isset($_POST["socid"])?$_POST["socid"]:""; - -if (!$user->rights->facture->lire) - accessforbidden(); - $langs->load("companies"); $langs->load("bills"); +$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility +$ref=GETPOST('ref','alpha'); +$socid=GETPOST('socid','int'); +$action=GETPOST('action','alpha'); + // Security check -if ($user->societe_id > 0) -{ - unset($_GET["action"]); - $socid = $user->societe_id; -} +$socid=0; +if ($user->societe_id) $socid=$user->societe_id; +$result=restrictedArea($user,'facture',$id,''); - -$fac = new Facture($db); -$fac->fetch($_GET["facid"]); +$object = new Facture($db); +$object->fetch($id); /******************************************************************************/ /* Actions */ /******************************************************************************/ -if ($_POST["action"] == 'update_public' && $user->rights->facture->creer) +if ($action == 'setnote_public' && $user->rights->facture->creer) { - $db->begin(); - - $res=$fac->update_note_public($_POST["note_public"],$user); - if ($res < 0) - { - $mesg='
'.$fac->error.'
'; - $db->rollback(); - } - else - { - $db->commit(); - } + $object->fetch($id); + $result=$object->update_note_public(GETPOST('note_public','alpha')); + if ($result < 0) dol_print_error($db,$object->error); } -if ($_POST["action"] == 'update' && $user->rights->facture->creer) +else if ($action == 'setnote' && $user->rights->facture->creer) { - $db->begin(); - - $res=$fac->update_note($_POST["note"],$user); - if ($res < 0) - { - $mesg='
'.$fac->error.'
'; - $db->rollback(); - } - else - { - $db->commit(); - } + $object->fetch($id); + $result=$object->update_note(GETPOST('note','alpha')); + if ($result < 0) dol_print_error($db,$object->error); } - /******************************************************************************/ /* Affichage fiche */ /******************************************************************************/ @@ -93,28 +72,26 @@ llxHeader(); $form = new Form($db); -$id = $_GET['facid']; -$ref= $_GET['ref']; if ($id > 0 || ! empty($ref)) { - $fac = new Facture($db); - $fac->fetch($id,$ref); + $object = new Facture($db); + $object->fetch($id,$ref); $soc = new Societe($db); - $soc->fetch($fac->socid); + $soc->fetch($object->socid); - $head = facture_prepare_head($fac); + $head = facture_prepare_head($object); dol_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), 0, 'bill'); print ''; // Ref - print ''; + print ''; print ''; // Company print ''; print ''; - - // Note publique - print ''; - print '"; - - // Note priv�e - if (! $user->societe_id) - { - print ''; - print '"; - } - + print "
'.$langs->trans('Ref').'
'.$langs->trans('Ref').''; $morehtmlref=''; $discount=new DiscountAbsolute($db); - $result=$discount->fetch(0,$fac->id); + $result=$discount->fetch(0,$object->id); if ($result > 0) { $morehtmlref=' ('.$langs->trans("CreditNoteConvertedIntoDiscount",$discount->getNomUrl(1,'discount')).')'; @@ -123,72 +100,24 @@ if ($id > 0 || ! empty($ref)) { dol_print_error('',$discount->error); } - print $form->showrefnav($fac,'ref','',1,'facnumber','ref',$morehtmlref); + print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref); print '
'.$langs->trans("Company").''.$soc->getNomUrl(1,'compta').'
'.$langs->trans("NotePublic").' :'; - if ($_GET["action"] == 'edit') - { - print '
'; - print ''; - print ''; - print '
"; - print ''; - print '
'; - } - else - { - print ($fac->note_public?nl2br($fac->note_public):" "); - } - print "
'.$langs->trans("NotePrivate").' :'; - if ($_GET["action"] == 'edit') - { - print '
'; - print ''; - print ''; - print '
"; - print ''; - print '
'; - } - else - { - print ($fac->note?nl2br($fac->note):" "); - } - print "
"; + + print '
'; + + include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'); - - /* - * Actions - */ - print ''; - print '
'; - - if ($user->rights->facture->creer && $_GET["action"] <> 'edit') - { - print "id&action=edit\">".$langs->trans('Modify').""; - } - - print "
"; - + print ''; } -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/htdocs/core/ajax/extraparams.php b/htdocs/core/ajax/extraparams.php index 3a363b41997..b4bb727db6b 100644 --- a/htdocs/core/ajax/extraparams.php +++ b/htdocs/core/ajax/extraparams.php @@ -1,74 +1,74 @@ - - * - * 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 . - */ - -/** - * \file /htdocs/core/ajax/extraparams.php - * \brief File to return Ajax response on set extra parameters of elements - */ - -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); - -include("../../main.inc.php"); - -$id = GETPOST('id','int'); -$element = GETPOST('element','alpha'); -$htmlelement = GETPOST('htmlelement','alpha'); -$type = GETPOST('type', 'alpha'); - -/* - * View - */ - -top_httphead(); - -print ''."\n"; - -if(! empty($id) && ! empty($element) && ! empty($htmlelement) && ! empty($type)) -{ - $value = GETPOST('value','alpha'); - $params=array(); - - dol_syslog("AjaxSetExtraParameters id=".$id." element=".$element." htmlelement=".$htmlelement." type=".$type." value=".$value, LOG_DEBUG); - - $classpath = $subelement = $element; - - // For compatibility - if ($element == 'order' || $element == 'commande') { $classpath = $subelement = 'commande'; } - else if ($element == 'propal') { $classpath = 'comm/propal'; $subelement = 'propal'; } - else if ($element == 'facture') { $classpath = 'compta/facture'; $subelement = 'facture'; } - else if ($element == 'contract') { $classpath = $subelement = 'contrat'; } - else if ($element == 'shipping') { $classpath = $subelement = 'expedition'; } - else if ($element == 'deplacement') { $classpath = 'compta/deplacement'; $subelement = 'deplacement'; } - - dol_include_once('/'.$classpath.'/class/'.$subelement.'.class.php'); - - $classname = ucfirst($subelement); - $object = new $classname($db); - $object->fetch($id); - - $params[$htmlelement] = array($type => $value); - $object->extraparams = array_merge($object->extraparams, $params); - - $result=$object->setExtraParameters(); -} - -?> + + * + * 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 . + */ + +/** + * \file /htdocs/core/ajax/extraparams.php + * \brief File to return Ajax response on set extra parameters of elements + */ + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); + +include("../../main.inc.php"); + +$id = GETPOST('id','int'); +$element = GETPOST('element','alpha'); +$htmlelement = GETPOST('htmlelement','alpha'); +$type = GETPOST('type', 'alpha'); + +/* + * View + */ + +top_httphead(); + +print ''."\n"; + +if(! empty($id) && ! empty($element) && ! empty($htmlelement) && ! empty($type)) +{ + $value = GETPOST('value','alpha'); + $params=array(); + + dol_syslog("AjaxSetExtraParameters id=".$id." element=".$element." htmlelement=".$htmlelement." type=".$type." value=".$value, LOG_DEBUG); + + $classpath = $subelement = $element; + + // For compatibility + if ($element == 'order' || $element == 'commande') { $classpath = $subelement = 'commande'; } + else if ($element == 'propal') { $classpath = 'comm/propal'; $subelement = 'propal'; } + else if ($element == 'facture') { $classpath = 'compta/facture'; $subelement = 'facture'; } + else if ($element == 'contract') { $classpath = $subelement = 'contrat'; } + else if ($element == 'shipping') { $classpath = $subelement = 'expedition'; } + else if ($element == 'deplacement') { $classpath = 'compta/deplacement'; $subelement = 'deplacement'; } + + dol_include_once('/'.$classpath.'/class/'.$subelement.'.class.php'); + + $classname = ucfirst($subelement); + $object = new $classname($db); + $object->fetch($id); + + $params[$htmlelement] = array($type => $value); + $object->extraparams = array_merge($object->extraparams, $params); + + $result=$object->setExtraParameters(); +} + +?> diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 95c93afc309..6e1e06f6279 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -545,7 +545,7 @@ class FormCompany } // We call a page after a small delay when a new input has been selected - $javaScript = "window.location=\'./contact.php?".$var_id."=".($forceid>0?$forceid:$object->id)."&".$htmlname."=\' + document.getElementById(\'".$htmlname."\').value;"; + $javaScript = "window.location=\'".$_SERVER['PHP_SELF']."?".$var_id."=".($forceid>0?$forceid:$object->id)."&".$htmlname."=\' + document.getElementById(\'".$htmlname."\').value;"; $htmloption = 'onChange="ac_delay(\''.$javaScript.'\',\'500\');"'; // When we select with mouse $htmloption.= 'onKeyUp="if (event.keyCode== 13) { ac_delay(\''.$javaScript.'\',\'500\'); }"'; // When we select with keyboard @@ -571,7 +571,7 @@ class FormCompany } else { - $javaScript = "window.location='./contact.php?".$var_id."=".($forceid>0?$forceid:$object->id)."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;"; + $javaScript = "window.location='".$_SERVER['PHP_SELF']."?".$var_id."=".($forceid>0?$forceid:$object->id)."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;"; print ''; - print ''; - print ''; - print ''; - - // Ligne ajout pour contact interne - print ""; - - print ''; - print img_object('','user').' '.$langs->trans("Users"); - print ''; - - print ''; - print $conf->global->MAIN_INFO_SOCIETE_NOM; - print ''; - - print ''; - //$userAlreadySelected = $fichinter->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type - $form->select_users($user->id,'contactid',0,$userAlreadySelected); - print ''; - print ''; - $formcompany->selectTypeContact($fichinter, '', 'type','internal'); - print ''; - print ''; - print ''; - - print ''; - - print '
'; - print ''; - print ''; - print ''; - print ''; - - // Ligne ajout pour contact externe - $var=!$var; - print ""; - - print ''; - print img_object('','contact').' '.$langs->trans("ThirdPartyContacts"); - print ''; - - print ''; - $selectedCompany = GETPOST('newcompany','int')?GETPOST('newcompany','int'):$fichinter->client->id; - $selectedCompany = $formcompany->selectCompaniesForNewContact($fichinter, 'id', $selectedCompany, $htmlname = 'newcompany'); - print ''; - - print ''; - $nbofcontacts=$form->select_contacts($selectedCompany, '', 'contactid'); - if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); - print ''; - print ''; - $formcompany->selectTypeContact($fichinter, '', 'type','external'); - print ''; - print ''; - print ''; - - print "
"; - - print ' '; - } - - // Liste des contacts li�s - print ''; - print ''.$langs->trans("Source").''; - print ''.$langs->trans("Company").''; - print ''.$langs->trans("Contacts").''; - print ''.$langs->trans("ContactType").''; - print ''.$langs->trans("Status").''; - print ' '; - print "\n"; - - $companystatic = new Societe($db); - $var = true; - - foreach(array('internal','external') as $source) - { - $tab = $fichinter->liste_contact(-1,$source); - $num=count($tab); - - $i = 0; - while ($i < $num) - { - $var = !$var; - - print ''; - - // Source - print ''; - if ($tab[$i]['source']=='internal') print $langs->trans("User"); - if ($tab[$i]['source']=='external') print $langs->trans("ThirdPartyContact"); - print ''; - - // Societe - print ''; - if ($tab[$i]['socid'] > 0) - { - $companystatic->fetch($tab[$i]['socid']); - print $companystatic->getNomUrl(1); - } - if ($tab[$i]['socid'] < 0) - { - print $conf->global->MAIN_INFO_SOCIETE_NOM; - } - if (! $tab[$i]['socid']) - { - print ' '; - } - print ''; - - // Contact - print ''; - if ($tab[$i]['source']=='internal') - { - $userstatic->id=$tab[$i]['id']; - $userstatic->lastname=$tab[$i]['lastname']; - $userstatic->firstname=$tab[$i]['firstname']; - print $userstatic->getNomUrl(1); - } - if ($tab[$i]['source']=='external') - { - $contactstatic->id=$tab[$i]['id']; - $contactstatic->lastname=$tab[$i]['lastname']; - $contactstatic->firstname=$tab[$i]['firstname']; - print $contactstatic->getNomUrl(1); - } - print ''; - - // Type de contact - print ''.$tab[$i]['libelle'].''; - - // Statut - print ''; - // Activation desativation du contact - if ($fichinter->statut >= 0) print ''; - print $contactstatic->LibStatut($tab[$i]['status'],3); - if ($fichinter->statut >= 0) print ''; - print ''; - - // Icon update et delete - print ''; - if ($fichinter->statut < 5 && $user->rights->ficheinter->creer) - { - print ' '; - print ''; - print img_delete(); - print ''; - } - print ''; - - print "\n"; - - $i ++; - } - } - print ""; + print '
'; + + // Contacts lines + include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'); } else { @@ -348,7 +168,7 @@ if ($fichinterid > 0) } } -$db->close(); llxFooter(); +$db->close(); ?> \ No newline at end of file diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index e3dc490bc6b..06b899644c4 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -621,6 +621,66 @@ if ($action == 'send' && ! GETPOST('cancel','alpha') && (empty($conf->global->MA $action='presend'; } +if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) +{ + if ($action == 'addcontact' && $user->rights->ficheinter->creer) + { + $result = $object->fetch($id); + + if ($result > 0 && $id > 0) + { + $result = $object->add_contact(GETPOST('contactid','int'), GETPOST('type','int'), GETPOST('source','alpha')); + } + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $langs->load("errors"); + $mesg = '
'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
'; + } + else + { + $mesg = '
'.$object->error.'
'; + } + } + } + + // bascule du statut d'un contact + else if ($action == 'swapstatut' && $user->rights->ficheinter->creer) + { + if ($object->fetch($id)) + { + $result=$object->swapContactStatus(GETPOST('ligne','int')); + } + else + { + dol_print_error($db); + } + } + + // Efface un contact + else if ($action == 'deletecontact' && $user->rights->ficheinter->creer) + { + $object->fetch($id); + $result = $object->delete_contact(GETPOST('lineid','int')); + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else { + dol_print_error($db); + } + } +} + /* * View @@ -856,10 +916,23 @@ else if ($id > 0 || ! empty($ref)) print ''.$langs->trans("Status").''.$object->getLibStatut(4).''; print "
"; + + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"); + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); + $formcompany= new FormCompany($db); + + $blocname = 'contacts'; + $title = $langs->trans('ContactsAddresses'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); + } if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { - include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'); + $blocname = 'notes'; + $title = $langs->trans('Notes'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); } /* diff --git a/htdocs/fichinter/note.php b/htdocs/fichinter/note.php index 3c3154594f1..a150e69573c 100644 --- a/htdocs/fichinter/note.php +++ b/htdocs/fichinter/note.php @@ -1,6 +1,6 @@ - * Copyright (C) 2011-2012 Juanjo Menent +/* Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2011-2012 Juanjo Menent * * 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 @@ -29,58 +29,35 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/fichinter.lib.php"); $langs->load('companies'); $langs->load("interventions"); -$fichinterid = GETPOST('id','int'); +$id = GETPOST('id','int'); $action=GETPOST('action','alpha'); // Security check if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'ficheinter', $fichinterid, 'fichinter'); +$result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); + +$object = new Fichinter($db); /******************************************************************************/ /* Actions */ /******************************************************************************/ -if ($action == 'update_public' && $user->rights->ficheinter->creer) +if ($action == 'setnote_public' && $user->rights->ficheinter->creer) { - $fichinter = new Fichinter($db); - $fichinter->fetch($fichinterid); - - $db->begin(); - - $res=$fichinter->update_note_public(GETPOST('note_public','alpha'),$user); - if ($res < 0) - { - $mesg='
'.$fichinter->error.'
'; - $db->rollback(); - } - else - { - $db->commit(); - } + $object->fetch($id); + $result=$object->update_note_public(GETPOST('note_public','alpha')); + if ($result < 0) dol_print_error($db,$object->error); } -if ($action == 'update' && $user->rights->ficheinter->creer) +else if ($action == 'setnote' && $user->rights->ficheinter->creer) { - $fichinter = new Fichinter($db); - $fichinter->fetch($fichinterid); - - $db->begin(); - - $res=$fichinter->update_note(GETPOST('note_private','alpha'),$user); - if ($res < 0) - { - $mesg='
'.$fichinter->error.'
'; - $db->rollback(); - } - else - { - $db->commit(); - } + $object->fetch($id); + $result=$object->update_note(GETPOST('note','alpha')); + if ($result < 0) dol_print_error($db,$object->error); } - /******************************************************************************/ /* Affichage fiche */ /******************************************************************************/ @@ -89,82 +66,36 @@ llxHeader(); $form = new Form($db); -if ($fichinterid) +if ($id > 0) { if ($mesg) print $mesg; - $fichinter = new Fichinter($db); - if ( $fichinter->fetch($fichinterid) ) + if ($object->fetch($id)) { $societe = new Societe($db); - if ( $societe->fetch($fichinter->socid) ) + if ($societe->fetch($object->socid)) { - $head = fichinter_prepare_head($fichinter); + $head = fichinter_prepare_head($object); dol_fiche_head($head, 'note', $langs->trans('InterventionCard'), 0, 'intervention'); print ''; - print ''; + print ''; - // Soci�t� + // Company print ''; - - // Note publique - print ''; - print '"; - - // Note priv�e - if (! $user->societe_id) - { - print ''; - print '"; - } - + print "
'.$langs->trans('Ref').''.$fichinter->ref.'
'.$langs->trans('Ref').''.$object->ref.'
'.$langs->trans('Company').''.$societe->getNomUrl(1).'
'.$langs->trans("NotePublic").' :'; - if ($action == 'edit') - { - print '
'; - print ''; - print ''; - print '
"; - print ''; - print '
'; - } - else - { - print ($fichinter->note_public?nl2br($fichinter->note_public):" "); - } - print "
'.$langs->trans("NotePrivate").' :'; - if ($action == 'edit') - { - print '
'; - print ''; - print ''; - print '
"; - print ''; - print '
'; - } - else - { - print ($fichinter->note_private?nl2br($fichinter->note_private):" "); - } - print "
"; - - print ''; - - /* - * Actions - */ - - print '
'; - if ($user->rights->ficheinter->creer && $action <> 'edit') - { - print ''.$langs->trans('Modify').''; - } + + print '
'; + + include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'); + print '
'; } } } -$db->close(); + llxFooter(); +$db->close(); ?> diff --git a/htdocs/theme/auguria/style.css.php b/htdocs/theme/auguria/style.css.php index 3d547852aa5..d3d7578d7c0 100644 --- a/htdocs/theme/auguria/style.css.php +++ b/htdocs/theme/auguria/style.css.php @@ -1219,7 +1219,7 @@ table.liste td { padding-right: 2px; } -tr.liste_titre +div.liste_titre, tr.liste_titre { height: 24px; background: #7699A9; @@ -2000,6 +2000,34 @@ a.cke_dialog_ui_button height: 72px !important; } +/* ============================================================================== */ +/* Table with div */ +/* ============================================================================== */ + +div.table-border { + display:table; + width: 100%; + border-collapse: collapse; + border: 1px solid #9CACBB; +} +div.table-border-row { + display:table-row; +} +div.table-key-border-col { + display:table-cell; + width: 25%; + vertical-align:top; + padding: 1px 2px 1px 1px; + border: 1px solid #9CACBB; + border-collapse: collapse; +} +div.table-val-border-col { + display:table-cell; + width:auto; + padding: 1px 2px 1px 1px; + border: 1px solid #9CACBB; + border-collapse: collapse; +} /* ============================================================================== */ /* Test using div instead of tables */ diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 1de8f765189..357e4f14d12 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -2318,6 +2318,34 @@ div.scroll2 { width: 582px !important; } +/* ============================================================================== */ +/* Table with div */ +/* ============================================================================== */ + +div.table-border { + display:table; + width: 100%; + border-collapse: collapse; + border: 1px solid #9CACBB; +} +div.table-border-row { + display:table-row; +} +div.table-key-border-col { + display:table-cell; + width: 25%; + vertical-align:top; + padding: 1px 2px 1px 1px; + border: 1px solid #9CACBB; + border-collapse: collapse; +} +div.table-val-border-col { + display:table-cell; + width:auto; + padding: 1px 2px 1px 1px; + border: 1px solid #9CACBB; + border-collapse: collapse; +} close(); diff --git a/quickbuild.xml b/quickbuild.xml index e5d6707b1ab..09bed28b867 100644 --- a/quickbuild.xml +++ b/quickbuild.xml @@ -2,7 +2,7 @@ - + @@ -41,6 +41,7 @@