protected function handleRequest(array $request) { $projectId = $request[self::FIELD_PROJECT_ID]; $title = $request[self::FIELD_TITLE]; $description = $request[self::FIELD_DESCRIPTION]; Project::update($projectId, $title, $description); }
public static function update($id) { self::check_logged_in(); $params = $_POST; $attributes = array('id' => $id, 'name' => $params['name']); $project = new Project($attributes); $errors = $project->validateProject(); if (count($errors) == 0) { $project->update(); Redirect::to('/project', array('message' => 'Project edited successfully')); } else { View::make('project/edit.html', array('errors' => $errors, 'attributes' => $attributes)); } }
/** * Update the specified resource in storage. * * @param Project $project * @return Response */ public function update($project) { $input = Input::all(); $project->title = $input['title']; $project->contact_firstname = $input['contact_firstname']; $project->contact_lastname = $input['contact_lastname']; $project->contact_email = $input['contact_email']; $project->contact_phone_number = $input['contact_phone_number']; $project->contact_phone_number_ext = $input['contact_phone_number_ext']; $project->description = $input['description']; $project->location = $input['location']; $project->expected_time = $input['expected_time']; $project->motivation = $input['motivation']; $project->resources = $input['resources']; $project->constraints = $input['constraints']; $project->state = $input['state']; $input['tags'] = isset($input['tags']) ? $input['tags'] : array(); //verify that there are some goals and tags in the $input $input['goals'] = isset($input['goals']) ? $input['goals'] : array(); if ($project->update()) { // Delete project goals and then re-create them $project->goals()->delete(); $loop_index = 0; foreach ($input['goals'] as $goal) { //Ignore empty goals if ($goal == '') { $loop_index++; continue; } else { $goalObj = new Goal(); $goalObj->goal = $goal; // The completed variable posted is an array containing the indexes for the goals that are marked as complete // This will swap the array's index with the value (ie. [0] => a, [1] => b will become [a] => 0, [b] => 1) // This then allows us to see if the current loop index has a goal that is complete without needing to use a for loop $completed = isset($input['completed']) ? array_flip($input['completed']) : array(); if (isset($completed[$loop_index])) { $goalObj->complete = 1; } else { $goalObj->complete = 0; } $project->goals()->save($goalObj); } $loop_index++; } // Delete project tags and then re-create them $project->tags()->detach(); foreach ($input['tags'] as $tag) { if ($tag == '') { continue; } else { $tagObj = Tag::find($tag); $project->tags()->attach($tagObj); } } return Redirect::to('/admin/project/' . $project->id . '/edit')->with('info', 'The project has been updated.'); } else { return Redirect::to('/admin/project/' . $project->id . '/edit')->withErrors($project->errors()); } }
include_once APP_INC_PATH . "class.status.php"; include_once APP_INC_PATH . "class.workflow.php"; include_once APP_INC_PATH . "db_access.php"; $tpl = new Template_API(); $tpl->setTemplate("manage/index.tpl.html"); Auth::checkAuthentication(APP_COOKIE); $tpl->assign("type", "projects"); $role_id = Auth::getCurrentRole(); if ($role_id == User::getRoleID('administrator') || $role_id == User::getRoleID('manager')) { if ($role_id == User::getRoleID('administrator')) { $tpl->assign("show_setup_links", true); } if (@$HTTP_POST_VARS["cat"] == "new") { $tpl->assign("result", Project::insert()); } elseif (@$HTTP_POST_VARS["cat"] == "update") { $tpl->assign("result", Project::update()); } elseif (@$HTTP_POST_VARS["cat"] == "delete") { Project::remove(); } $tpl->assign("active_projects", Project::getAssocList(Auth::getUserID(), true)); if (@$HTTP_GET_VARS["cat"] == "edit") { $tpl->assign("info", Project::getDetails($HTTP_GET_VARS["id"])); } $tpl->assign("list", Project::getList()); $tpl->assign("user_options", User::getActiveAssocList(false, NULL, false, false, true)); $tpl->assign("status_options", Status::getAssocList()); $tpl->assign("customer_backends", Customer::getBackendList()); $tpl->assign("workflow_backends", Workflow::getBackendList()); } else { $tpl->assign("show_not_allowed_msg", true); }
} else { if (isset($_POST["restore"])) { $project->check($_POST["id"], DELETE); $project->restore($_POST); Event::log($_POST["id"], "project", 4, "maintain", sprintf(__('%s restores an item'), $_SESSION["glpiname"])); $project->redirectToList(); } else { if (isset($_POST["purge"])) { $project->check($_POST["id"], PURGE); $project->delete($_POST, 1); Event::log($_POST["id"], "project", 4, "maintain", sprintf(__('%s purges an item'), $_SESSION["glpiname"])); $project->redirectToList(); } else { if (isset($_POST["update"])) { $project->check($_POST["id"], UPDATE); $project->update($_POST); Event::log($_POST["id"], "project", 4, "maintain", sprintf(__('%s updates an item'), $_SESSION["glpiname"])); Html::back(); } else { Html::header(Project::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "tools", "project"); if (isset($_GET['showglobalgantt']) && $_GET['showglobalgantt']) { $project->showGantt(-1); } else { $project->display($_GET); } Html::footer(); } } } } }
function doEdit() { if (isset($_POST['submit'])) { $PROJECTID = $_POST['projectid']; $PROJECTNUMBER = $_POST['projectnumber']; $NAME = $_POST['projectname']; $CLIENTNAME = $_POST['clientname']; $CLIENTCONTACTS = $_POST['']; $PROJECTTYPEID = $_POST['projecttype']; $STARTDATE = $_POST['startdate']; $ENDDATE = $_POST['enddate']; $DAYS = $_POST['days']; $AMOUNT = $_POST['amount']; $PROJECTSTATUS = $_POST['status']; $SECTOR = $_POST['sector']; $BUREAU = $_POST['bureau']; $SCHOOL = $_POST['school']; $project = new Project(); $project->project_id = $PROJECTID; $project->project_number = $PROJECTNUMBER; $project->project_name = $NAME; $project->client_contacts = $CLIENTCONTACTS; $project->project_type_id = $PROJECTTYPEID; $project->client_name = $CLIENTNAME; $project->start_date = $STARTDATE; $project->end_date = $ENDDATE; $project->days = $DAYS; $project->total_amount = $AMOUNT; $project->project_status = $PROJECTSTATUS; $project->project_bureau_id = $BUREAU; $project->project_school_id = $SCHOOL; $project->project_sector_id = $SECTOR; } if ($PROJECTID == "") { message('ID Number is required!', "error"); redirect('index.php?view=edit&id=' . $PROJECTID); } elseif ($NAME == "") { message('Project Name is required!', "error"); redirect('index.php?view=edit&id=' . $PROJECTID); } elseif ($PROJECTNUMBER == "") { message('Project Number is required!', "error"); redirect('index.php?view=edit&id=' . $PROJECTID); } elseif ($CLIENTCONTACTS == "") { message('Client Contacts is required!', "error"); redirect('index.php?view=edit&id=' . $PROJECTID); } elseif ($PROJECTTYPEID == "") { message('Project type is required!', "error"); redirect('index.php?view=edit&id=' . $PROJECTID); } elseif ($CLIENTNAME == "") { message('Client is required!', "error"); redirect('index.php?view=edit&id=' . $PROJECTID); } elseif ($STARTDATE == "") { message('Start is required!', "error"); redirect('index.php?view=edit&id=' . $PROJECTID); } elseif ($ENDDATE == "") { message('End is required!', "error"); redirect('index.php?view=edit&id=' . $PROJECTID); } elseif ($AMOUNT == "") { message('Amount is required!', "error"); redirect('index.php?view=edit&id=' . $PROJECTID); } elseif ($DAYS == "") { message('Days is required!', "error"); redirect('index.php?view=edit&id=' . $PROJECTID); } elseif ($PROJECTSTATUS == "") { message('Project Status is required!', "error"); redirect('index.php?view=edit&id=' . $PROJECTID); } elseif ($BUREAU == "") { message('Bureau is required!', "error"); redirect('index.php?view=edit&id=' . $PROJECTID); } elseif ($SECTOR == "") { message('Sector is required!', "error"); redirect('index.php?view=edit&id=' . $PROJECTID); } elseif ($SCHOOL == "") { message('School is required!', "error"); redirect('index.php?view=edit&id=' . $PROJECTID); } else { $project->update($_GET['id']); message('Project information updated successfully!', "info"); redirect('index.php'); } }
* For the full copyright and license information, * please see the COPYING and AUTHORS files * that were distributed with this source code. */ require_once __DIR__ . '/../../init.php'; $tpl = new Template_Helper(); $tpl->setTemplate('manage/projects.tpl.html'); Auth::checkAuthentication(); $role_id = Auth::getCurrentRole(); if ($role_id < User::ROLE_MANAGER) { Misc::setMessage(ev_gettext('Sorry, you are not allowed to access this page.'), Misc::MSG_ERROR); $tpl->displayTemplate(); exit; } if (@$_POST['cat'] == 'new') { Misc::mapMessages(Project::insert(), array(1 => array(ev_gettext('Thank you, the project was added successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to add the new project.'), Misc::MSG_ERROR), -2 => array(ev_gettext('Please enter the title for this new project.'), Misc::MSG_ERROR))); } elseif (@$_POST['cat'] == 'update') { Misc::mapMessages(Project::update(), array(1 => array(ev_gettext('Thank you, the project was updated successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to update the project information.'), Misc::MSG_ERROR), -2 => array(ev_gettext('Please enter the title for this project.'), Misc::MSG_ERROR))); } elseif (@$_POST['cat'] == 'delete') { Misc::mapMessages(Project::remove(), array(1 => array(ev_gettext('Thank you, the project was deleted successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to delete the project.'), Misc::MSG_ERROR))); } $tpl->assign('active_projects', Project::getAssocList(Auth::getUserID(), true)); if (@$_GET['cat'] == 'edit') { $tpl->assign('info', Project::getDetails($_GET['id'])); } $tpl->assign('list', Project::getList()); $tpl->assign('user_options', User::getActiveAssocList()); $tpl->assign('status_options', Status::getAssocList()); $tpl->assign('customer_backends', CRM::getBackendList()); $tpl->assign('workflow_backends', Workflow::getBackendList()); $tpl->displayTemplate();
/** * Check if a file is specified for loading. * * Also save changes to it if posted. * * @since 1.2.0 Added custom save destination; under PME content directory. * @since 1.1.0 Improved sprintf calls for localization purposes. * @since 1.0.0 */ public static function process_request() { // Skip if no file is specified if (!isset($_REQUEST['pofile'])) { return; } // If file was specified via $_POST, check for manage nonce action if (isset($_POST['pofile']) && (!isset($_POST['_pomoeditor_nonce']) || !wp_verify_nonce($_POST['_pomoeditor_nonce'], 'pomoeditor-manage-' . md5($_POST['pofile'])))) { wp_die(__('Cheatin’ uh?'), 403); } // Create the source/destination paths $file = $_REQUEST['pofile']; $source = realpath(WP_CONTENT_DIR . '/' . $file); // Check that the source exists if (strtolower(pathinfo($source, PATHINFO_EXTENSION)) != 'po') { /* Translators: %s = full path to file */ wp_die(sprintf(__('The requested file is not supported: %s', 'pomo-editor'), $source), 400); } elseif (!file_exists($source)) { /* Translators: %s = full path to file */ wp_die(sprintf(__('The requested file cannot be found: %s', 'pomo-editor'), $source), 404); } elseif (!is_path_permitted($source)) { /* Translators: %s = full path to file */ wp_die(sprintf(__('The requested file is not within one of the permitted paths: %s', 'pomo-editor'), $source), 403); } elseif (!is_writable($source)) { /* Translators: %s = full path to file */ wp_die(sprintf(__('The requested file is not writable: %s', 'pomo-editor'), $source), 403); } elseif (isset($_POST['podata'])) { // Load $project = new Project($source); $project->load(); // Update $project->update(json_decode(stripslashes($_POST['podata']), true), true); // Create destination from $source $destination = $source; // If the destination isn't already in the PME content directory, prepend it if (strpos($file, 'pomo-editor/') !== 0) { $destination = str_replace(WP_CONTENT_DIR, PME_CONTENT_DIR, $source); $file = 'pomo-editor/' . $file; } // Save $project->export($destination); // Redirect wp_redirect(admin_url("tools.php?page=pomo-editor&pofile={$file}&changes-saved=true")); exit; } }
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")).'</div>'; } if (! $error) { $project = new Project($db); $project->fetch($_POST["id"]); $project->ref = $_POST["ref"]; $project->title = $_POST["title"]; $project->socid = $_POST["socid"]; $project->description = $_POST["description"]; $project->public = $_POST["public"]; $project->date_start = empty($_POST["project"])?'':dol_mktime(12,0,0,$_POST['projectmonth'],$_POST['projectday'],$_POST['projectyear']); $project->date_end = empty($_POST["projectend"])?'':dol_mktime(12,0,0,$_POST['projectendmonth'],$_POST['projectendday'],$_POST['projectendyear']); $result=$project->update($user); $_GET["id"]=$project->id; // On retourne sur la fiche projet } else { $_GET["id"]=$_POST["id"]; $_GET['action']='edit'; } } // Build doc if (GETPOST('action') == 'builddoc' && $user->rights->projet->creer) { $project = new Project($db); $project->fetch($_GET['id']);
public function verify() { $res = array(); $res['Success'] = false; if ($this->Action > 1) { //不通过,删除操作 $hours = new Hours(); $hours->Id = $this->Id; $result = $hours->delete(); if ($result > 0) { $res['Success'] = true; $res['Message'] = "删除成功"; } else { $res['Message'] = "删除失败"; } } else { //通过,计入项目总工时 $hours = new Hours(); $hours->Id = $this->Id; $hours->Ratio = $this->Ratio; $hours->Hours2 = $this->Hours2; $result = $hours->update(); if ($result > 0) { //审核成功 $project = new Project(); $project->setValue($this->ProjectId); $project->Hours = $project->Hours + $hours->Hours2; $project->update(); $res['Success'] = true; $res['Message'] = "审核通过"; $res['NewId'] = $this->Id; } else { $res['Success'] = false; $res['Message'] = "审核失败"; } } echo json_encode($res); exit; }
function _reset_date_task(&$db, $id_project, $velocity) { global $user; if ($velocity == 0) { return false; } $project = new Project($db); $project->fetch($id_project); $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "projet_task\n\tWHERE fk_projet=" . $id_project . " AND progress<100\n\tORDER BY rang"; $res = $db->query($sql); $current_time = time(); while ($obj = $db->fetch_object($res)) { $task = new Task($db); $task->fetch($obj->rowid); $task->fetch_optionals($obj->rowid); // Otherwise they are scratched in the update if ($task->progress == 0) { $task->date_start = $current_time; } $task->date_end = _get_delivery_date_with_velocity($db, $task, $velocity, $current_time); $current_time = $task->date_end; $task->update($user); } $project->date_end = $current_time; $project->update($user); }
public function effect() { $res = array(); $project = new Project(); $project->setValue($this->ProjectId); if ($project->Url != $this->Url) { //生产二维码 $project->Url = $this->Url; $destination_folder = date("Y") . "/"; //上传文件路径 $filenamenew = uniqid(date("Ymd"), true) . '.png'; $destination = $destination_folder . $filenamenew; $stor = new Storage(); if (!empty($project->QrCode)) { $stor->delete(FILE_DOMAIN, $project->QrCode); } $project->QrCode = $destination; $url = urlencode($project->Url); $qrcode = URL_WEBSITE . '/basic/handles/qrcode.php?Url=' . $url; $f = new Fetchurl(); $imageData = $f->fetch($qrcode); $stor->write(FILE_DOMAIN, $project->QrCode, $imageData); } $project->Pv = $this->Pv; $project->Uv = $this->Uv; $project->Fans = $this->Fans; $project->Summary = $this->Summary; $project->Laud = $this->Laud; //print_r($project); $result = $project->update(); if ($result > 0) { $res['Success'] = true; $res['Message'] = "更新成功"; //发送部门老大emailt通知 } else { $res['Success'] = false; $res['Message'] = "没有更新任何数据"; } echo json_encode($res); exit; }
public function updateSettings(Project $project) { $project->update(Input::only('closed_statuses', 'workboard_mode')); Flash::success('The project settings have been updated'); return Redirect::back(); }
/** * Function called when a Dolibarrr business event is done. * All functions "run_trigger" are triggered if file * is inside directory core/triggers * * @param string $action Event action code * @param Object $object Object * @param User $user Object user * @param Translate $langs Object langs * @param conf $conf Object conf * @return int <0 if KO, 0 if no triggered ran, >0 if OK */ public function run_trigger($action, &$object, &$user, &$langs, &$conf) { global $user, $db; dol_include_once('/grapefruit/class/grapefruit.class.php'); $langs->load('grapefruit@grapefruit'); // Put here code you want to execute when a Dolibarr business events occurs. // Data and type of action are stored into $object and $action // Users if ($action == 'ACTION_CREATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); if (!empty($conf->global->GRAPEFRUIT_CAN_ASSOCIATE_TASK_TO_ACTIONCOMM)) { // il faut récup le fk_task et fait un lien avec "related" $fk_task = GETPOST('fk_task', 'int'); if ($fk_task > 0) { $r = $object->add_object_linked('task', $fk_task); } } } elseif ($action === 'LINECONTRACT_INSERT') { TGrappeFruit::checkContractFourn($object); } elseif ($action === 'ORDER_VALIDATE') { TGrappeFruit::createBillOnOrderValidate($object); if (!empty($conf->global->GRAPEFRUIT_ALLOW_CREATE_ORDER_AND_BILL_ON_UNSIGNED_PROPAL)) { TGrappeFruit::clotureOriginPropal($object); } dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); } elseif ($action === 'BILL_CREATE') { if (!empty($conf->global->GRAPEFRUIT_LINK_INVOICE_TO_SESSION_IF_PROPAL_IS) && $conf->agefodd->enabled) { if ($object->origin == 'propal' && $object->origin_id > 0) { $db =& $this->db; dol_include_once('/agefodd.git/class/agefodd_session_element.class.php'); $res = $db->query("SELECT fk_session_agefodd FROM " . MAIN_DB_PREFIX . "agefodd_session_element WHERE fk_element=" . $object->origin_id . " AND element_type='propal'"); $obj = $db->fetch_object($res); if ($obj->fk_session_agefodd > 0) { $agf = new Agefodd_session_element($db); $agf->fk_element = $object->id; $agf->fk_session_agefodd = $obj->fk_session_agefodd; $agf->fk_soc = empty($object->socid) ? $object->fk_soc : $object->socid; $agf->element_type = 'invoice'; $result = $agf->create($user); } } } } elseif ($action === 'BILL_PAYED') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); TGrappeFruit::createShippingFromOrderOnBillPayed($object); if (!empty($conf->global->GRAPEFRUIT_SEND_BILL_BY_MAIL_ON_BILLED)) { if (empty($conf->global->GRAPEFRUIT_SEND_BILL_BY_MAIL_ON_VALIDATE_ORDER)) { TGrappeFruit::sendBillByMail($object); } else { if (empty($object->linked_objects)) { $object->fetchObjectLinked(null, null, $object->id, 'facture'); } if (empty($object->linkedObjects['commande'])) { return false; } foreach ($object->linkedObjects['commande'] as &$commande) { TGrappeFruit::sendOrderByMail($commande); } } } } elseif ($action === 'BILL_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); if (!empty($conf->global->GRAPEFRUIT_SEND_BILL_BY_MAIL_ON_VALIDATE)) { if (empty($conf->global->GRAPEFRUIT_SEND_BILL_BY_MAIL_ON_VALIDATE_ORDER)) { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $model = $object->modelpdf; $object->ref = $object->newref; $object->generateDocument($model, $outputlangs); //if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } TGrappeFruit::sendBillByMail($object); } else { if (empty($object->linked_objects)) { $object->fetchObjectLinked(null, null, $object->id, 'facture'); } if (empty($object->linkedObjects['commande'])) { return false; } foreach ($object->linkedObjects['commande'] as &$commande) { TGrappeFruit::sendOrderByMail($commande); } } } if (!empty($conf->propal->enabled) && !empty($conf->global->GRAPEFRUIT_INVOICE_CLASSIFY_BILLED_PROPAL)) { $object->fetchObjectLinked('', 'propal', $object->id, $object->element); if (!empty($object->linkedObjects)) { foreach ($object->linkedObjects['propal'] as $element) { $ret = $element->classifyBilled($user); } } } if (!empty($conf->global->GRAPEFRUIT_SET_ORDER_BILLED_IF_SAME_MONTANT)) { TGrappeFruit::setOrderBilledIfSameMontant($object); } } elseif ($action === 'PROJECT_CREATE') { if (!TGrappeFruit::checkNoDuplicateRef($object)) { return -1; } if (!TGrappeFruit::checkBudgetNotEmpty($object)) { return -1; } if (!TGrappeFruit::checkDateEndNotEmpty($object)) { return -1; } TGrappeFruit::createTasks($object); dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); } elseif ($action === 'PROJECT_MODIFY') { if (!TGrappeFruit::checkBudgetNotEmpty($object)) { return -1; } if (!TGrappeFruit::checkDateEndNotEmpty($object)) { return -1; } dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); } elseif ($action === 'PROPAL_CREATE') { $db = $this->db; if (!empty($conf->global->GRAPEFRUIT_LINK_PROPAL_2_PROJECT)) { dol_include_once('/projet/class/project.class.php'); $projId = 0; $sql = "SELECT p.rowid AS rowid"; $sql .= " FROM " . MAIN_DB_PREFIX . "projet as p"; $sql .= " WHERE p.fk_soc = " . $object->socid; $sql .= " ORDER BY p.dateo DESC"; $sql .= " LIMIT 1"; $resql = $db->query($sql); if ($resql) { while ($line = $db->fetch_object($resql)) { $projId = $line->rowid; } } //On fetch le projet $projet = new Project($db); $projet->fetch($projId); //TODO Ajouter la propale au projet //var_dump($object->table_element, $object->id);exit; $projet->update_element($object->table_element, $object->id); } dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); } elseif ($action == 'ORDER_SUPPLIER_DISPATCH') { // classify supplier order delivery status dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); if (!empty($conf->commande->enabled) && !empty($conf->fournisseur->enabled) && !empty($conf->global->GRAPEFRUIT_SUPPLIER_ORDER_CLASSIFY_RECEIPT_ORDER)) { dol_include_once('/grapefruit/class/supplier.commande.dispatch.class.php'); $qtydelivered = array(); $qtywished = array(); $supplierorderdispatch = new CommandeFournisseurDispatchATM($this->db); $filter = array('t.fk_commande' => $object->id); if (!empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) { $filter['t.status'] = 1; } $ret = $supplierorderdispatch->fetchAll('', '', 0, 0, $filter); if ($ret < 0) { $this->error = $supplierorderdispatch->error; $this->errors = $supplierorderdispatch->errors; return $ret; } else { if (is_array($supplierorderdispatch->lines) && count($supplierorderdispatch->lines) > 0) { //Build array with quantity deliverd by product foreach ($supplierorderdispatch->lines as $line) { if (!empty($line->fk_product)) { $qtydelivered[$line->fk_product] += $line->qty; } } foreach ($object->lines as $line) { if (!empty($line->fk_product)) { $qtywished[$line->fk_product] += $line->qty; } } //Compare array $diff_array = array_diff_assoc($qtydelivered, $qtywished); $diff_array = array_merge($diff_array, array_diff_assoc($qtywished, $qtydelivered)); // dans les 2 sens parce que la fonction teste pas dans les 2 sens (array_diff_assoc($a, $b) ne donne pas forcement le meme res que array_diff_assoc($b, $a)) if (count($diff_array) == 0) { //No diff => mean everythings is received $ret = $object->setStatus($user, 5); if ($ret < 0) { $this->error = $object->error; $this->errors = $object->errors; return $ret; } } else { //Diff => received partially $ret = $object->setStatus($user, 4); if ($ret < 0) { $this->error = $object->error; $this->errors = $object->errors; return $ret; } } } } } } elseif ($action === 'SHIPPING_VALIDATE') { if (!empty($conf->global->GRAPEFRUIT_SET_ORDER_SHIPPED_IF_ALL_PRODUCT_SHIPPED)) { TGrappeFruit::setOrderShippedIfAllProductShipped($object); } } elseif ($action === 'ORDER_SUPPLIER_VALIDATE') { if ($conf->global->GRAPEFRUIT_AUTO_ORDER_ON_SUPPLIERORDER_VALIDATION_WITH_METHOD > 0) { TGrappeFruit::orderSupplierOrder($object, $conf->global->GRAPEFRUIT_AUTO_ORDER_ON_SUPPLIERORDER_VALIDATION_WITH_METHOD); } } //Passage d'une opportunité au statut gagné dès son affectation à un devis ou une commande if ($action === 'PROPAL_CREATE' || $action === 'ORDER_CREATE') { if ($conf->global->GRAPEFRUIT_PROJECT_AUTO_WIN) { if ($object->fk_project) { $projet = new Project($db); $projet->fetch($object->fk_project); if ($projet->opp_status != 6) { $projet->opp_status = 6; $projet->update($user); } } } } /* if ($action === 'USER_LOGIN') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } else if($action ==='LINECONTRACT_INSERT') { TGrappeFruit::checkContractFourn($object); } elseif ($action === 'USER_UPDATE_SESSION') { // Warning: To increase performances, this action is triggered only if // constant MAIN_ACTIVATE_UPDATESESSIONTRIGGER is set to 1. dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'USER_CREATE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'USER_CREATE_FROM_CONTACT') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'USER_MODIFY') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'USER_NEW_PASSWORD') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'USER_ENABLEDISABLE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'USER_DELETE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'USER_LOGOUT') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'USER_SETINGROUP') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'USER_REMOVEFROMGROUP') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } // Groups elseif ($action === 'GROUP_CREATE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'GROUP_MODIFY') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'GROUP_DELETE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } // Companies elseif ($action === 'COMPANY_CREATE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'COMPANY_MODIFY') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'COMPANY_DELETE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } // Contacts elseif ($action === 'CONTACT_CREATE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'CONTACT_MODIFY') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'CONTACT_DELETE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } // Products elseif ($action === 'PRODUCT_CREATE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'PRODUCT_MODIFY') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'PRODUCT_DELETE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } // Customer orders elseif ($action === 'ORDER_CREATE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'ORDER_CLONE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'ORDER_VALIDATE') { TGrappeFruit::createBillOnOrderValidate($object); dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'ORDER_DELETE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'ORDER_BUILDDOC') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'ORDER_SENTBYMAIL') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'LINEORDER_INSERT') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'LINEORDER_DELETE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } // Supplier orders elseif ($action === 'ORDER_SUPPLIER_CREATE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'ORDER_SUPPLIER_VALIDATE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'ORDER_SUPPLIER_SENTBYMAIL') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'SUPPLIER_ORDER_BUILDDOC') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } // Proposals elseif ($action === 'PROPAL_CREATE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'PROPAL_CLONE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'PROPAL_MODIFY') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'PROPAL_VALIDATE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'PROPAL_BUILDDOC') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'PROPAL_SENTBYMAIL') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'PROPAL_CLOSE_SIGNED') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'PROPAL_CLOSE_REFUSED') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'PROPAL_DELETE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'LINEPROPAL_INSERT') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'LINEPROPAL_MODIFY') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'LINEPROPAL_DELETE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } // Contracts elseif ($action === 'CONTRACT_CREATE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'CONTRACT_MODIFY') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'CONTRACT_ACTIVATE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'CONTRACT_CANCEL') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'CONTRACT_CLOSE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'CONTRACT_DELETE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } // Bills elseif ($action === 'BILL_CREATE') { if(!empty($conf->global->GRAPEFRUIT_LINK_INVOICE_TO_SESSION_IF_PROPAL_IS) && $conf->agefodd->enabled) { // var_dump($object->origin, $object->origin_id); if($object->origin == 'propal' && $object->origin_id>0) { $db = &$this->db; dol_include_once('/agefodd.git/class/agefodd_session_element.class.php'); $res = $db->query("SELECT fk_session_agefodd FROM ".MAIN_DB_PREFIX."agefodd_session_element WHERE fk_element=".$object->origin_id." AND element_type='propal'"); $obj = $db->fetch_object($res); //var_dump($obj->fk_session_agefodd); if($obj->fk_session_agefodd>0) { $agf = new Agefodd_session_element($db); $agf->fk_element = $object->id; $agf->fk_session_agefodd = $obj->fk_session_agefodd; $agf->fk_soc = empty($object->socid) ? $object->fk_soc : $object->socid; $agf->element_type = 'invoice';0 $result = $agf->create($user); //var_dump($result); } //var_dump($db); // exit('!'); } } dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'BILL_CLONE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'BILL_MODIFY') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'BILL_PAYED') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); TGrappeFruit::createShippingFromOrderOnBillPayed($object); if (empty($conf->global->GRAPEFRUIT_SEND_BILL_BY_MAIL_ON_VALIDATE_ORDER)) { TGrappeFruit::sendBillByMail($object); } else { if(empty($object->linked_objects)) $object->fetchObjectLinked(null,null,$object->id,'facture'); if(empty($object->linkedObjects['commande'])) return false; foreach($object->linkedObjects['commande'] as &$commande) { TGrappeFruit::sendOrderByMail($commande); } } } elseif ($action === 'BILL_BUILDDOC') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'BILL_SENTBYMAIL') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'BILL_CANCEL') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'BILL_DELETE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'LINEBILL_INSERT') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'LINEBILL_DELETE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } // Payments elseif ($action === 'PAYMENT_CUSTOMER_CREATE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'PAYMENT_SUPPLIER_CREATE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'PAYMENT_ADD_TO_BANK') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'PAYMENT_DELETE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } // Interventions elseif ($action === 'FICHEINTER_CREATE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'FICHEINTER_MODIFY') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'FICHEINTER_VALIDATE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'FICHEINTER_DELETE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } // Members elseif ($action === 'MEMBER_CREATE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'MEMBER_VALIDATE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'MEMBER_SUBSCRIPTION') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'MEMBER_MODIFY') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'MEMBER_NEW_PASSWORD') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'MEMBER_RESILIATE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'MEMBER_DELETE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } // Categories elseif ($action === 'CATEGORY_CREATE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'CATEGORY_MODIFY') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'CATEGORY_DELETE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } // Projects elseif ($action === 'PROJECT_CREATE') { if(!TGrappeFruit::checkBudgetNotEmpty($object)) return -1; if(!TGrappeFruit::checkDateEndNotEmpty($object)) return -1; TGrappeFruit::createTasks($object); dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'PROJECT_MODIFY') { if(!TGrappeFruit::checkBudgetNotEmpty($object)) return -1; if(!TGrappeFruit::checkDateEndNotEmpty($object)) return -1; dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'PROJECT_DELETE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } // Project tasks elseif ($action === 'TASK_CREATE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'TASK_MODIFY') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'TASK_DELETE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } // Task time spent elseif ($action === 'TASK_TIMESPENT_CREATE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'TASK_TIMESPENT_MODIFY') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'TASK_TIMESPENT_DELETE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } // Shipping elseif ($action === 'SHIPPING_CREATE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'SHIPPING_MODIFY') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'SHIPPING_SENTBYMAIL') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'SHIPPING_DELETE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'SHIPPING_BUILDDOC') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } // File elseif ($action === 'FILE_UPLOAD') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } elseif ($action === 'FILE_DELETE') { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); } */ return 0; }