diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 0a33c822392..5289521295b 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -438,7 +438,6 @@ else if ($action == 'setstatut' && $user->rights->propale->cloturer) { $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("CloseAs")).'
'; $action='statut'; - $action='statut'; } else { @@ -2005,6 +2004,7 @@ else } -$db->close(); +// End of page llxFooter(); +$db->close(); ?> diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index d11ab2b1ceb..2a188fa044e 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -868,6 +868,7 @@ class Commande extends CommonObject function createFromProposal($object) { global $conf,$user,$langs; + global $hookmanager; $error=0; @@ -915,16 +916,26 @@ class Commande extends CommonObject $this->note = $object->note; $this->note_public = $object->note_public; - $this->origin = $object->element; - $this->origin_id = $object->id; + $this->origin = $object->element; + $this->origin_id = $object->id; + + // Possibility to add external linked objects with hooks + $this->linked_objects[$this->origin] = $this->origin_id; + if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects)) + { + $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects); + } $ret = $this->create($user); if ($ret > 0) { // Actions hooked (by external module) - include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); - $hookmanager=new HookManager($this->db); + if (! is_object($hookmanager)) + { + include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); + $hookmanager=new HookManager($this->db); + } $hookmanager->initHooks(array('orderdao')); $parameters=array('objFrom'=>$object); diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index e26f0c3390b..6b04d51f2de 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1236,13 +1236,16 @@ if ($action == 'create' && $user->rights->commande->creer) $ref_client = (!empty($objectsrc->ref_client)?$object->ref_client:''); $soc = $objectsrc->client; - $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); - $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); - $availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0)); - $demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0)); - $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); - $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); + $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); + $availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0)); + $demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0)); + $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); + $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; + + $note_private = (! empty($objectsrc->note) ? $objectsrc->note : (! empty($objectsrc->note_private) ? $objectsrc->note_private : '')); + $note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : ''); // Object source contacts list $srccontactslist = $objectsrc->liste_contact(-1,'external',1); @@ -1383,8 +1386,8 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; print ''.$langs->trans('NotePublic').''; print ''; - print ''; + print ''; + print ''; // Note privee if (! $user->societe_id) @@ -1392,8 +1395,8 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; print ''.$langs->trans('NotePrivate').''; print ''; - print ''; + print ''; + print ''; } if (is_object($objectsrc)) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index dad4757f61d..f0af7b909b9 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -669,8 +669,15 @@ class Facture extends CommonObject $this->note = $object->note; $this->note_public = $object->note_public; - $this->origin = $object->element; - $this->origin_id = $object->id; + $this->origin = $object->element; + $this->origin_id = $object->id; + + // Possibility to add external linked objects with hooks + $this->linked_objects[$this->origin] = $this->origin_id; + if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects)) + { + $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects); + } $ret = $this->create($user); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 497607988e8..ef21b9a7aa0 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1815,32 +1815,38 @@ abstract class CommonObject } /** - * Set statut of an object + * Set status of an object * - * @param int $statut Statut to set + * @param int $status Status to set * @param int $elementId Id of element to force (use this->id by default) * @param string $elementType Type of element to force (use ->this->element by default) * @return int <0 if KO, >0 if OK */ - function setStatut($statut,$elementId='',$elementType='') + function setStatut($status,$elementId='',$elementType='') { $elementId = (!empty($elementId)?$elementId:$this->id); $elementTable = (!empty($elementType)?$elementType:$this->table_element); + + $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable; - $sql.= " SET fk_statut = ".$statut; + $sql.= " SET fk_statut = ".$status; $sql.= " WHERE rowid=".$elementId; dol_syslog(get_class($this)."::setStatut sql=".$sql, LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $this->error=$this->db->lasterror(); - dol_syslog(get_class($this)."::setStatut ".$this->error, LOG_ERR); - return -1; + if ($this->db->query($sql)) + { + $this->db->commit(); + $this->statut = $status; + return 1; + } + else + { + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::setStatut ".$this->error, LOG_ERR); + $this->db->rollback(); + return -1; } - - return 1; } diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 28b9fc49260..c381fe14b94 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -693,9 +693,13 @@ if ($action == 'create') if ($conf->projet->enabled) { $langs->load("project"); - + print ''.$langs->trans("Project").''; - $numprojet=select_projects($soc->id,GETPOST('projectid','int'),'projectid'); + if ($societe->fournisseur==1) + $numprojet=select_projects(-1,$_POST["projectid"],'projectid'); + else + $numprojet=select_projects($societe->id,$_POST["projectid"],'projectid'); + //$numprojet=select_projects($soc->id,GETPOST('projectid','int'),'projectid'); if ($numprojet==0) { print '   '.$langs->trans("AddProject").''; diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index ac741e683f3..677c477bb02 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004-2006 Rodolphe Quiedeville * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005 Eric Seigne - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2011 Juanjo Menent * Copyright (C) 2011 Philippe Grand * @@ -1231,7 +1231,7 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - print $form->load_tva('tva_tx',$line->tva_tx); + print $form->load_tva('tva_tx',$line->tva_tx,$soc,$mysoc); print ''; print ''; print ''; @@ -1605,7 +1605,8 @@ if ($id > 0 || ! empty($ref)) } } -$db->close(); +// End of page llxFooter(); +$db->close(); ?> diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 9debd0a0827..d0acf26d822 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -1060,7 +1060,8 @@ if ($action == 'create') } else { - if ($conf->global->PRODUCT_SHOW_WHEN_CREATE) + // TODO more bugs + if (1==2 && $conf->global->PRODUCT_SHOW_WHEN_CREATE) { print ''; print ' '.$langs->trans('Label').''; @@ -1838,7 +1839,8 @@ else } } -llxFooter(); +// End of page +llxFooter(); $db->close(); ?>