本文整理汇总了PHP中dol_clone函数的典型用法代码示例。如果您正苦于以下问题:PHP dol_clone函数的具体用法?PHP dol_clone怎么用?PHP dol_clone使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dol_clone函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* @param array $options Options array
* @param int $fk_element fk_element
* @param string $element element
*/
function __construct($options = null, $fk_element = null, $element = null)
{
global $db, $conf;
global $object;
$this->fk_element = $fk_element;
$this->element = $element;
$pathname = $filename = $element;
if (preg_match('/^([^_]+)_([^_]+)/i', $element, $regs)) {
$pathname = $regs[1];
$filename = $regs[2];
}
$parentForeignKey = '';
// For compatibility
if ($element == 'propal') {
$pathname = 'comm/propal';
$dir_output = $conf->{$element}->dir_output;
} elseif ($element == 'facture') {
$pathname = 'compta/facture';
$dir_output = $conf->{$element}->dir_output;
} elseif ($element == 'project') {
$element = $pathname = 'projet';
$dir_output = $conf->{$element}->dir_output;
} elseif ($element == 'project_task') {
$pathname = 'projet';
$filename = 'task';
$dir_output = $conf->projet->dir_output;
$parentForeignKey = 'fk_project';
$parentClass = 'Project';
$parentElement = 'projet';
$parentObject = 'project';
} elseif ($element == 'fichinter') {
$element = 'ficheinter';
$dir_output = $conf->{$element}->dir_output;
} elseif ($element == 'order_supplier') {
$pathname = 'fourn';
$filename = 'fournisseur.commande';
$dir_output = $conf->fournisseur->commande->dir_output;
} elseif ($element == 'invoice_supplier') {
$pathname = 'fourn';
$filename = 'fournisseur.facture';
$dir_output = $conf->fournisseur->facture->dir_output;
} elseif ($element == 'product') {
$dir_output = $conf->product->multidir_output[$conf->entity];
} elseif ($element == 'action') {
$pathname = 'comm/action';
$filename = 'actioncomm';
$dir_output = $conf->agenda->dir_output;
} elseif ($element == 'chargesociales') {
$pathname = 'compta/sociales';
$filename = 'chargesociales';
$dir_output = $conf->tax->dir_output;
} else {
$dir_output = $conf->{$element}->dir_output;
}
dol_include_once('/' . $pathname . '/class/' . $filename . '.class.php');
$classname = ucfirst($filename);
if ($element == 'order_supplier') {
$classname = 'CommandeFournisseur';
} elseif ($element == 'invoice_supplier') {
$classname = 'FactureFournisseur';
}
$object = new $classname($db);
$object->fetch($fk_element);
if (!empty($parentForeignKey)) {
dol_include_once('/' . $parentElement . '/class/' . $parentObject . '.class.php');
$parent = new $parentClass($db);
$parent->fetch($object->{$parentForeignKey});
if (!empty($parent->socid)) {
$parent->fetch_thirdparty();
}
$object->{$parentObject} = dol_clone($parent);
} else {
$object->fetch_thirdparty();
}
$object_ref = dol_sanitizeFileName($object->ref);
if ($element == 'invoice_supplier') {
$object_ref = get_exdir($object->id, 2) . $object_ref;
} else {
if ($element == 'project_task') {
$object_ref = $object->project->ref . '/' . $object_ref;
}
}
$this->options = array('script_url' => $_SERVER['PHP_SELF'], 'upload_dir' => $dir_output . '/' . $object_ref . '/', 'upload_url' => DOL_URL_ROOT . '/document.php?modulepart=' . $element . '&attachment=1&file=/' . $object_ref . '/', 'param_name' => 'files', 'delete_type' => 'DELETE', 'max_file_size' => null, 'min_file_size' => 1, 'accept_file_types' => '/.+$/i', 'max_number_of_files' => null, 'max_width' => null, 'max_height' => null, 'min_width' => 1, 'min_height' => 1, 'discard_aborted_uploads' => true, 'image_versions' => array('thumbnail' => array('upload_dir' => $dir_output . '/' . $object_ref . '/thumbs/', 'upload_url' => DOL_URL_ROOT . '/document.php?modulepart=' . $element . '&attachment=1&file=/' . $object_ref . '/thumbs/', 'max_width' => 80, 'max_height' => 80)));
if ($options) {
$this->options = array_replace_recursive($this->options, $options);
}
}
示例2: createFromClone
/**
* Load an object from its id and create a new one in database
*
* @return int New id of clone
*/
function createFromClone()
{
global $conf, $user, $langs, $hookmanager;
$error = 0;
$this->context['createfromclone'] = 'createfromclone';
$this->db->begin();
// Load source object
$objFrom = dol_clone($this);
$this->id = 0;
$this->statut = 0;
// Clear fields
$this->user_author_id = $user->id;
$this->user_valid = '';
$this->date_creation = '';
$this->date_validation = '';
$this->ref_supplier = '';
// Create clone
$result = $this->create($user);
if ($result < 0) {
$error++;
}
if (!$error) {
// Hook of thirdparty module
if (is_object($hookmanager)) {
$parameters = array('objFrom' => $objFrom);
$action = '';
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action);
// Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
$error++;
}
}
// Call trigger
$result = $this->call_trigger('ORDER_SUPPLIER_CLONE', $user);
if ($result < 0) {
$error++;
}
// End call triggers
}
unset($this->context['createfromclone']);
// End
if (!$error) {
$this->db->commit();
return $this->id;
} else {
$this->db->rollback();
return -1;
}
}
示例3: setEventMessage
$action = '';
}
include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php';
// Must be include, not include_once
include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php';
// Must be include, not include_once
include DOL_DOCUMENT_ROOT . '/core/actions_lineupdown.inc.php';
// Must be include, not include_once
// Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande->creer) {
if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) {
setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors');
} else {
if ($object->id > 0) {
// Because createFromClone modifies the object, we must clone it so that we can restore it later
$orig = dol_clone($object);
$result = $object->createFromClone($socid);
if ($result > 0) {
header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result);
exit;
} else {
setEventMessage($object->error, 'errors');
$object = $orig;
$action = '';
}
}
}
} else {
if ($action == 'reopen' && $user->rights->commande->creer) {
if ($object->statut == Commande::STATUS_CANCELED || $object->statut == Commande::STATUS_CLOSED) {
$result = $object->set_reopen($user);
示例4: build_file
/**
* Build export file.
* File is built into directory $conf->export->dir_temp.'/'.$user->id
* Arrays this->array_export_xxx are already loaded for required datatoexport
*
* @param User $user User that export
* @param string $model Export format
* @param string $datatoexport Name of dataset to export
* @param array $array_selected Filter on array of fields to export
* @param array $array_filterValue Filter on array of fields with a filter
* @param string $sqlquery If set, transmit the sql request for select (otherwise, sql request is generated from arrays)
* @return int <0 if KO, >0 if OK
*/
function build_file($user, $model, $datatoexport, $array_selected, $array_filterValue, $sqlquery = '')
{
global $conf, $langs;
$indice = 0;
asort($array_selected);
dol_syslog(get_class($this) . "::" . __FUNCTION__ . " " . $model . ", " . $datatoexport . ", " . implode(",", $array_selected));
// Check parameters or context properties
if (empty($this->array_export_fields) || !is_array($this->array_export_fields)) {
$this->error = "ErrorBadParameter";
return -1;
}
// Creation de la classe d'export du model ExportXXX
$dir = DOL_DOCUMENT_ROOT . "/core/modules/export/";
$file = "export_" . $model . ".modules.php";
$classname = "Export" . $model;
require_once $dir . $file;
$objmodel = new $classname($this->db);
if (!empty($sqlquery)) {
$sql = $sqlquery;
} else {
// Define value for indice from $datatoexport
$foundindice = 0;
foreach ($this->array_export_code as $key => $dataset) {
if ($datatoexport == $dataset) {
$indice = $key;
$foundindice++;
//print "Found indice = ".$indice." for dataset=".$datatoexport."\n";
break;
}
}
if (empty($foundindice)) {
$this->error = "ErrorBadParameter can't find dataset " . $datatoexport . " into preload arrays this->array_export_code";
return -1;
}
$sql = $this->build_sql($indice, $array_selected, $array_filterValue);
}
// Run the sql
$this->sqlusedforexport = $sql;
dol_syslog(get_class($this) . "::" . __FUNCTION__ . " sql=" . $sql);
$resql = $this->db->query($sql);
if ($resql) {
//$this->array_export_label[$indice]
$filename = "export_" . $datatoexport;
$filename .= '.' . $objmodel->getDriverExtension();
$dirname = $conf->export->dir_temp . '/' . $user->id;
$outputlangs = dol_clone($langs);
// We clone to have an object we can modify (for example to change output charset by csv handler) without changing original value
// Open file
dol_mkdir($dirname);
$result = $objmodel->open_file($dirname . "/" . $filename, $outputlangs);
if ($result >= 0) {
// Genere en-tete
$objmodel->write_header($outputlangs);
// Genere ligne de titre
$objmodel->write_title($this->array_export_fields[$indice], $array_selected, $outputlangs, $this->array_export_TypeFields[$indice]);
$var = true;
while ($objp = $this->db->fetch_object($resql)) {
$var = !$var;
// Process special operations
if (!empty($this->array_export_special[$indice])) {
foreach ($this->array_export_special[$indice] as $key => $value) {
if (!array_key_exists($key, $array_selected)) {
continue;
}
// Field not selected
// Operation NULLIFNEG
if ($this->array_export_special[$indice][$key] == 'NULLIFNEG') {
//$alias=$this->array_export_alias[$indice][$key];
$alias = str_replace(array('.', '-'), '_', $key);
if ($objp->{$alias} < 0) {
$objp->{$alias} = '';
}
}
// Operation ZEROIFNEG
if ($this->array_export_special[$indice][$key] == 'ZEROIFNEG') {
//$alias=$this->array_export_alias[$indice][$key];
$alias = str_replace(array('.', '-'), '_', $key);
if ($objp->{$alias} < 0) {
$objp->{$alias} = '0';
}
}
}
}
// end of special operation processing
$objmodel->write_record($array_selected, $objp, $outputlangs, $this->array_export_TypeFields[$indice]);
}
// Genere en-tete
//.........这里部分代码省略.........
示例5: doActions
//.........这里部分代码省略.........
$contact->zip = $this->object->zip;
$contact->town = $this->object->town;
$contact->country_id = $this->object->country_id;
$contact->socid = $this->object->id;
// fk_soc
$contact->status = 1;
$contact->email = $this->object->email;
$contact->priv = 0;
$result = $contact->create($user);
}
} else {
$this->errors = $this->object->errors;
}
if ($result >= 0) {
$this->db->commit();
if ($this->object->client == 1) {
header("Location: " . DOL_URL_ROOT . "/comm/fiche.php?socid=" . $this->object->id);
return;
} else {
if ($this->object->fournisseur == 1) {
header("Location: " . DOL_URL_ROOT . "/fourn/fiche.php?socid=" . $this->object->id);
return;
} else {
header("Location: " . $_SERVER["PHP_SELF"] . "?socid=" . $this->object->id);
return;
}
}
exit;
} else {
$this->db->rollback();
$this->errors = $this->object->errors;
$action = 'create';
}
}
if ($action == 'update') {
if ($_POST["cancel"]) {
header("Location: " . $_SERVER["PHP_SELF"] . "?socid=" . $this->object->id);
exit;
}
$oldsoccanvas = dol_clone($this->object);
// To avoid setting code if third party is not concerned. But if it had values, we keep them.
if (empty($this->object->client) && empty($oldsoccanvas->code_client)) {
$this->object->code_client = '';
}
if (empty($this->object->fournisseur) && empty($oldsoccanvas->code_fournisseur)) {
$this->object->code_fournisseur = '';
}
$result = $this->object->update($this->object->id, $user, 1, $oldsoccanvas->codeclient_modifiable(), $oldsoccanvas->codefournisseur_modifiable());
if ($result >= 0) {
header("Location: " . $_SERVER["PHP_SELF"] . "?socid=" . $this->object->id);
exit;
} else {
$reload = 0;
$this->errors = $this->object->errors;
$action = "edit";
}
}
}
}
if ($action == 'confirm_delete' && GETPOST("confirm") == 'yes') {
$result = $this->object->delete($this->object->id);
if ($result >= 0) {
header("Location: " . DOL_URL_ROOT . "/societe/societe.php?delsoc=" . $this->object->nom . "");
exit;
} else {
$reload = 0;
$this->errors = $this->object->errors;
$action = '';
}
}
/*
* Generate document
*/
if ($action == 'builddoc') {
if (is_numeric(GETPOST('model'))) {
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Model"));
} else {
require_once DOL_DOCUMENT_ROOT . '/core/modules/societe/modules_societe.class.php';
$this->object->fetch_thirdparty();
// Define output language
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) {
$newlang = GETPOST('lang_id');
}
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
$newlang = $this->object->default_lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$result = thirdparty_doc_create($this->db, $this->object->id, '', GETPOST('model', 'alpha'), $outputlangs);
if ($result <= 0) {
dol_print_error($this->db, $result);
exit;
}
}
}
}
示例6: list_of_autoecmfiles
//.........这里部分代码省略.........
$ref = isset($reg[1]) ? $reg[1] : '';
}
if ($modulepart == 'tax') {
preg_match('/(\\d+)\\/[^\\/]+$/', $relativefile, $reg);
$id = isset($reg[1]) ? $reg[1] : '';
}
if ($modulepart == 'project') {
preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg);
$ref = isset($reg[1]) ? $reg[1] : '';
}
if ($modulepart == 'fichinter') {
preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg);
$ref = isset($reg[1]) ? $reg[1] : '';
}
if ($modulepart == 'user') {
preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg);
$id = isset($reg[1]) ? $reg[1] : '';
}
if (!$id && !$ref) {
continue;
}
$found = 0;
if (!empty($this->cache_objects[$modulepart . '_' . $id . '_' . $ref])) {
$found = 1;
} else {
//print 'Fetch '.$id." - ".$ref.'<br>';
if ($id) {
$result = $object_instance->fetch($id);
} else {
//fetchOneLike looks for objects with wildcards in its reference.
//It is useful for those masks who get underscores instead of their actual symbols
//fetchOneLike requires some info in the object. If it doesn't have it, then 0 is returned
//that's why we look only look fetchOneLike when fetch returns 0
if (!($result = $object_instance->fetch('', $ref))) {
$result = $object_instance->fetchOneLike($ref);
}
}
if ($result > 0) {
$found = 1;
$this->cache_objects[$modulepart . '_' . $id . '_' . $ref] = dol_clone($object_instance);
}
// Save object into a cache
if ($result == 0) {
$found = 1;
$this->cache_objects[$modulepart . '_' . $id . '_' . $ref] = 'notfound';
unset($filearray[$key]);
}
}
if (!$found > 0 || !is_object($this->cache_objects[$modulepart . '_' . $id . '_' . $ref])) {
continue;
}
// We do not show orphelins files
$var = !$var;
print '<tr ' . $bc[$var] . '>';
print '<td>';
if ($found > 0 && is_object($this->cache_objects[$modulepart . '_' . $id . '_' . $ref])) {
print $this->cache_objects[$modulepart . '_' . $id . '_' . $ref]->getNomUrl(1, 'document');
} else {
print $langs->trans("ObjectDeleted", $id ? $id : $ref);
}
print '</td>';
print '<td>';
//print "XX".$file['name']; //$file['name'] must be utf8
print '<a data-ajax="false" href="' . DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart;
if ($forcedownload) {
print '&attachment=1';
}
print '&file=' . urlencode($relativefile) . '">';
print img_mime($file['name'], $file['name'] . ' (' . dol_print_size($file['size'], 0, 0) . ')') . ' ';
print dol_trunc($file['name'], $maxlength, 'middle');
print '</a>';
print "</td>\n";
print '<td align="right">' . dol_print_size($file['size'], 1, 1) . '</td>';
print '<td align="center">' . dol_print_date($file['date'], "dayhour") . '</td>';
print '<td align="right">';
if (!empty($useinecm)) {
print '<a data-ajax="false" href="' . DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart;
}
if ($forcedownload) {
print '&attachment=1';
}
print '&file=' . urlencode($relativefile) . '">';
print img_view() . '</a> ';
//if ($permtodelete) print '<a href="'.$url.'?id='.$object->id.'§ion='.$_REQUEST["section"].'&action=delete&urlfile='.urlencode($file['name']).'">'.img_delete().'</a>';
//else print ' ';
print "</td></tr>\n";
}
}
if (count($filearray) == 0) {
print '<tr ' . $bc[false] . '><td colspan="4">';
if (empty($textifempty)) {
print $langs->trans("NoFileFound");
} else {
print $textifempty;
}
print '</td></tr>';
}
print "</table>";
// Fin de zone
}
示例7: createFromClone
/**
* Load an object from its id and create a new one in database
*
* @param int $socid Id of thirdparty
* @return int New id of clone
*/
function createFromClone($socid = 0)
{
global $user, $langs, $conf, $hookmanager;
$this->context['createfromclone'] = 'createfromclone';
$error = 0;
$now = dol_now();
$this->db->begin();
// get extrafields so they will be clone
foreach ($this->lines as $line) {
$line->fetch_optionals($line->rowid);
}
// Load source object
$objFrom = dol_clone($this);
$objsoc = new Societe($this->db);
// Change socid if needed
if (!empty($socid) && $socid != $this->socid) {
if ($objsoc->fetch($socid) > 0) {
$this->socid = $objsoc->id;
$this->cond_reglement_id = !empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0;
$this->mode_reglement_id = !empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0;
$this->fk_project = '';
$this->fk_delivery_address = '';
}
// reset ref_client
$this->ref_client = '';
// TODO Change product price if multi-prices
} else {
$objsoc->fetch($this->socid);
}
$this->id = 0;
$this->statut = 0;
if (empty($conf->global->PROPALE_ADDON) || !is_readable(DOL_DOCUMENT_ROOT . "/core/modules/propale/" . $conf->global->PROPALE_ADDON . ".php")) {
$this->error = 'ErrorSetupNotComplete';
return -1;
}
// Clear fields
$this->user_author = $user->id;
$this->user_valid = '';
$this->date = $now;
$this->datep = $now;
// deprecated
$this->fin_validite = $this->date + $this->duree_validite * 24 * 3600;
if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) {
$this->ref_client = '';
}
// Set ref
require_once DOL_DOCUMENT_ROOT . "/core/modules/propale/" . $conf->global->PROPALE_ADDON . '.php';
$obj = $conf->global->PROPALE_ADDON;
$modPropale = new $obj();
$this->ref = $modPropale->getNextValue($objsoc, $this);
// Create clone
$result = $this->create($user);
if ($result < 0) {
$error++;
} else {
// copy internal contacts
if ($this->copy_linked_contact($objFrom, 'internal') < 0) {
$error++;
} elseif ($objFrom->socid == $this->socid) {
if ($this->copy_linked_contact($objFrom, 'external') < 0) {
$error++;
}
}
}
if (!$error) {
// Hook of thirdparty module
if (is_object($hookmanager)) {
$parameters = array('objFrom' => $objFrom);
$action = '';
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action);
// Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
$error++;
}
}
// Call trigger
$result = $this->call_trigger('PROPAL_CLONE', $user);
if ($result < 0) {
$error++;
}
// End call triggers
}
unset($this->context['createfromclone']);
// End
if (!$error) {
$this->db->commit();
return $this->id;
} else {
$this->db->rollback();
return -1;
}
}
示例8: __clone
/**
* Overwrite magic function to solve problem of cloning object that are kept as references
*
* @return void
*/
function __clone()
{
// Force a copy of this->lines, otherwise it will point to same object.
if (isset($this->lines) && is_array($this->lines)) {
$nboflines = count($this->lines);
for ($i = 0; $i < $nboflines; $i++) {
$this->lines[$i] = dol_clone($this->lines[$i]);
}
}
}
示例9: createFromClone
/**
* Load an object from its id and create a new one in database
*
* @return int New id of clone
*/
function createFromClone()
{
global $conf, $user, $langs, $hookmanager;
$error = 0;
$this->db->begin();
// Load source object
$objFrom = dol_clone($this);
$this->id = 0;
$this->statut = 0;
// Clear fields
$this->user_author_id = $user->id;
$this->user_valid = '';
$this->date_creation = '';
$this->date_validation = '';
$this->ref_supplier = '';
// Create clone
$result = $this->create($user);
if ($result < 0) {
$error++;
}
if (!$error) {
// Hook of thirdparty module
if (is_object($hookmanager)) {
$parameters = array('objFrom' => $objFrom);
$action = '';
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action);
// Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
$error++;
}
}
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface = new Interfaces($this->db);
$result = $interface->run_triggers('ORDER_SUPPLIER_CLONE', $this, $user, $langs, $conf);
if ($result < 0) {
$error++;
$this->errors = $interface->errors;
}
// Fin appel triggers
}
// End
if (!$error) {
$this->db->commit();
return $this->id;
} else {
$this->db->rollback();
return -1;
}
}
示例10: createFromClone
/**
* Load an object from its id and create a new one in database
*
* @param int $socid Id of thirdparty
* @return int New id of clone
*/
function createFromClone($socid = 0)
{
global $conf, $user, $langs, $hookmanager;
$error = 0;
$this->db->begin();
// get extrafields so they will be clone
foreach ($this->lines as $line) {
$line->fetch_optionals($line->rowid);
}
// Load source object
$objFrom = dol_clone($this);
// Change socid if needed
if (!empty($socid) && $socid != $this->socid) {
$objsoc = new Societe($this->db);
if ($objsoc->fetch($socid) > 0) {
$this->socid = $objsoc->id;
$this->cond_reglement_id = !empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0;
$this->mode_reglement_id = !empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0;
$this->fk_project = '';
$this->fk_delivery_address = '';
}
// TODO Change product price if multi-prices
}
$this->id = 0;
$this->statut = 0;
// Clear fields
$this->user_author_id = $user->id;
$this->user_valid = '';
$this->date_creation = '';
$this->date_validation = '';
$this->ref_client = '';
// Set ref
require_once DOL_DOCUMENT_ROOT . "/core/modules/commande/" . $conf->global->COMMANDE_ADDON . '.php';
$obj = $conf->global->COMMANDE_ADDON;
$modCommande = new $obj();
$this->ref = $modCommande->getNextValue($objsoc, $this);
// Create clone
$result = $this->create($user);
if ($result < 0) {
$error++;
}
if (!$error) {
// Hook of thirdparty module
if (is_object($hookmanager)) {
$parameters = array('objFrom' => $objFrom);
$action = '';
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action);
// Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
$error++;
}
}
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface = new Interfaces($this->db);
$result = $interface->run_triggers('ORDER_CLONE', $this, $user, $langs, $conf);
if ($result < 0) {
$error++;
$this->errors = $interface->errors;
}
// Fin appel triggers
}
// End
if (!$error) {
$this->db->commit();
return $this->id;
} else {
$this->db->rollback();
return -1;
}
}
示例11: doActions
/**
* 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 = dol_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';
}
}
}
}
示例12: testContactUpdate
/**
* testContactUpdate
*
* @param Contact $localobject Contact
* @return int
*
* @depends testContactFetch
* The depends says test is run only if previous is ok
*/
public function testContactUpdate($localobject)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject->oldcopy=dol_clone($localobject);
$localobject->note='New note after update';
//$localobject->note_public='New note public after update';
$localobject->lastname='New name';
$localobject->firstname='New firstname';
$localobject->address='New address';
$localobject->zip='New zip';
$localobject->town='New town';
$localobject->country_id=2;
//$localobject->status=0;
$localobject->phone_pro='New tel pro';
$localobject->phone_perso='New tel perso';
$localobject->phone_mobile='New tel mobile';
$localobject->fax='New fax';
$localobject->email='newemail@newemail.com';
$localobject->jabberid='New im id';
$localobject->default_lang='es_ES';
$result=$localobject->update($localobject->id,$user);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0, 'Contact::update error');
$result=$localobject->update_note($localobject->note);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0, 'Contact::update_note error');
//$result=$localobject->update_note_public($localobject->note_public);
//print __METHOD__." id=".$localobject->id." result=".$result."\n";
//$this->assertLessThan($result, 0);
$newobject=new Contact($this->savdb);
$result=$newobject->fetch($localobject->id);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0, 'Contact::fetch error');
print __METHOD__." old=".$localobject->note." new=".$newobject->note."\n";
$this->assertEquals($localobject->note, $newobject->note);
//print __METHOD__." old=".$localobject->note_public." new=".$newobject->note_public."\n";
//$this->assertEquals($localobject->note_public, $newobject->note_public);
print __METHOD__." old=".$localobject->lastname." new=".$newobject->lastname."\n";
$this->assertEquals($localobject->lastname, $newobject->lastname);
print __METHOD__." old=".$localobject->firstname." new=".$newobject->firstname."\n";
$this->assertEquals($localobject->firstname, $newobject->firstname);
print __METHOD__." old=".$localobject->address." new=".$newobject->address."\n";
$this->assertEquals($localobject->address, $newobject->address);
print __METHOD__." old=".$localobject->zip." new=".$newobject->zip."\n";
$this->assertEquals($localobject->zip, $newobject->zip);
print __METHOD__." old=".$localobject->town." new=".$newobject->town."\n";
$this->assertEquals($localobject->town, $newobject->town);
print __METHOD__." old=".$localobject->country_id." new=".$newobject->country_id."\n";
$this->assertEquals($localobject->country_id, $newobject->country_id);
print __METHOD__." old=BE new=".$newobject->country_code."\n";
$this->assertEquals('BE', $newobject->country_code);
//print __METHOD__." old=".$localobject->status." new=".$newobject->status."\n";
//$this->assertEquals($localobject->status, $newobject->status);
print __METHOD__." old=".$localobject->phone_pro." new=".$newobject->phone_pro."\n";
$this->assertEquals($localobject->phone_pro, $newobject->phone_pro);
print __METHOD__." old=".$localobject->phone_pro." new=".$newobject->phone_pro."\n";
$this->assertEquals($localobject->phone_perso, $newobject->phone_perso);
print __METHOD__." old=".$localobject->phone_mobile." new=".$newobject->phone_mobile."\n";
$this->assertEquals($localobject->phone_mobile, $newobject->phone_mobile);
print __METHOD__." old=".$localobject->fax." new=".$newobject->fax."\n";
$this->assertEquals($localobject->fax, $newobject->fax);
print __METHOD__." old=".$localobject->email." new=".$newobject->email."\n";
$this->assertEquals($localobject->email, $newobject->email);
print __METHOD__." old=".$localobject->jabberid." new=".$newobject->jabberid."\n";
$this->assertEquals($localobject->jabberid, $newobject->jabberid);
print __METHOD__." old=".$localobject->default_lang." new=".$newobject->default_lang."\n";
$this->assertEquals($localobject->default_lang, $newobject->default_lang);
return $localobject;
}
示例13: createFromClone
/**
* Load an object from its id and create a new one in database
*
* @param int $socid Id of thirdparty
* @return int New id of clone
*/
function createFromClone($socid = 0)
{
global $conf, $user, $langs, $hookmanager;
$error = 0;
$this->context['createfromclone'] = 'createfromclone';
$this->db->begin();
// get extrafields so they will be clone
foreach ($this->lines as $line) {
$line->fetch_optionals($line->rowid);
}
// Load source object
$objFrom = dol_clone($this);
// Change socid if needed
if (!empty($socid) && $socid != $this->socid) {
$objsoc = new Societe($this->db);
if ($objsoc->fetch($socid) > 0) {
$this->socid = $objsoc->id;
$this->cond_reglement_id = !empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0;
$this->mode_reglement_id = !empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0;
$this->fk_project = '';
$this->fk_delivery_address = '';
}
// TODO Change product price if multi-prices
}
$this->id = 0;
$this->statut = 0;
// Clear fields
$this->date = dol_now();
// Date of invoice is set to current date when cloning. // TODO Best is to ask date into confirm box
$this->user_author = $user->id;
$this->user_valid = '';
$this->fk_facture_source = 0;
$this->date_creation = '';
$this->date_validation = '';
$this->ref_client = '';
$this->close_code = '';
$this->close_note = '';
$this->products = $this->lines;
// Tant que products encore utilise
// Loop on each line of new invoice
foreach ($this->lines as $i => $line) {
if (($this->lines[$i]->info_bits & 0x2) == 0x2) {
unset($this->lines[$i]);
unset($this->products[$i]);
// Tant que products encore utilise
}
}
// Create clone
$result = $this->create($user);
if ($result < 0) {
$error++;
} else {
// copy internal contacts
if ($this->copy_linked_contact($objFrom, 'internal') < 0) {
$error++;
} elseif ($objFrom->socid == $this->socid) {
if ($this->copy_linked_contact($objFrom, 'external') < 0) {
$error++;
}
}
}
if (!$error) {
// Hook of thirdparty module
if (is_object($hookmanager)) {
$parameters = array('objFrom' => $objFrom);
$action = '';
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action);
// Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
$error++;
}
}
// Call trigger
$result = $this->call_trigger('BILL_CLONE', $user);
if ($result < 0) {
$error++;
}
// End call triggers
}
unset($this->context['createfromclone']);
// End
if (!$error) {
$this->db->commit();
return $this->id;
} else {
$this->db->rollback();
return -1;
}
}
示例14: isset
if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer)
{
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$datenaiss='';
if (isset($_POST["naissday"]) && $_POST["naissday"]
&& isset($_POST["naissmonth"]) && $_POST["naissmonth"]
&& isset($_POST["naissyear"]) && $_POST["naissyear"])
{
$datenaiss=dol_mktime(12, 0, 0, $_POST["naissmonth"], $_POST["naissday"], $_POST["naissyear"]);
}
// Create new object
if ($result > 0)
{
$adh->oldcopy=dol_clone($adh);
// Change values
$adh->civilite_id = trim($_POST["civilite_id"]);
$adh->prenom = trim($_POST["prenom"]);
$adh->nom = trim($_POST["nom"]);
$adh->login = trim($_POST["login"]);
$adh->pass = trim($_POST["pass"]);
$adh->societe = trim($_POST["societe"]);
$adh->adresse = trim($_POST["address"]); // deprecated
$adh->address = trim($_POST["address"]);
$adh->cp = trim($_POST["zipcode"]); // deprecated
$adh->zip = trim($_POST["zipcode"]);
$adh->ville = trim($_POST["town"]); // deprecated
$adh->town = trim($_POST["town"]);
示例15: GETPOST
print '<tr>';
print '<td class="fieldrequired">' . $langs->trans("QtyMin") . '</td>';
print '<td>';
$quantity = GETPOST('qty') ? GETPOST('qty') : "1";
if ($rowid) {
print '<input type="hidden" name="qty" value="' . $product->fourn_qty . '">';
print $product->fourn_qty;
} else {
print '<input class="flat" name="qty" size="5" value="' . $quantity . '">';
}
print '</td></tr>';
// Vat rate
$default_vat = '';
// We don't have supplier, so we try to guess.
// For this we build a fictive supplier with same properties than user but using vat)
$mysoc2 = dol_clone($mysoc);
$mysoc2->name = 'Fictive seller with same country';
$mysoc2->tva_assuj = 1;
$default_vat = get_default_tva($mysoc2, $mysoc, $product->id, 0);
print '<tr><td class="fieldrequired">' . $langs->trans("VATRateForSupplierProduct") . '</td>';
print '<td>';
//print $form->load_tva('tva_tx',$product->tva_tx,$supplier,$mysoc); // Do not use list here as it may be any vat rates for any country
if (!empty($socid)) {
$default_vat = get_default_tva($supplier, $mysoc, $product->id);
if (empty($default_vat)) {
$default_vat = $product->tva_tx;
}
}
print '<input type="text" class="flat" size="5" name="tva_tx" value="' . (GETPOST("tva_tx") ? vatrate(GETPOST("tva_tx")) : ($default_vat != '' ? vatrate($default_vat) : '')) . '">';
print '</td></tr>';
if (!empty($conf->dynamicprices->enabled)) {