Esempio n. 1
0
     $agf->fk_biens = "0";
     $agf->descriptif = GETPOST('descriptif', 'alpha');
     $agf->entity = getpost('entity');
     $agf->datec = $now;
     $agf->date_contrat = $now;
     $agf->date_creation = $now;
     $agf->date_cloture = $now;
     $agf->status = "1";
     $agf->mise_en_service = $now;
     $agf->fin_validite = $now;
     $agf->fk_bails = '0';
     $agf->fk_commercial = '1';
     $agf->fk_user_author = $user;
     $agf->fk_user_mod = '1';
     $agf->fk_user_author = '1';
     $result = $agf->create($user);
     if ($result > 0) {
         if ($url_return) {
             Header("Location: " . $url_return);
         } else {
             Header("Location: " . $_SERVER['PHP_SELF'] . "?action=edit&id=" . $result);
         }
         exit;
     } else {
         dol_syslog("Gestimmo::site::card error=" . $agf->error, LOG_ERR);
         $mesg = '<div class="error">' . $agf->error . '</div>';
     }
 } else {
     Header("Location: list.php");
     exit;
 }
Esempio n. 2
0
 /**
  *	Load an object from its id and create a new one in database
  *
  *	@param	int		$fromid     Id of object to clone
  * 	@return	int					New id of clone
  */
 function createFromClone($fromid)
 {
     global $user, $langs;
     $error = 0;
     $object = new Mandat($this->db);
     $this->db->begin();
     // Load source object
     $object->fetch($fromid);
     $object->id = 0;
     $object->statut = 0;
     // Clear fields
     // ...
     // Create clone
     $result = $object->create($user);
     // Other options
     if ($result < 0) {
         $this->error = $object->error;
         $error++;
     }
     if (!$error) {
     }
     // End
     if (!$error) {
         $this->db->commit();
         return $object->id;
     } else {
         $this->db->rollback();
         return -1;
     }
 }
Esempio n. 3
0
*/
$action = "list";
// Protection if external user
if ($user->societe_id > 0) {
    //accessforbidden();
}
/*******************************************************************
* ACTIONS
*
* Put here all code to do according to value of "action" parameter
********************************************************************/
if ($action == 'add') {
    $object = new Mandat($db);
    $object->prop1 = $_POST["field1"];
    $object->prop2 = $_POST["field2"];
    $result = $object->create($user);
    if ($result > 0) {
        // Creation OK
    }
    // Creation KO
    $mesg = $object->error;
}
/***************************************************
* VIEW
*
* Put here all code to build page
****************************************************/
$texte = "Listes des mandats";
//llxHeader('','Liste mandats','');
llxHeader("", "", $texte);
$form = new Form($db);
Esempio n. 4
0
 // For compatibility
 if ($element == 'order') {
     $element = $subelement = 'commande';
 }
 if ($element == 'propal') {
     $element = 'comm/propal';
     $subelement = 'propal';
 }
 $object->origin = $_POST['origin'];
 $object->origin_id = $_POST['originid'];
 // Possibility to add external linked objects with hooks
 $object->linked_objects[$object->origin] = $object->origin_id;
 if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects'])) {
     $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']);
 }
 $id = $object->create($user);
 if ($id < 0) {
     $mesg = '<div class="error">' . $object->error . '</div>';
 }
 if ($id > 0) {
     dol_include_once('/' . $element . '/class/' . $subelement . '.class.php');
     $classname = ucfirst($subelement);
     $srcobject = new $classname($db);
     dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines");
     $result = $srcobject->fetch($object->origin_id);
     if ($result > 0) {
         $srcobject->fetch_thirdparty();
         $lines = $srcobject->lines;
         if (empty($lines) && method_exists($srcobject, 'fetch_lines')) {
             $lines = $srcobject->fetch_lines();
         }