diff --git a/ChangeLog b/ChangeLog index e63d2f537b0..dd57b6137b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ For users: - Look enhancements for graphics (add transparency). - Added statistics report for supplier invoices - Added average amount in invoices statistics reports. +- Can move a contract line to another contract of same third party. For translators: - The errors language file contains only error or warning messages with diff --git a/htdocs/contrat/contrat.class.php b/htdocs/contrat/contrat.class.php index 6290f6265c1..92e7752c6b8 100644 --- a/htdocs/contrat/contrat.class.php +++ b/htdocs/contrat/contrat.class.php @@ -1117,11 +1117,10 @@ class Contrat extends CommonObject } } - - /** - * \brief R�cup�re les lignes de detail du contrat - * \param statut Statut des lignes detail � r�cup�rer - * \return array Tableau des lignes de details + /** + * \brief Return list of line rowid + * \param statut Status of lines to get + * \return array Array of line's rowid */ function array_detail($statut=-1) { @@ -1132,6 +1131,7 @@ class Contrat extends CommonObject $sql.= " WHERE fk_contrat =".$this->id; if ($statut >= 0) $sql.= " AND statut = '$statut'"; + dolibarr_syslog("Contrat::array_detail() sql=".$sql,LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { @@ -1151,12 +1151,49 @@ class Contrat extends CommonObject return -1; } } + + /** + * \brief Return list of other contracts for same company than current contract + * \param option 'all' or 'others' + * \return array Array of contracts id + */ + function getListOfContracts($option='all') + { + $tab=array(); + + $sql = "SELECT c.rowid, c.ref"; + $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c"; + $sql.= " WHERE fk_soc =".$this->socid; + if ($option == 'others') $sql.= " AND c.rowid != ".$this->id; + + dolibarr_syslog("Contrat::getOtherContracts() sql=".$sql,LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $num=$this->db->num_rows($resql); + $i=0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + $contrat=new Contrat($this->db); + $contrat->fetch($obj->rowid); + $tab[]=$contrat; + $i++; + } + return $tab; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } /** * \brief Charge indicateurs this->nbtodo et this->nbtodolate de tableau de bord * \param user Objet user - * \param mode "inactive" pour services � activer, "expired" pour services expir�s + * \param mode "inactive" pour services a activer, "expired" pour services expires * \return int <0 si ko, >0 si ok */ function load_board($user,$mode) @@ -1275,7 +1312,7 @@ class ContratLigne /** * \brief Constructeur d'objets ligne de contrat - * \param DB handler d'acc�s base de donn�e + * \param DB Database access handler */ function ContratLigne($DB) { diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 952f10fcc37..da17170cc77 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -131,10 +131,6 @@ if ($_POST["date_end_real_updatemonth"] && $_POST["date_end_real_updateday"] && $date_end_real_update=dolibarr_mktime(12, 0 , 0, $_POST["date_end_real_updatemonth"], $_POST["date_end_real_updateday"], $_POST["date_end_real_updateyear"]); } - -/* - * Actions - */ if ($_POST["action"] == 'add') { $datecontrat = dolibarr_mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); @@ -391,6 +387,32 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes') } } +if ($_POST["action"] == 'confirm_move' && $_POST["confirm"] == 'yes') +{ + if ($user->rights->contrat->creer) + { + if ($_POST['newcid'] > 0) + { + $contractline = new ContratLigne($db); + $result=$contractline->fetch($_GET["lineid"]); + $contractline->fk_contrat = $_POST["newcid"]; + $result=$contractline->update($user,1); + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF'].'?id='.$_GET['id']); + return; + } + else + { + $mesg='
| '; } - // Icon update et delete (statut contrat 0=brouillon,1=valid�,2=ferm�) + // Icon move, update et delete (statut contrat 0=brouillon,1=valid�,2=ferm�) print ' | ';
+ if (sizeof($arrayothercontracts) && $contrat->statut != 2 && $user->rights->contrat->creer)
+ {
+ print '';
+ print img_picto($langs->trans("MoveToAnotherContract"),'uparrow');
+ print '';
+ }
+ else {
+ print ' ';
+ }
if ($contrat->statut != 2 && $user->rights->contrat->creer)
{
print '';
@@ -824,11 +857,11 @@ else
print '| ';
- // Date pr�vues
+ // Date planned
print $langs->trans("DateStartPlanned").': ';
if ($objp->date_debut) {
print dolibarr_print_date($objp->date_debut);
- // Warning si date prevu pass�e et pas en service
+ // Warning si date prevu passee et pas en service
if ($objp->statut == 0 && $objp->date_debut < time() - $conf->contrat->warning_delay) { print " ".img_warning($langs->trans("Late")); }
}
else print $langs->trans("Unknown");
@@ -904,6 +937,27 @@ else
print " | |