Ejemplo n.º 1
0
             if (!$error) {
                 $result = $object->setThirdPartyId($socid);
                 if ($result < 0) {
                     dol_print_error($object->db, $object->error);
                 }
                 $action = '';
             }
         }
     }
 }
 // Create user from a member
 if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) {
     if ($result > 0) {
         // Creation user
         $nuser = new User($db);
         $result = $nuser->create_from_member($object, GETPOST('login'));
         if ($result < 0) {
             $langs->load("errors");
             setEventMessages($langs->trans($nuser->error), null, 'errors');
         }
     } else {
         setEventMessages($object->errors, $object->error, 'errors');
     }
 }
 // Create third party from a member
 if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) {
     if ($result > 0) {
         // Creation user
         $company = new Societe($db);
         $result = $company->create_from_member($object, GETPOST('companyname'));
         if ($result < 0) {
 /**
  *  Load data control
  *
  *  @param	string	$action    Type of action
  *  @param	int		$id			Id of object
  *	@return	void
  */
 function doActions(&$action, $id)
 {
     global $conf, $user, $langs;
     // Creation utilisateur depuis Adherent
     if ($action == 'confirm_create_user' && GETPOST("confirm") == 'yes') {
         // Recuperation adherent actuel
         $result = $this->object->fetch($id);
         if ($result > 0) {
             $this->db->begin();
             // Creation user
             $nuser = new User($this->db);
             $result = $nuser->create_from_member($this->object, $_POST["login"]);
             if ($result > 0) {
                 $result2 = $nuser->setPassword($user, $_POST["password"], 0, 1, 1);
                 if ($result2) {
                     $this->db->commit();
                 } else {
                     $this->db->rollback();
                 }
             } else {
                 $this->errors[] = $nuser->error;
                 $this->db->rollback();
             }
         } else {
             $this->errors = $this->object->errors;
         }
     }
     // Creation adherent
     if ($action == 'add') {
         $this->assign_post();
         if (!$_POST["name"]) {
             array_push($this->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname") . ' / ' . $langs->transnoentities("Label")));
             $action = 'create';
         }
         if ($_POST["name"]) {
             $id = $this->object->create($user);
             if ($id > 0) {
                 header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
                 exit;
             } else {
                 $this->errors = $this->object->errors;
                 $action = 'create';
             }
         }
     }
     if ($action == 'confirm_delete' && GETPOST("confirm") == 'yes') {
         $result = $this->object->fetch($id);
         $this->object->old_name = $_POST["old_name"];
         $this->object->old_firstname = $_POST["old_firstname"];
         $result = $this->object->delete();
         if ($result > 0) {
             header("Location: list.php");
             exit;
         } else {
             $this->errors = $this->object->errors;
         }
     }
     if ($action == 'update') {
         if ($_POST["cancel"]) {
             header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $this->object->id);
             exit;
         }
         if (empty($_POST["name"])) {
             $this->error = array($langs->trans("ErrorFieldRequired", $langs->transnoentities("Name") . ' / ' . $langs->transnoentities("Label")));
             $action = 'edit';
         }
         if (empty($this->error)) {
             $this->object->fetch($_POST["adherentid"]);
             $this->object->oldcopy = clone $this->object;
             $this->assign_post();
             $result = $this->object->update($_POST["adherentid"], $user);
             if ($result > 0) {
                 header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $this->object->id);
                 exit;
             } else {
                 $this->errors = $this->object->errors;
                 $action = 'edit';
             }
         }
     }
 }
Ejemplo n.º 3
0
				if ($result < 0) dol_print_error($adh->db,$adh->error);
				$_POST['action']='';
				$action='';
			}
		}
	}
}

// Create user from a member
if ($_POST["action"] == 'confirm_create_user' && $_POST["confirm"] == 'yes' && $user->rights->user->user->creer)
{
	if ($result > 0)
	{
		// Creation user
		$nuser = new User($db);
		$result=$nuser->create_from_member($adh,$_POST["login"]);

		if ($result < 0)
		{
			$langs->load("errors");
			$errmsg=$langs->trans($nuser->error);
		}
	}
	else
	{
		$errmsg=$adh->error;
	}
}

// Create third party from a member
if ($_POST["action"] == 'confirm_create_thirdparty' && $_POST["confirm"] == 'yes' && $user->rights->societe->creer)