diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index ae741698641..b7c0e83904c 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -199,12 +199,10 @@ if ($id > 0 || ! empty($ref)) print ""; 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..a75ac9a504d 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -148,17 +148,6 @@ if ($id > 0 || ! empty($ref)) 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..152d690fff7 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,7 +99,7 @@ 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 ''; @@ -114,64 +107,14 @@ if ($id > 0 || ! empty($ref)) 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 ""; + include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'); - // 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 ''; - - /* - * 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/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..dd05eede948 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 '"; + include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'); - // 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,22 @@ 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 "
"; - - - /* - * Actions - */ - print ''; - print '
'; - - if ($user->rights->facture->creer && $_GET["action"] <> 'edit') - { - print "id&action=edit\">".$langs->trans('Modify').""; - } - - print "
"; + print ""; + print ''; } -$db->close(); llxFooter(); +$db->close(); ?> 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..ce17cc34faf 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,34 @@ 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 '"; - } - + + include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'); + 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 '
'; } } } -$db->close(); + llxFooter(); +$db->close(); ?>