Exemplo n.º 1
0
 /**
  * @param $data     - Config Array of this Input with the following Structure
  *                      array(
  *                          'label' => 'Label the Function should use',
  *                          'name' => 'The Fieldname, which should submit the value, the Workflow will be write to Environment',
  *                          'config' => Key-Value Array with all configurations, done by admin
  *                      )
  * @param \Workflow\VTEntity $context - Current Record, which is assigned to the Workflow
  * @return array - The rendered content, shown to the user with the following structure
  *                  array(
  *                      'html' => '<htmlContentOfThisInputField>',
  *                      'javascript' => 'A Javascript executed after html is shown'
  *                  )
  *
  */
 public function renderFrontend($data, $context)
 {
     $relmod = $data['config']['reference'];
     $mainData = array();
     $records = \Workflow\VtUtils::getRelatedRecords($context->getModuleName(), $context->getId(), $relmod);
     if (count($records) > 0) {
         $mainData = \Workflow\VtUtils::getMainRecordData($relmod, $records);
         $fieldId = 'field_' . preg_replace('/[^a-zA-Z0-9_]/', '_', $data['name']);
         uasort($mainData, function ($a, $b) {
             return strcmp($a["number"], $b["number"]);
         });
     }
     $html = '';
     $script = '';
     $field = '<select style="width:410px;" name="' . $data['name'] . '" id="' . $fieldId . '" class="select2" data-placeholder="' . vtranslate('choose Reference', 'Workflow2') . '">';
     if (!empty($data['config']['nullable'])) {
         $field .= '<option value="" selected="selected"><em>- ' . vtranslate('no Selection', 'Workflow2') . '</em></option>';
     }
     if (count($mainData) > 0) {
         foreach ($mainData as $crmid => $record) {
             $field .= '<option value="' . $crmid . '" data-url="' . $record['link'] . '">[' . $record['number'] . '] ' . $record['label'] . '</option>';
         }
     }
     $field .= '</select>';
     $html = "<label><div style='min-height:26px;padding:2px 0;'><div style=''><strong>" . $data['label'] . "</strong></div><div style='text-align:right;'>" . $field . "<div style='display:none;margin-top:5px;' id='url_" . $data['name'] . "'></div></div></div></label>";
     $script = '';
     if (!empty($data['config']['nullable'])) {
         $script .= 'jQuery("#' . $fieldId . '").select2("val", "");';
     }
     $script .= 'jQuery("#' . $fieldId . '").on("change", function(e) {var selected = jQuery("#' . $fieldId . ' option:selected"); if(selected.val() == "") { jQuery("#url_' . $data['name'] . '").html("");return;}; jQuery("#url_' . $data['name'] . '").show().html("Link: <a href=\'" + selected.data("url") + "\' target=\'_blank\'><strong>" + selected.text() + "</strong></a>");
      });';
     return array('html' => $html, 'javascript' => $script);
 }
Exemplo n.º 2
0
 /**
  * @param $key
  * @param $value
  * @param $context \Workflow\VTEntity
  * @return array|void
  */
 public function generateAttachments($key, $value, $context)
 {
     $adb = \PearDatabase::getInstance();
     // If added current Document, get the ID from Context
     if ($key == "current_document") {
         $key = $context->getId();
     }
     $parts = explode('#', $key);
     if ($parts[0] == 'all_childs') {
         $crmid = \Workflow\VTTemplate::parse($value[2]['val'], $context);
         if (empty($crmid)) {
             return array();
         }
         if ($crmid == $context->getId()) {
             $this->getAllChildAttachmentIds($context);
             return;
         } else {
             $this->getAllChildAttachmentIds(\Workflow\VTEntity::getForId($crmid));
             return;
         }
     }
     $sql = 'SELECT attachmentsid FROM vtiger_seattachmentsrel WHERE crmid = ?';
     $result = $adb->pquery($sql, array(intval($key)));
     $attachmentID = $adb->query_result($result, 0, "attachmentsid");
     $this->addAttachmentRecord('ID', $attachmentID);
 }
Exemplo n.º 3
0
 /**
  * @param $value
  * @param $name
  * @param $type
  * @param \Workflow\VTEntity $context
  * @return \type
  */
 public function getValue($value, $name, $type, $context)
 {
     if ($type == 'date') {
         $value = \DateTimeField::convertToDBFormat($value);
     }
     if ($type == 'file') {
         //            var_dump($value, $name, $type, $_FILES, $this);
         $context->addTempFile($_FILES['fileUpload']['tmp_name'][$name], $value, $_FILES['fileUpload']['name'][$name]);
         return '1';
     }
     return $value;
 }
Exemplo n.º 4
0
 /**
  * @param $key
  * @param $value
  * @param $context \Workflow\VTEntity
  * @return array|void
  */
 public function doAction($configuration, $filepath, $filename, $context, $targetRecordIds = array())
 {
     $adb = \PearDatabase::getInstance();
     require_once 'modules/Documents/Documents.php';
     $focus = new \Documents();
     $focus->parentid = $context->getId();
     $docTitle = $configuration["title"];
     $docDescr = nl2br($configuration["description"]);
     $docTitle = \Workflow\VTTemplate::parse($docTitle, $context);
     $docDescr = \Workflow\VTTemplate::parse($docDescr, $context);
     $focus->column_fields['notes_title'] = $docTitle;
     $focus->column_fields['assigned_user_id'] = $context->get('assigned_user_id');
     $focus->column_fields['filename'] = $filename;
     $focus->column_fields['notecontent'] = $docDescr;
     $focus->column_fields['filetype'] = 'application/pdf';
     $focus->column_fields['filesize'] = filesize($filepath);
     $focus->column_fields['filelocationtype'] = 'I';
     $focus->column_fields['fileversion'] = '';
     $focus->column_fields['filestatus'] = 'on';
     $focus->column_fields['folderid'] = $configuration["folderid"];
     $focus->save('Documents');
     $upload_file_path = decideFilePath();
     $date_var = date("Y-m-d H:i:s");
     $next_id = $adb->getUniqueID("vtiger_crmentity");
     copy($filepath, $upload_file_path . $next_id . "_" . $filename);
     $sql1 = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(?, ?, ?, ?, ?, ?, ?)";
     $params1 = array($next_id, $context->get('assigned_user_id'), $context->get('assigned_user_id'), "Documents Attachment", 'Documents Attachment', date("Y-m-d H:i:s"), date("Y-m-d H:i:s"));
     $adb->pquery($sql1, $params1);
     $filetype = "application/octet-stream";
     $sql2 = "insert into vtiger_attachments(attachmentsid, name, description, type, path) values(?, ?, ?, ?, ?)";
     $params2 = array($next_id, $filename, $docDescr, $filetype, $upload_file_path);
     $adb->pquery($sql2, $params2, true);
     $sql3 = 'insert into vtiger_seattachmentsrel values(?,?)';
     $adb->pquery($sql3, array($focus->id, $next_id));
     if ($configuration["relation"] === "1") {
         foreach ($targetRecordIds as $id) {
             $sql = "INSERT INTO vtiger_senotesrel SET crmid = " . $id . ", notesid = " . $focus->id;
             $adb->query($sql);
         }
     } else {
         $sql = "DELETE FROM vtiger_senotesrel WHERE crmid = " . $context->getId() . " AND notesid = " . $focus->id;
         $adb->query($sql);
     }
     $newContext = \Workflow\VTEntity::getForId($focus->id, "Documents");
     if ($configuration['workflowid'] !== "") {
         $objWorkflow = new \Workflow\Main($configuration['workflowid'], false, $context->getUser());
         $objWorkflow->setContext($newContext);
         $objWorkflow->isSubWorkflow(true);
         $objWorkflow->start();
     }
 }
Exemplo n.º 5
0
 /**
  * @param $context \Workflow\VTEntity
  */
 public function handleTask(&$context)
 {
     $setterMap = $this->get("setter");
     $newModule = $this->get("new_module");
     if (empty($newModule)) {
         $this->addStat("NO Configuration set");
         return "yes";
     }
     $newObj = VTEntity::create($newModule);
     $this->fieldSetter->apply($newObj, $setterMap, $context, $this);
     if ($newObj->isInventory() && $context->isInventory()) {
         $newObj->importInventory($context->exportInventory());
         $newObj->set('hdnTaxType', $context->get('hdnTaxType'));
     }
     //$newObj->redirectToCreationForm();
     try {
         $newObj->save();
     } catch (WebServiceException $exp) {
         // Somethink is wrong with the values. missing mandatory fields?
     }
     if ($this->_productchooser !== null && $this->get('product') != -1) {
         $newObj = $this->_productchooser->addProducts2Entity($this->get('product'), $context, $newObj);
         try {
             $newObj->save();
         } catch (WebServiceException $exp) {
             // Somethink is wrong with the values. missing mandatory fields?
         }
     }
     if ($context->getModuleName() == "Assets" && $newModule == "HelpDesk") {
         global $adb;
         $sql = "INSERT INTO vtiger_crmentityrel SET crmid = ?, module = ?, relcrmid = ?, relmodule = ?";
         $adb->pquery($sql, array($context->getId(), $context->getModuleName(), $newObj->getId(), $newObj->getModuleName()));
     }
     $context->setEnvironment("new_record_id", $newObj->getId(), $this);
     if ($this->get("redirectAfter") == "1") {
         $this->getWorkflow()->setSuccessRedirection("index.php?module=" . $newModule . "&view=Detail&record=" . $newObj->getId(), 'same');
     }
     if ($this->get("exec_workflow") !== "" && $this->get("exec_workflow") != -1) {
         $newContext = VTEntity::getForId($newObj->getId(), $newObj->getModuleName());
         $newContext->loadEnvironment($context->getEnvironment());
         $objWorkflow = new \Workflow\Main($this->get("exec_workflow"), false, $context->getUser());
         $objWorkflow->setContext($newContext);
         $objWorkflow->start();
     }
     return "yes";
 }
 public function handleTask(&$context)
 {
     $envId = $this->get('envId');
     if (empty($envId)) {
         throw new \Exception('You must configure the generate Recordlist Block and set a Environment ID.');
     }
     $fields = $this->get('fields');
     $env = $context->getEnvironment($envId);
     $moduleName = $env['moduleName'];
     $ids = $env['ids'];
     $tabid = getTabid($moduleName);
     $search_module = $this->get("search_module");
     if (!empty($search_module)) {
         if ($search_module != -1) {
             $parts = explode("#~#", $search_module);
         }
     }
     if ($moduleName != $parts[0]) {
         throw new \Exception('The generate RecordList Block use the wrong Module. You must set ' . $moduleName . ' or create another block.');
     }
     $adb = \PearDatabase::getInstance();
     $html = '<table border=1 cellpadding=2 cellspacing=0>';
     $html .= '<thead><tr>';
     foreach ($fields as $field) {
         $html .= '<th style="width:' . $field['width'] . ';text-align:left;background-color:#ccc;">' . $field['label'] . '</th>';
     }
     $html .= '</tr></thead>';
     foreach ($ids as $id) {
         $html .= '<tr>';
         $record = \Workflow\VTEntity::getForId($id, $moduleName);
         foreach ($fields as $field) {
             if ($field['field'] == 'link') {
                 $value = '<a href="' . vglobal('site_URL') . '/index.php?module=' . $record->getModuleName() . '&view=Detail&record=' . $id . '">Link</a>';
             } else {
                 $value = \Workflow\VTTemplate::parse($field['field'], $record);
             }
             $html .= '<td>' . $value . '</td>';
         }
         $html .= '</tr>';
     }
     $html .= '</table>';
     $env['html'] = $html;
     $context->setEnvironment($envId, $env);
     return "yes";
 }
 /**
  * @param $context \Workflow\VTEntity
  */
 public function handleTask(&$context)
 {
     $values = $this->get("cols");
     $srcrecord = $this->get('srcrecord');
     if (empty($srcrecord) || $srcrecord == -1) {
         $srcrecord = 'crmid';
     }
     if ($srcrecord !== 'crmid') {
         $targetContext = \Workflow\VTEntity::getForId($context->get($srcrecord));
     } else {
         $targetContext = $context;
     }
     foreach ($values["key"] as $index => $value) {
         $keyValue = $values["value"][$index];
         $context->setEnvironment($keyValue, $targetContext->getEntityData($value));
     }
     return "yes";
 }
Exemplo n.º 8
0
 public function process(Vtiger_Request $request)
 {
     ${"GLOBALS"}["drfxxcw"] = "workflow";
     ${"GLOBALS"}["qdicwdai"] = "context";
     $yygxkirxkn = "hash";
     $lmnathdjcp = "params";
     $szuzcuefxy = "execId";
     $vleloffw = "environment";
     global $current_user;
     ${${"GLOBALS"}["ppcqurfuseke"]} = PearDatabase::getInstance();
     ${$lmnathdjcp} = $request->getAll();
     ${${"GLOBALS"}["dchjxoxtxl"]} = (int) $request->get("workflow");
     ${$yygxkirxkn} = $request->get("hash");
     ${${"GLOBALS"}["iujcwkxmrghj"]} = \Workflow\Importer::getInstance(${${"GLOBALS"}["giulhdd"]});
     ${"GLOBALS"}["yijvwhkkly"] = "ready";
     ${"GLOBALS"}["civjsw"] = "current_user";
     ${${"GLOBALS"}["kblmucwe"]} = $objImporter->get("execId");
     $gbidioupkub = "hash";
     if (!empty(${$szuzcuefxy})) {
         $uomjohpljtr = "execId";
         $amancvjzyb = "task";
         ${"GLOBALS"}["ihdjnerjw"] = "sql";
         ${${"GLOBALS"}["hkxcia"]} = \Workflow\Queue::getQueueEntryByExecId(${$uomjohpljtr});
         ${"GLOBALS"}["mtarmljwhk"] = "task";
         ${${"GLOBALS"}["ihdjnerjw"]} = "DELETE FROM vtiger_wf_queue WHERE id = " . ${$amancvjzyb}["queue_id"] . "";
         $adb->query(${${"GLOBALS"}["fmhsywrhw"]});
         \Workflow\Queue::runEntry(${${"GLOBALS"}["mtarmljwhk"]});
         exit;
     }
     ${${"GLOBALS"}["hfdtldd"]} = \Workflow\VTEntity::getDummy();
     ${${"GLOBALS"}["xuwgiqqwoqm"]} = new \Workflow\Main(${${"GLOBALS"}["drfxxcw"]}, false, ${${"GLOBALS"}["civjsw"]});
     ${$vleloffw} = array("_import_hash" => ${$gbidioupkub}, "_internal" => $_SESSION["_import_data"][${${"GLOBALS"}["giulhdd"]}]);
     ${${"GLOBALS"}["ibtbwjumn"]}["importParams"] = $objImporter->get("importParams");
     $context->loadEnvironment(${${"GLOBALS"}["ibtbwjumn"]});
     $objWorkflow->setContext(${${"GLOBALS"}["qdicwdai"]});
     $objWorkflow->start();
     ${${"GLOBALS"}["ibtbwjumn"]} = $context->getEnvironment();
     ${${"GLOBALS"}["meglgccnf"]} = $objImporter->get("ready");
     if (${${"GLOBALS"}["yijvwhkkly"]} == true) {
         $objImporter->handleFinish();
     } else {
         $objImporter->handlePause();
     }
 }
 public function handleTask(&$context)
 {
     /* Insert here source code to execute the task */
     $products = $context->exportInventory();
     $products = $products['listitems'];
     $checked = new \Workflow\ConditionCheck();
     $logger = new \Workflow\ConditionLogger();
     $conditions = $this->get('condition');
     $expression = $this->get('expression');
     $environment = $context->getEnvironment();
     foreach ($products as $product) {
         $productContext = \Workflow\VTEntity::getForId($product['productid'], 'Products');
         $productContext->loadEnvironment($environment);
         $checked->setLogger($logger);
         $return = $checked->check($conditions, $productContext);
         $logs = $logger->getLogs();
         $logs[] = "Complete Result: " . intval($return);
         $this->setStat($logs);
         $logger->clearLogs();
         if ($return == true) {
             $parser = new \Workflow\ExpressionParser($expression, $productContext, false);
             # Last Parameter = DEBUG
             $parser->setVariable('quantity', $product['quantity']);
             $parser->setVariable('unitprice', $product['unitprice']);
             $parser->setVariable('discount_amount', $product['discount_amount']);
             $parser->setVariable('discount_percent', $product['discount_percent']);
             try {
                 $parser->run();
             } catch (\Workflow\ExpressionException $exp) {
                 Workflow2::error_handler(E_EXPRESSION_ERROR, $exp->getMessage(), "", "");
             }
             $environment = $productContext->getEnvironment();
             if ($parser->getReturn() === 'stop') {
                 break;
             }
         }
     }
     $context->loadEnvironment($environment);
     return "yes";
 }
 /**
  * @param $context \Workflow\VTEntity
  */
 public function handleTask(&$context)
 {
     $values = $this->get("cols");
     $srcrecord = $this->get('srcrecord');
     if (empty($srcrecord) || $srcrecord == -1) {
         $srcrecord = 'crmid';
     }
     if ($srcrecord !== 'crmid') {
         $targetContext = \Workflow\VTEntity::getForId($context->get($srcrecord));
     } else {
         $targetContext = $context;
     }
     foreach ($values["key"] as $index => $value) {
         $keyValue = $values["value"][$index];
         if (strpos($keyValue, '$') !== false || strpos($keyValue, '?') !== false) {
             $objTemplate = new VTTemplate($context);
             $keyValue = $objTemplate->render($keyValue);
         }
         $targetContext->addEntityData($value, $keyValue);
     }
     return "yes";
 }
 /**
  * @param $context \Workflow\VTEntity
  */
 public function handleTask(&$context)
 {
     $recordID = trim($this->get("recordid", $context));
     if (!empty($recordID) && $recordID != -1) {
         $contextRecord = \Workflow\VTEntity::getForId($recordID);
     } else {
         $contextRecord = $context;
     }
     $newObj = \Workflow\VTEntity::create($contextRecord->getModuleName());
     $oldData = $contextRecord->getData();
     foreach ($oldData as $key => $value) {
         $newObj->set($key, $value);
     }
     if ($contextRecord->isInventory()) {
         $products = $contextRecord->exportInventory();
         $newObj->importInventory($products);
         $newObj->save();
     }
     /* After this line, copy from Creator */
     $setterMap = $this->get("setter");
     if (is_array($setterMap)) {
         $this->fieldSetter->apply($newObj, $setterMap, $contextRecord, $this);
     }
     $newObj->save();
     $context->setEnvironment("new_record_id", $newObj->getWsId(), $this);
     if ($this->get("redirectAfter") == "1") {
         $this->getWorkflow()->setSuccessRedirection("index.php?module=" . $newObj->getModuleName() . "&view=Detail&record=" . $newObj->getId());
     }
     if ($this->get("exec_workflow") !== "" && $this->get("exec_workflow") != -1) {
         $newContext = \Workflow\VTEntity::getForId($newObj->getId(), $newObj->getModuleName());
         $objWorkflow = new \Workflow\Main($this->get("exec_workflow"), false, $context->getUser());
         $objWorkflow->setContext($newContext);
         $objWorkflow->isSubWorkflow(true);
         $objWorkflow->start();
     }
     return "yes";
 }
Exemplo n.º 12
0
 /**
  * @param $context \Workflow\VTEntity|\Workflow\VTInventoryEntity
  */
 public function handleTask(&$context)
 {
     $referenceId = $context->getId();
     Workflow2::$enableError = true;
     $parentRecordModel = Inventory_Record_Model::getInstanceById($referenceId);
     $currencyInfo = $parentRecordModel->getCurrencyInfo();
     $taxes = $parentRecordModel->getProductTaxes();
     $shippingTaxes = $parentRecordModel->getShippingTaxes();
     $relatedProducts = $parentRecordModel->getProducts();
     $recordModel = Vtiger_Record_Model::getCleanInstance('Invoice');
     $recordModel->setRecordFieldValues($parentRecordModel);
     $recordModel->save();
     $newId = $recordModel->getId();
     $contextRecord = $context;
     /**
      * @var $newObj \Workflow\VTEntity|\Workflow\VTInventoryEntity
      */
     $newObj = \Workflow\VTEntity::getForId($newId);
     $newObj->set('hdnTaxType', $parentRecordModel->get('hdnTaxType'));
     $newObj->importProductsFromRecord($relatedProducts, true);
     $setterMap = $this->get("setter");
     $this->fieldSetter->apply($newObj, $setterMap, $contextRecord, $this);
     $newObj->save();
     if ($this->get("redirectAfter") == "1") {
         $this->getWorkflow()->setSuccessRedirection("index.php?module=" . $newObj->getModuleName() . "&view=Detail&record=" . $newObj->getId());
     }
     if ($this->get("exec_workflow") !== "" && $this->get("exec_workflow") != -1) {
         $newContext = VTEntity::getForId($newObj->getId(), $newObj->getModuleName());
         $newContext->loadEnvironment($context->getEnvironment());
         $objWorkflow = new \Workflow\Main($this->get("exec_workflow"), false, $context->getUser());
         $objWorkflow->isSubWorkflow(true);
         $objWorkflow->setContext($newContext);
         $objWorkflow->start();
     }
     Workflow2::$enableError = true;
 }
Exemplo n.º 13
0
 public function handleEvent($handlerType, $entityData)
 {
     ob_start();
     $buqkvslhibra = "wfManager";
     if (isset($_REQUEST["tableblocks"])) {
         $fcbnalas = "tableBlocks";
         ${$fcbnalas} = $_REQUEST["tableblocks"];
         unset($_REQUEST["tableblocks"]);
     }
     ${$buqkvslhibra} = new \Workflow\Manager();
     ${"GLOBALS"}["miokdjdmdfu"] = "handlerType";
     EntityDelta::refreshDelta($entityData->getModuleName(), $entityData->focus->id);
     if (empty($_SERVER["HTTP_X_REQUESTED_WITH"]) || strtolower($_SERVER["HTTP_X_REQUESTED_WITH"]) != "xmlhttprequest") {
         Workflow2::${${"GLOBALS"}["ulovgcim"]} = false;
     }
     Workflow2::log($entityData->focus->id, 0, 0, "Start EventHandler");
     $snkisgyf = "tableBlocks";
     if ($entityData->getModuleName() == "Emails") {
         ${"GLOBALS"}["wykgomknt"] = "recordid";
         $blnoxjqmlwd = "from_email";
         ${${"GLOBALS"}["jivgrzryssor"]} = explode("|", $entityData->get("parent_id"));
         if (!empty($_REQUEST["pmodule"]) && !empty($_REQUEST["sorce_ids"])) {
             $swvglcac = "parent_ids";
             ${$swvglcac}[] = $_REQUEST["sorce_ids"];
         }
         $lioxtho = "from_email";
         ${$blnoxjqmlwd} = $entityData->get("from_email");
         ${${"GLOBALS"}["bichpdpooc"]} = $entityData->get("saved_toid");
         if (empty(${${"GLOBALS"}["jouqmwctl"]})) {
             if (!empty($_REQUEST["from_email"])) {
                 ${"GLOBALS"}["rbujprnbgdx"] = "email_val";
                 ${"GLOBALS"}["fitxeffb"] = "type";
                 list(${${"GLOBALS"}["fitxeffb"]}, ${${"GLOBALS"}["mhnoosvdd"]}) = explode("::", addslashes($_REQUEST["from_email"]), 2);
                 if (${${"GLOBALS"}["rbujprnbgdx"]} != "") {
                     global $adb;
                     if (${${"GLOBALS"}["bhmfosqagd"]} == "a") {
                         ${"GLOBALS"}["fqvigntr"] = "sql_a";
                         ${"GLOBALS"}["jncqqplmd"] = "from_email";
                         $igxjijlcydv = "sql_a";
                         ${${"GLOBALS"}["fqvigntr"]} = "select * from vtiger_systems where from_email_field != ? AND server_type = ?";
                         ${${"GLOBALS"}["xprvdcgf"]} = $adb->pquery(${$igxjijlcydv}, array("", "email"));
                         ${${"GLOBALS"}["jncqqplmd"]} = $adb->query_result(${${"GLOBALS"}["xprvdcgf"]}, 0, "from_email_field");
                     } else {
                         ${"GLOBALS"}["evgeluzfpjrb"] = "sql_u";
                         ${"GLOBALS"}["jbhzfdfy"] = "sql_u";
                         ${${"GLOBALS"}["evgeluzfpjrb"]} = "SELECT first_name, last_name, " . ${${"GLOBALS"}["bhmfosqagd"]} . " AS email  FROM vtiger_users WHERE id = '" . ${${"GLOBALS"}["mhnoosvdd"]} . "'";
                         ${${"GLOBALS"}["eldowmraukw"]} = $adb->pquery(${${"GLOBALS"}["jbhzfdfy"]}, array());
                         ${${"GLOBALS"}["jouqmwctl"]} = $adb->query_result(${${"GLOBALS"}["eldowmraukw"]}, 0, "email");
                     }
                 }
             } else {
                 $gpvvsxkue = "from_email";
                 global $current_user;
                 ${$gpvvsxkue} = $current_user->column_fields["email1"];
             }
         }
         ${${"GLOBALS"}["ijfuwupmdh"]} = array("subject" => $entityData->get("subject"), "content" => $entityData->get("description"), "from" => ${$lioxtho}, "to" => ${${"GLOBALS"}["bichpdpooc"]});
         foreach (${${"GLOBALS"}["jivgrzryssor"]} as ${${"GLOBALS"}["wykgomknt"]}) {
             $ypgvphf = "recordid";
             if (empty(${${"GLOBALS"}["oubotd"]})) {
                 continue;
             }
             ${${"GLOBALS"}["lcnizm"]} = VTEntity::getForId(${$ypgvphf});
             if (${${"GLOBALS"}["lcnizm"]} !== false) {
                 ${"GLOBALS"}["lxtohylj"] = "workflows";
                 ${${"GLOBALS"}["lxtohylj"]} = $wfManager->GetWorkflows($context->getModuleName(), Workflow\Main::SENDMAIL_START);
                 if (count(${${"GLOBALS"}["qyirwsbmmu"]}) > 0) {
                     ${"GLOBALS"}["ccnmigsavy"] = "maildata";
                     $smkkdars = "wf";
                     $context->setEnvironment("email", ${${"GLOBALS"}["ccnmigsavy"]});
                     foreach (${${"GLOBALS"}["qyirwsbmmu"]} as ${$smkkdars}) {
                         $wf->setExecutionTrigger("WF2_CREATION");
                         if (!$context->isAvailable()) {
                             break;
                         }
                         $wf->setContext(${${"GLOBALS"}["lcnizm"]});
                         if ($wf->checkCondition(${${"GLOBALS"}["zltonpc"]})) {
                             $wf->start();
                         }
                     }
                 }
             }
         }
     }
     if ($entityData->getModuleName() == "ModComments") {
         ${${"GLOBALS"}["iasgnhr"]} = array("commentcontent" => $entityData->get("commentcontent"), "assigned_user_id" => $entityData->get("assigned_user_id"));
         $tvesqluqa = "parent_ids";
         ${$tvesqluqa} = array($entityData->get("related_to"));
         foreach (${${"GLOBALS"}["jivgrzryssor"]} as ${${"GLOBALS"}["oubotd"]}) {
             ${${"GLOBALS"}["lcnizm"]} = VTEntity::getForId(${${"GLOBALS"}["oubotd"]});
             $context->loadEnvironment(array_merge($context->getEnvironment(), ${${"GLOBALS"}["iasgnhr"]}));
             if (${${"GLOBALS"}["lcnizm"]} !== false) {
                 $fpzckemsvm = "wf";
                 ${${"GLOBALS"}["qyirwsbmmu"]} = $wfManager->GetWorkflows($context->getModuleName(), Workflow\Main::COMMENT_START);
                 foreach (${${"GLOBALS"}["qyirwsbmmu"]} as ${$fpzckemsvm}) {
                     $wwheuivbjc = "context";
                     $wf->setExecutionTrigger("WF2_CREATION");
                     if (!$context->isAvailable()) {
                         break;
                     }
                     $gtfpogfmp = "entityData";
                     $wf->setContext(${$wwheuivbjc});
                     if ($wf->checkCondition(${$gtfpogfmp})) {
                         $wf->start();
                     }
                 }
             }
         }
     }
     if (${${"GLOBALS"}["miokdjdmdfu"]} == "vtiger.entity.aftersave") {
         $obmqbokjajz = "context";
         ${$obmqbokjajz} = VTEntity::getForId($entityData->focus->id, $entityData->getModuleName());
         ${"GLOBALS"}["ubninbunb"] = "wf";
         ${"GLOBALS"}["jefljf"] = "context";
         Queue::updateDynamicDate(${${"GLOBALS"}["jefljf"]});
         ${${"GLOBALS"}["qyirwsbmmu"]} = $wfManager->GetWorkflows($entityData->getModuleName(), array(Workflow\Main::ON_FIRST_SAVE, Workflow\Main::ON_EVERY_SAVE));
         ${${"GLOBALS"}["qwvmufvez"]} = $entityData->isNew();
         foreach (${${"GLOBALS"}["qyirwsbmmu"]} as ${${"GLOBALS"}["ubninbunb"]}) {
             $uhytlcpqip = "context";
             if (!$wf->checkExecuteCondition(${$uhytlcpqip})) {
                 continue;
             }
             $wf->setExecutionTrigger(${${"GLOBALS"}["qwvmufvez"]} ? "WF2_CREATION" : "WF2_EVERY_SAVE");
             Workflow2::log($entityData->focus->id, $wf->getId(), 0, "Found WF");
             $fbdjnio = "isNew";
             if (PHP_SAPI === "cli") {
                 echo "Start of Workflow " . $wf->getId() . "\n";
             }
             ${${"GLOBALS"}["lcnizm"]} = VTEntity::getForId($entityData->focus->id, $entityData->getModuleName());
             $context->setIsNew(${$fbdjnio});
             if (!$context->isAvailable()) {
                 break;
             }
             $wf->setContext(${${"GLOBALS"}["lcnizm"]});
             if ($wf->checkCondition(${${"GLOBALS"}["zltonpc"]})) {
                 $wf->start();
                 if ($wf->getSuccessRedirection() !== false) {
                     header("Location:" . $wf->getSuccessRedirection());
                     exit;
                 }
             }
         }
     }
     if (${${"GLOBALS"}["tgrrmbvg"]} == "vtiger.entity.beforedelete") {
         ${${"GLOBALS"}["qyirwsbmmu"]} = $wfManager->GetWorkflows($entityData->getModuleName(), array(Workflow\Main::BEFOREDELETE_START));
         foreach (${${"GLOBALS"}["qyirwsbmmu"]} as ${${"GLOBALS"}["moypxyiw"]}) {
             if (!$wf->checkExecuteCondition(${${"GLOBALS"}["lcnizm"]})) {
                 continue;
             }
             $wf->setExecutionTrigger(Workflow\Main::BEFOREDELETE_START);
             Workflow2::log($entityData->focus->id, $wf->getId(), 0, "Found WF");
             if (PHP_SAPI === "cli") {
                 echo "Start of Workflow " . $wf->getId() . "\n";
             }
             ${${"GLOBALS"}["lcnizm"]} = VTEntity::getForId($entityData->focus->id, $entityData->getModuleName());
             $context->setIsNew(false);
             if (!$context->isAvailable()) {
                 break;
             }
             $wf->setContext(${${"GLOBALS"}["lcnizm"]});
             if ($wf->checkCondition(${${"GLOBALS"}["zltonpc"]})) {
                 $wf->start();
                 if ($wf->getSuccessRedirection() !== false) {
                     Workflow2::error_handler(E_NONBREAK_ERROR, "Redirections do not work on \"before delete\" triggered Workflows.");
                 }
             }
         }
     }
     if (isset(${$snkisgyf})) {
         $_REQUEST["tableblocks"] = ${${"GLOBALS"}["ujnutvf"]};
     }
     Workflow2::${${"GLOBALS"}["ihoxvzlniq"]} = false;
 }
Exemplo n.º 14
0
 ${"GLOBALS"}["viljauoxjm"] = "user";
 if (${${"GLOBALS"}["nzrzpvuahr"]}["execution_user"] == "0") {
     ${${"GLOBALS"}["nzrzpvuahr"]}["execution_user"] = $current_user->id;
 }
 ${"GLOBALS"}["uhixyxgidqr"] = "row";
 $nrhyxmzurk = "user";
 ${${"GLOBALS"}["viljauoxjm"]} = new Users();
 ${"GLOBALS"}["eaiddcmebmb"] = "row";
 $user->retrieveCurrentUserInfoFromFile(${${"GLOBALS"}["uhixyxgidqr"]}["execution_user"]);
 \Workflow\VTEntity::setUser(${$nrhyxmzurk});
 ${${"GLOBALS"}["vcbzbbezhw"]} = new Workflow_Main(${${"GLOBALS"}["eaiddcmebmb"]}["id"], false, ${${"GLOBALS"}["vpcmorlu"]});
 $objWorkflow->setExecutionTrigger("WF2_MANUELL");
 if (${${"GLOBALS"}["bjxrkxjwht"]} == false && $objWorkflow->isRunning($_POST["crmid"])) {
     continue;
 }
 ${${"GLOBALS"}["suwlvvxno"]} = \Workflow\VTEntity::getForId(intval($_POST["crmid"]), $_POST["return_module"]);
 if (!empty(${${"GLOBALS"}["nzrzpvuahr"]}["startfields"]) && !isset($_POST["startfields"])) {
     ${"GLOBALS"}["djwuofnr"] = "row";
     $ciuknauota = "startfields";
     ${${"GLOBALS"}["ekwrlphqm"]} = unserialize(${${"GLOBALS"}["djwuofnr"]}["startfields"]);
     $oaeirdgf = "value";
     foreach (${${"GLOBALS"}["ekwrlphqm"]} as ${${"GLOBALS"}["ohibiiqriqt"]} => ${$oaeirdgf}) {
         $xvdqmpgby = "startfields";
         $irouxk = "key";
         $eawxjdnsn = "context";
         ${"GLOBALS"}["mqwzhj"] = "value";
         ${${"GLOBALS"}["mqwzhj"]}["default"] = trim(VTTemplate::parse(${${"GLOBALS"}["dsqtopnzqiy"]}["default"], ${$eawxjdnsn}));
         ${$xvdqmpgby}[${$irouxk}] = ${${"GLOBALS"}["dsqtopnzqiy"]};
     }
     die(json_encode(array("result" => "startfields", "workflow" => intval($_POST["workflow"]), "fields" => ${$ciuknauota})));
 }
 public function handleTask(&$context)
 {
     $adb = \PearDatabase::getInstance();
     /* Insert here source code to execute the task */
     $format = $this->get('fileformat');
     $fields = $this->get('fields');
     $tmpfile = tempnam(sys_get_temp_dir(), 'CSV');
     @unlink($tmpfile);
     $source = $this->get('source');
     if ($source == -1 || $source == 'envid') {
         $env = $context->getEnvironment($this->get('recordlistid'));
     } elseif ($source == 'customview') {
         $search_module = $this->get("search_module");
         $parts = explode("#~#", $search_module);
         $searchModuleName = $parts[0];
         $queryGenerator = new \QueryGenerator($searchModuleName, \Users::getActiveAdminUser());
         $queryGenerator->initForCustomViewById($this->get('customviewsource'));
         $query = $queryGenerator->getQuery();
         $parts = preg_split('/FROM/i', $query);
         $sqlQuery = 'SELECT vtiger_crmentity.crmid as id_col FROM ' . $parts[1];
         $result = $adb->query($sqlQuery, true);
         $this->addStat("num Rows: " . $adb->num_rows($result));
         while ($row = $adb->fetchByAssoc($result)) {
             $recordids[] = $row["id_col"];
         }
         $env = array('moduleName' => $searchModuleName, 'ids' => $recordids);
     }
     $moduleName = $env['moduleName'];
     $ids = $env['ids'];
     $filename = $this->get('filename', $context);
     switch ($format) {
         case 'csv':
             $file = fopen($tmpfile, 'w');
             $headline = $this->get('insertheadline');
             if ($headline == '1') {
                 $headline = array();
                 foreach ($fields as $field) {
                     $headline[] = $field['label'];
                 }
                 fputcsv($file, $headline, ';');
             }
             foreach ($ids as $id) {
                 $record = \Workflow\VTEntity::getForId($id, $moduleName);
                 $tmp = array();
                 foreach ($fields as $field) {
                     $tmp[] = \Workflow\VTTemplate::parse($field['field'], $record);
                 }
                 fputcsv($file, $tmp, ';');
             }
             fclose($file);
             break;
         case 'excel':
             require_once $this->getAdditionalPath('phpexcel') . 'PHPExcel.php';
             // Create new PHPExcel object
             $objPHPExcel = new PHPExcel();
             // Set document properties
             $objPHPExcel->getProperties()->setCreator("Workflow Designer")->setLastModifiedBy("Workflow Designer")->setTitle("Workflow Designer Export")->setSubject("Workflow Designer Export");
             $headline = $this->get('insertheadline');
             $alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
             $currentROW = 1;
             if ($headline == '1') {
                 $headline = array();
                 foreach ($fields as $field) {
                     $headline[] = $field['label'];
                 }
                 $objPHPExcel->setActiveSheetIndex(0)->fromArray(array($headline), NULL, 'A1');
                 $currentROW++;
             }
             foreach ($ids as $id) {
                 $record = \Workflow\VTEntity::getForId($id, $moduleName);
                 $tmp = array();
                 foreach ($fields as $field) {
                     $tmp[] = \Workflow\VTTemplate::parse($field['value'], $record);
                 }
                 $objPHPExcel->getActiveSheet()->fromArray($tmp, '', 'A' . $currentROW);
                 $currentROW++;
             }
             $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
             $objWriter->save($tmpfile);
             break;
     }
     \Workflow\FileAction::doActions($this->get('resultaction'), $tmpfile, $filename, $context, $context->getId(), $this->getWorkflow());
     @unlink($tmpfile);
     return "yes";
 }
 public function handleTask(&$context)
 {
     /** Copied from WfTaskDuplicateRecord */
     /**
      * @var $contextRecord VTInventoryEntity
      */
     $contextRecord = $context;
     $newObj = \Workflow\VTEntity::create($contextRecord->getModuleName());
     $oldData = $contextRecord->getData();
     //var_dump($oldData);
     foreach ($oldData as $key => $value) {
         $newObj->set($key, $value);
     }
     //$newObj->set('hdnDiscountPercent', -1 * $oldData['hdnDiscountPercent']);
     $newObj->set('hdnDiscountAmount', -1 * $oldData['hdnDiscountAmount']);
     /** Copied from WfTaskDuplicateRecord ENDE */
     $products = $contextRecord->exportInventory();
     foreach ($products["listitems"] as $index => $listitem) {
         $listitem["quantity"] *= -1;
         $listitem['discount_amount'] *= -1;
         $products["listitems"][$index] = $listitem;
     }
     $products["shippingCost"] *= -1;
     $newObj->importInventory($products);
     /* After this line, copy from Creator */
     $setterMap = $this->get("setter");
     $this->fieldSetter->apply($newObj, $setterMap, $contextRecord, $this);
     $products = $this->get("product");
     /* INSERT PRODUCT */
     if (is_array($products) && count($products) > 0) {
         $availTaxes = getAllTaxes("available");
         foreach ($products as $index => $value) {
             if (!empty($value["productid_individual"])) {
                 $productid = VTTemplate::parse($value["productid_individual"], $context);
             } else {
                 $productid = $value["productid"];
             }
             if (strpos($productid, "x") !== false) {
                 $parts = explode("x", $productid);
                 $productid = $parts[1];
             }
             $crmProduct = CRMEntity::getInstance("Products");
             $crmProduct->id = $productid;
             $crmProduct->retrieve_entity_info($productid, "Products");
             $context->setEnvironment("product", $crmProduct->column_fields);
             foreach ($value as $key => $template) {
                 $value[$key] = VTTemplate::parse($template, $context);
             }
             $tax = array();
             foreach ($availTaxes as $aTax) {
                 if ($value["tax" . $aTax["taxid"] . "_enable"] == 1) {
                     $tax[$aTax["taxid"]] = VTTemplate::parse($value["tax" . $aTax["taxid"]], $context);
                 }
             }
             $this->addStat("AddProduct " . $value["quantity"] . " x " . $productid . " (" . $value["unitprice"] . ")");
             $newObj->addProduct($productid, $value["description"], $value["comment"], $value["quantity"], $value["unitprice"], $value["discount_mode"] == "percentage" ? $value["discount_value"] : 0, $value["discount_mode"] == "amount" ? $value["discount_value"] : 0, $tax);
         }
         try {
             $newObj->save();
         } catch (WebServiceException $exp) {
             // Somethink is wrong with the values. missing mandatory fields?
         }
     }
     try {
         $newObj->save();
     } catch (WebServiceException $exp) {
         // Somethink is wrong with the values. missing mandatory fields?
     }
     $context->setEnvironment("new_record_id", $newObj->getWsId(), $this);
     if ($this->get("redirectAfter") == "1") {
         $this->getWorkflow()->setSuccessRedirection($newObj->getDetailUrl());
     }
     if ($this->get("exec_workflow") !== "" && $this->get("exec_workflow") != -1) {
         $newContext = \Workflow\VTEntity::getForId($newObj->getId(), $newObj->getModuleName());
         $objWorkflow = new \Workflow\Main($this->get("exec_workflow"), false, $context->getUser());
         $objWorkflow->setContext($newContext);
         $objWorkflow->isSubWorkflow(true);
         $objWorkflow->start();
     }
     return "yes";
 }
 function wf_changedfields($crmid, $internalFields = false)
 {
     if (empty($crmid)) {
         return false;
     }
     $objRecord = \Workflow\VTEntity::getForId($crmid);
     return \Workflow\EntityDelta::changeFields($objRecord->getModuleName(), $crmid, $internalFields);
 }
 /**
  * @param $context \Workflow\VTEntity
  * @return string
  */
 public function handleTask(&$context)
 {
     global $adb;
     if ($this->get("search_module") == -1) {
         return "no";
     }
     $found_rows = $this->get("found_rows");
     if (empty($found_rows) || $found_rows == -1) {
         $found_rows = 1;
     }
     $recordsource = $this->get('recordsource');
     if (empty($recordsource) || $recordsource == -1) {
         $recordsource = 'condition';
     }
     $parts = explode("#~#", $this->get("search_module"));
     $functionName = $parts[0];
     $related_module = VtUtils::getModuleName($parts[1]);
     $recordids = array();
     if ($recordsource == 'condition') {
         require_once 'modules/Workflow2/VTConditionMySql.php';
         $logger = new \Workflow\ConditionLogger();
         $objMySQL = new \Workflow\ConditionMysql($related_module, $context);
         $objMySQL->setLogger($logger);
         $main_module = CRMEntity::getInstance($related_module);
         #$sqlTables = $main_module->generateReportsQuery($related_module);
         $sqlCondition = $objMySQL->parse($this->get("condition"));
         $sqlTables = $objMySQL->generateTables();
         if (strlen($sqlCondition) > 3) {
             $sqlCondition .= " AND vtiger_crmentity.deleted = 0";
         } else {
             $sqlCondition .= " vtiger_crmentity.deleted = 0";
         }
         $logs = $logger->getLogs();
         $this->setStat($logs);
         $idColumn = $main_module->table_name . "." . $main_module->table_index;
         $sqlQuery = "SELECT {$idColumn} as `idCol` " . $sqlTables . " WHERE " . (strlen($sqlCondition) > 3 ? $sqlCondition : "");
         $sortField = $this->get("sort_field");
         $sqlQuery .= ' GROUP BY crmid ';
         if (!empty($sortField) && $sortField != -1) {
             $sortDirection = $this->get("sortDirection");
             $sortField = VtUtils::getColumnName($sortField);
             $sqlQuery .= " ORDER BY " . $sortField . " " . $sortDirection;
         }
         $numRows = $this->get("found_rows");
         if (!empty($numRows) && $numRows != -1) {
             $sqlQuery .= " LIMIT " . $found_rows;
         }
         $this->addStat("MySQL Query: " . $sqlQuery);
         $result = $adb->query($sqlQuery, true);
         $this->addStat("num Rows: " . $adb->num_rows($result));
         while ($row = $adb->fetchByAssoc($result)) {
             $recordids[] = $row["idcol"];
         }
     }
     if ($recordsource == 'customview') {
         $queryGenerator = new \QueryGenerator($related_module, \Users::getActiveAdminUser());
         $queryGenerator->initForCustomViewById($this->get('customviewsource'));
         $query = $queryGenerator->getQuery();
         $parts = preg_split('/FROM/i', $query);
         $sqlQuery = 'SELECT vtiger_crmentity.crmid as id_col FROM ' . $parts[1];
         $result = $adb->query($sqlQuery, true);
         $this->addStat("num Rows: " . $adb->num_rows($result));
         while ($row = $adb->fetchByAssoc($result)) {
             $recordids[] = $row["id_col"];
         }
     }
     $filterbyproduct = $this->get('filterbyproduct');
     if ($filterbyproduct === 'yes') {
         $products = $this->get('products');
         if (!empty($products)) {
             $sql = 'SELECT id FROM vtiger_inventoryproductrel WHERE id IN (' . generateQuestionMarks($recordids) . ') AND productid = ? GROUP BY id';
             $recordids[] = $products;
             $result = $adb->pquery($sql, $recordids);
             $recordids = array();
             while ($row = $adb->fetchByAssoc($result)) {
                 $recordids[] = $row['id'];
             }
         }
     }
     $workflow_id = $this->get("workflow_id");
     if (!empty($workflow_id)) {
         foreach ($recordids as $recordId) {
             $tmpContext = \Workflow\VTEntity::getForId($recordId, $related_module);
             $tmpContext->clearEnvironment();
             $tmpContext->loadEnvironment($context->getEnvironment());
             $obj = new \Workflow\Main($workflow_id, false, $context->getUser());
             $obj->setExecutionTrigger($this->getWorkflow()->getExecutionTrigger());
             $obj->setContext($tmpContext);
             $obj->isSubWorkflow(true);
             $obj->start();
             if ($obj->getSuccessRedirection() != false) {
                 $this->getWorkflow()->setSuccessRedirection($obj->getSuccessRedirection());
                 $this->getWorkflow()->setSuccessRedirectionTarget($obj->getSuccessRedirectionTarget());
             }
             $env = $this->get("env");
             if ($env !== -1 && !empty($env["result_environments"])) {
                 $oldEnv = $context->getEnvironment($env["result_environments"]);
                 $oldEnv[] = $tmpContext->getEnvironment();
                 $context->setEnvironment("result_environments", $oldEnv, $this);
             }
         }
     }
     return "yes";
 }
Exemplo n.º 19
0
 /**
  * @param $context \Workflow\VTEntity
  */
 public function handleTask(&$context)
 {
     $setterMap = $this->get("setter");
     $newModule = $this->get("new_module");
     if (empty($newModule)) {
         $this->addStat("NO Configuration set");
         return "yes";
     }
     $uniqueCheck = $this->get('uniquecheck');
     $createNew = true;
     if ($uniqueCheck !== -1 && is_array($uniqueCheck) && !empty($uniqueCheck)) {
         $setterMap = $this->get('setter');
         $fieldValue = $this->fieldSetter->getFieldValueArray($context, $setterMap);
         $condition = array();
         foreach ($uniqueCheck as $checkField) {
             $condition[$checkField] = $fieldValue[$checkField];
         }
         $records = \Workflow\VtUtils::findRecordIDs($newModule, $condition);
         if (count($records) > 0) {
             // duplicate records found
             $this->addStat('duplicate Record found [' . implode(',', $records) . '] -> do not create new');
             $updateexisting = $this->get('updateexisting');
             if ($updateexisting !== -1 && is_array($updateexisting) && !empty($updateexisting)) {
                 foreach ($records as $crmid) {
                     $entity = \Workflow\VTEntity::getForId($crmid);
                     foreach ($updateexisting as $field) {
                         $entity->set($field, $fieldValue[$field]);
                     }
                     $entity->save();
                     break;
                 }
             }
             $context->setEnvironment("new_record_id", $records[0], $this);
             $context->setEnvironment("was_created_new", 'false', $this);
             $createNew = false;
             $newObj = \Workflow\VTEntity::getForId($records[0]);
         }
     }
     if ($createNew === true) {
         $newObj = VTEntity::create($newModule);
         $this->fieldSetter->apply($newObj, $setterMap, $context, $this);
         try {
             $newObj->save();
         } catch (WebServiceException $exp) {
             // Somethink is wrong with the values. missing mandatory fields?
         }
         $context->setEnvironment("new_record_id", $newObj->getId(), $this);
         $context->setEnvironment("was_created_new", 'true', $this);
     }
     if ($context->getModuleName() == "Assets" && $newModule == "HelpDesk") {
         global $adb;
         $sql = "INSERT INTO vtiger_crmentityrel SET crmid = ?, module = ?, relcrmid = ?, relmodule = ?";
         $adb->pquery($sql, array($context->getId(), $context->getModuleName(), $newObj->getId(), $newObj->getModuleName()));
     }
     if ($this->get("redirectAfter") == "1") {
         $this->getWorkflow()->setSuccessRedirection("index.php?module=" . $newModule . "&view=Detail&record=" . $newObj->getId());
     }
     if ($this->get("exec_workflow") !== "" && $this->get("exec_workflow") != -1) {
         $newContext = VTEntity::getForId($newObj->getId(), $newObj->getModuleName());
         $newContext->loadEnvironment($context->getEnvironment());
         $objWorkflow = new \Workflow\Main($this->get("exec_workflow"), false, $context->getUser());
         $objWorkflow->isSubWorkflow(true);
         $objWorkflow->setContext($newContext);
         $objWorkflow->start();
     }
     Workflow2::$enableError = true;
     return "yes";
 }
Exemplo n.º 20
0
 public function save()
 {
     ${"GLOBALS"}["ducixeik"] = "additionalProductFields";
     ${${"GLOBALS"}["wtrcwdueuts"]} = PearDatabase::getInstance();
     ${${"GLOBALS"}["ducixeik"]} = $this->getAdditionalProductFields();
     ${"GLOBALS"}["molcrpc"] = "manualUpdateFields";
     ${"GLOBALS"}["gbmhcqh"] = "tmp";
     ${"GLOBALS"}["ewjsruuy"] = "fieldName";
     ${${"GLOBALS"}["molcrpc"]} = array();
     foreach (${${"GLOBALS"}["vptmrj"]} as ${${"GLOBALS"}["ewjsruuy"]} => ${${"GLOBALS"}["gbmhcqh"]}) {
         if (${${"GLOBALS"}["ykppheofobwk"]}["implemented"] == false) {
             $jpmxewcq = "relData";
             ${"GLOBALS"}["fkfnvsuaox"] = "manualUpdateFields";
             ${${"GLOBALS"}["fkfnvsuaox"]}[] = ${${"GLOBALS"}["thpgoyrlu"]};
             ${$jpmxewcq} = $this->_getProductRelData();
         }
     }
     require_once "modules/Emails/mail.php";
     if (!empty($this->_id) && $this->_changed == true) {
         $this->_changedProducts = $this->_changed;
         if ($this->_listitems === null) {
             $this->_loadProducts();
         }
     }
     parent::save();
     $this->prepareTransfer();
     if (!empty($this->_currencyID)) {
         ${${"GLOBALS"}["xkutivbm"]} = $this->_currencyID;
     } else {
         $ogqhrcro = "currency_id";
         ${$ogqhrcro} = false;
     }
     $this->clearData();
     if ($this->_changedProducts === true) {
         ${"GLOBALS"}["tgkrfb"] = "shipping_handling_charge";
         ${"GLOBALS"}["negltbro"] = "field";
         ${${"GLOBALS"}["amsupsflnmf"]} = $this->get("hdnTaxType");
         ${"GLOBALS"}["hxnewftfdqn"] = "i";
         ${"GLOBALS"}["etqhqirsnh"] = "taxtype";
         $agoclef = "adjustment";
         ${$agoclef} = 0;
         ${${"GLOBALS"}["tgkrfb"]} = 0;
         $qwpblm = "i";
         ${"GLOBALS"}["krxwtxw"] = "fields";
         ${${"GLOBALS"}["whqnrjvsw"]} = getAllTaxes();
         $nxxrnbh = "intObject";
         $mdwcbjhvim = "availTaxes";
         $vaqwwrr = "value";
         $_REQUEST["totalProductCount"] = count($this->_listitems);
         $_REQUEST["taxtype"] = ${${"GLOBALS"}["etqhqirsnh"]};
         $_REQUEST["subtotal"] = 0;
         ${${"GLOBALS"}["pponynktout"]} = $this->getProductFields();
         foreach (${${"GLOBALS"}["krxwtxw"]} as ${${"GLOBALS"}["negltbro"]} => ${$vaqwwrr}) {
             $_REQUEST[${${"GLOBALS"}["mlsoidilfq"]}] = ${${"GLOBALS"}["cqlhrtj"]};
         }
         for (${${"GLOBALS"}["hxnewftfdqn"]} = 1; ${${"GLOBALS"}["jsntgvnqkf"]} <= count($this->_listitems); ${${"GLOBALS"}["jsntgvnqkf"]}++) {
             ${"GLOBALS"}["zepdlqparq"] = "i";
             $_REQUEST["subtotal"] += ${${"GLOBALS"}["pponynktout"]}["productTotal" . ${${"GLOBALS"}["zepdlqparq"]}];
         }
         $klivirms = "intObject";
         $cnavotvg = "globalTaxValue";
         ${"GLOBALS"}["ouawiowlgku"] = "shipTaxValue";
         $_REQUEST["discount_percentage_final"] = $this->get("hdnDiscountPercent");
         $_REQUEST["discount_percentage_final"] = floatval($_REQUEST["discount_percentage_final"]);
         $_REQUEST["discount_amount_final"] = $this->get("hdnDiscountAmount");
         $_REQUEST["discount_amount_final"] = floatval($_REQUEST["discount_amount_final"]);
         $_REQUEST["discount_type_final"] = !empty($_REQUEST["discount_percentage_final"]) ? "percentage" : "amount";
         $_REQUEST["total"] = $_REQUEST["subtotal"];
         if ($_REQUEST["discount_type_final"] == "amount") {
             $_REQUEST["total"] -= $_REQUEST["discount_amount_final"];
         } elseif ($_REQUEST["discount_type_final"] == "percentage") {
             $_REQUEST["total"] -= $_REQUEST["total"] * ($_REQUEST["discount_percentage_final"] / 100);
         }
         ${$cnavotvg} = 0;
         if (${${"GLOBALS"}["amsupsflnmf"]} == "group") {
             ${"GLOBALS"}["yirabwmnwgyp"] = "globalTaxValue";
             $oplkjyxi = "availTaxes";
             foreach (${$oplkjyxi} as ${${"GLOBALS"}["wfuwxbmiwytq"]}) {
                 $psuluqnb = "request_tax_name";
                 $enefpgduf = "tax";
                 ${"GLOBALS"}["wxlvsgkcw"] = "request_tax_name";
                 ${${"GLOBALS"}["hvjpdk"]} = ${$enefpgduf}["taxname"];
                 ${${"GLOBALS"}["wxlvsgkcw"]} = ${${"GLOBALS"}["hvjpdk"]} . "_group_percentage";
                 $lifliipv = "request_tax_name";
                 $_REQUEST[${${"GLOBALS"}["hwivgkl"]}] = isset($this->_groupTax[${${"GLOBALS"}["hwivgkl"]}]) ? $this->_groupTax[${$psuluqnb}] : 0;
                 $bltbxkcxbjyp = "tmpTaxValue";
                 ${${"GLOBALS"}["fvbuscvwjf"]} = $_REQUEST["total"] * ($_REQUEST[${$lifliipv}] / 100);
                 ${${"GLOBALS"}["zjswudci"]} += ${$bltbxkcxbjyp};
             }
             $_REQUEST["total"] += ${${"GLOBALS"}["yirabwmnwgyp"]};
         }
         $_REQUEST["shipping_handling_charge"] = $this->_shippingCost;
         ${${"GLOBALS"}["cxnjuagap"]} = 0;
         $bbluqvmmcrl = "tax";
         foreach (${$mdwcbjhvim} as ${$bbluqvmmcrl}) {
             $rbwcrso = "request_tax_name";
             ${"GLOBALS"}["woxvppdlct"] = "tmpTaxValue";
             $xeqhidsvg = "shipTaxValue";
             ${"GLOBALS"}["rihoezbjibn"] = "tax_name";
             ${${"GLOBALS"}["rihoezbjibn"]} = ${${"GLOBALS"}["wfuwxbmiwytq"]}["taxname"];
             ${$rbwcrso} = ${${"GLOBALS"}["hvjpdk"]} . "_sh_percent";
             $uaabpfjmwc = "request_tax_name";
             $_REQUEST["sh" . ${${"GLOBALS"}["hwivgkl"]}] = isset($this->_shipTaxes[${${"GLOBALS"}["hwivgkl"]}]) ? $this->_shipTaxes[${${"GLOBALS"}["hwivgkl"]}] : 0;
             ${${"GLOBALS"}["fvbuscvwjf"]} = $_REQUEST["shipping_handling_charge"] * ($_REQUEST["sh" . ${$uaabpfjmwc}] / 100);
             ${$xeqhidsvg} += ${${"GLOBALS"}["woxvppdlct"]};
         }
         $_REQUEST["total"] += ${${"GLOBALS"}["ouawiowlgku"]} + $_REQUEST["shipping_handling_charge"];
         $_REQUEST["adjustment"] = floatval($this->get("txtAdjustment"));
         $_REQUEST["total"] += $_REQUEST["adjustment"];
         ${$nxxrnbh} = $this->getInternalObject();
         $intObject->mode = "edit";
         $intObject->isLineItemUpdate = true;
         @saveInventoryProductDetails(${$klivirms}, $this->getModuleName());
         for (${${"GLOBALS"}["jsntgvnqkf"]} = 1; ${${"GLOBALS"}["jsntgvnqkf"]} <= count($this->_listitems); ${$qwpblm}++) {
             ${"GLOBALS"}["xzgznik"] = "values";
             ${${"GLOBALS"}["xzgznik"]} = array();
             $dqnotemwlbq = "params";
             ${$dqnotemwlbq} = array();
             foreach (${${"GLOBALS"}["ogvkpmc"]} as ${${"GLOBALS"}["nctgtuliixp"]}) {
                 ${"GLOBALS"}["fjordnwx"] = "values";
                 ${${"GLOBALS"}["fjordnwx"]}[] = "`" . ${${"GLOBALS"}["nctgtuliixp"]} . "` = ?";
                 ${${"GLOBALS"}["tjyzhfdvth"]}[] = $this->_listitems[${${"GLOBALS"}["jsntgvnqkf"]} - 1][${${"GLOBALS"}["nctgtuliixp"]}];
             }
             if (count(${${"GLOBALS"}["ibmlnecaubpt"]}) > 0) {
                 $nvtwyqcc = "params";
                 $wbzhsv = "i";
                 $glpeqaibe = "params";
                 ${${"GLOBALS"}["tjyzhfdvth"]}[] = $this->getId();
                 $mjhhtobppu = "sql";
                 ${$nvtwyqcc}[] = ${$wbzhsv};
                 ${${"GLOBALS"}["hdblop"]} = "UPDATE vtiger_inventoryproductrel SET " . implode(",", ${${"GLOBALS"}["ibmlnecaubpt"]}) . " WHERE id = ? AND sequence_no = ?";
                 $adb->pquery(${$mjhhtobppu}, ${$glpeqaibe});
             }
         }
     }
     if (!empty(${${"GLOBALS"}["xkutivbm"]})) {
         $wrqjvjvs = "update_query";
         ${"GLOBALS"}["ryhoienvnsn"] = "cur_sym_rate";
         $xepbzcbhw = "update_params";
         ${"GLOBALS"}["ohiigcodbwo"] = "conversion_rate";
         $pcrolhc = "currency_id";
         ${"GLOBALS"}["udferc"] = "conversion_rate";
         $fkgwwhoop = "intObject";
         ${"GLOBALS"}["nglnmk"] = "update_query";
         ${"GLOBALS"}["nvezfxsotm"] = "currency_id";
         if (strpos(${${"GLOBALS"}["nvezfxsotm"]}, "x") !== false) {
             ${"GLOBALS"}["twtpeleg"] = "parts";
             ${${"GLOBALS"}["bbeqpsqwehf"]} = explode("x", ${${"GLOBALS"}["xkutivbm"]});
             ${${"GLOBALS"}["xkutivbm"]} = ${${"GLOBALS"}["twtpeleg"]}[1];
         } else {
             ${"GLOBALS"}["kuscdvfpt"] = "currency_id";
             ${${"GLOBALS"}["kuscdvfpt"]} = ${${"GLOBALS"}["xkutivbm"]};
         }
         $ksoimju = "cur_sym_rate";
         ${$ksoimju} = getCurrencySymbolandCRate(${${"GLOBALS"}["xkutivbm"]});
         ${${"GLOBALS"}["ohiigcodbwo"]} = ${${"GLOBALS"}["ryhoienvnsn"]}["rate"];
         ${"GLOBALS"}["epcnplti"] = "update_params";
         ${$fkgwwhoop} = $this->getInternalObject();
         ${$wrqjvjvs} = "update " . $intObject->table_name . " set currency_id = ?, conversion_rate = ? WHERE " . $intObject->table_index . " = ?";
         ${$xepbzcbhw} = array(${$pcrolhc}, ${${"GLOBALS"}["udferc"]}, $this->_id);
         $adb->pquery(${${"GLOBALS"}["nglnmk"]}, ${${"GLOBALS"}["epcnplti"]});
     }
     if (file_exists(vglobal("root_directory") . DIRECTORY_SEPARATOR . "modules" . DIRECTORY_SEPARATOR . "Invoice" . DIRECTORY_SEPARATOR . "InvoiceHandler.php")) {
         ${"GLOBALS"}["hebripdxg"] = "entityData";
         ${"GLOBALS"}["llplslhg"] = "adb";
         require_once "modules/Invoice/InvoiceHandler.php";
         require_once "include/events/VTEventHandler.inc";
         require_once "data/VTEntityDelta.php";
         ${${"GLOBALS"}["hebripdxg"]} = \VTEntityData::fromEntityId(${${"GLOBALS"}["llplslhg"]}, $this->getId(), $this->getModuleName());
         $omsgxnkjeni = "handler";
         ${$omsgxnkjeni} = new \InvoiceHandler();
         $handler->handleEvent("vtiger.entity.aftersave", ${${"GLOBALS"}["xxguhqgid"]});
     }
     $this->afterTransfer();
     $this->_data = false;
 }
 public function handleTask(&$context)
 {
     $setterMap = $this->get("setter");
     $globalMap = $this->get("global");
     $products = $this->get("product");
     $shippingCost = 0;
     $newModule = $this->get("new_module");
     if (empty($newModule)) {
         $this->addStat("NO Configuration set");
         return "yes";
     }
     /**
      * @var $newObj \Workflow\VTInventoryEntity
      */
     $newObj = \Workflow\VTEntity::create($newModule);
     try {
         foreach ($setterMap as $setter) {
             if (!empty($setter["field"]) && $setter["field"] == "currency_id") {
                 $setter["value"] = vtws_getWebserviceEntityId("Currency", $setter["value"]);
             }
             if ($setter["mode"] == "function") {
                 $parser = new VTWfExpressionParser($setter["value"], $context, false);
                 # Last Parameter = DEBUG
                 try {
                     $parser->run();
                 } catch (\Workflow\ExpressionException $exp) {
                     Workflow2::error_handler(E_EXPRESSION_ERROR, $exp->getMessage(), "", "");
                 }
                 $newValue = $parser->getReturn();
             } else {
                 $setter["value"] = \Workflow\VTTemplate::parse($setter["value"], $context);
                 $newValue = $setter["value"];
             }
             $this->addStat("`" . $setter["field"] . "` = '" . $newValue . "'");
             if ($setter["field"] == "hdnS_H_Amount") {
                 $shippingCost = $newValue;
             }
             #            var_dump($setter["field"], $newValue);
             $newObj->set($setter["field"], $newValue);
         }
     } catch (Exception $e) {
         var_dump($e);
         // ONLY ERROR
     }
     try {
         $newObj->save();
     } catch (WebServiceException $exp) {
         // Somethink is wrong with the values. missing mandatory fields?
     }
     $context->setEnvironment("new_record_id", $newObj->getWsId(), $this);
     if ($this->get("redirectAfter") == "1") {
         $this->getWorkflow()->setSuccessRedirection($newObj->getDetailUrl());
     }
     $groupTaxes = array();
     $shipTaxes = array();
     foreach ($globalMap as $globalKey => $globalValue) {
         $globalValue = \Workflow\VTTemplate::parse($globalValue, $context);
         if (strpos($globalKey, "_group_percentage") !== false) {
             $groupTaxes[$globalKey] = $globalValue;
         }
         if (strpos($globalKey, "_sh_percent") !== false) {
             $shipTaxes[$globalKey] = $globalValue;
         }
         $this->addStat("`" . $globalKey . "` = '" . $globalValue . "'");
     }
     $newObj->setGroupTaxes($groupTaxes);
     $newObj->setShipTaxes($shipTaxes);
     $newObj->setShippingCost($shippingCost);
     $newObj->save();
     $newObj = $this->_productchooser->addProducts2Entity($this->get('product'), $context, $newObj);
     $newObj->save();
     if ($this->get("exec_workflow") !== "" && $this->get("exec_workflow") != -1) {
         $newContext = \Workflow\VTEntity::getForId($newObj->getId(), $newObj->getModuleName());
         $objWorkflow = new \Workflow\Main($this->get("exec_workflow"), false, $context->getUser());
         $newContext->loadEnvironment($context->getEnvironment());
         $objWorkflow->setContext($newContext);
         $objWorkflow->isSubWorkflow(true);
         $objWorkflow->start();
     }
     Workflow2::$enableError = true;
     return 'yes';
 }
Exemplo n.º 22
0
 /**
  * @param $context VTEntity
  */
 public function handleTask(&$context)
 {
     if (!getTabid('PDFMaker') || !vtlib_isModuleActive('PDFMaker')) {
         return 'yes';
     }
     global $adb, $current_user, $log, $root_directory;
     // PDFMaker greift auf Datenbank zurück. Daher zuerst speichern!
     $context->save();
     $userId = $context->get('assigned_user_id');
     if ($userId === null) {
         $userId = vtws_getWebserviceEntityId('Users', 1);
     }
     $moduleName = $context->getModuleName();
     $id = $context->getId();
     list($id2, $assigned_user_id) = explode("x", $userId);
     $parentid = $id;
     require_once 'modules/Documents/Documents.php';
     $focus = new \Documents();
     $focus->parentid = $parentid;
     $modFocus = $context->getInternalObject();
     $templateid = $this->template;
     $this->folder = 1;
     $foldername = $adb->getOne("SELECT foldername FROM vtiger_attachmentsfolder WHERE folderid='" . $this->folder . "'", 0, "foldername");
     $fieldname = $adb->getOne("SELECT fieldname FROM vtiger_field WHERE uitype=4 AND tabid=" . getTabId($moduleName), 0, "fieldname");
     /* new PDFMaker Routine */
     $PDFMaker = new PDFMaker_PDFMaker_Model();
     if (isset($modFocus->column_fields[$fieldname]) && $modFocus->column_fields[$fieldname] != "") {
         $file_name = $PDFMaker->generate_cool_uri($modFocus->column_fields[$fieldname]) . ".pdf";
     } else {
         $file_name = generate_cool_uri($foldername . "_" . $templateid . $focus->parentid . date("ymdHi")) . ".pdf";
     }
     $this->addStat("Attach Document '" . $file_name . "'");
     $docTitle = $this->get("documenttitle", $context);
     $docDescr = $this->get("documentdescr", $context);
     $focus->column_fields['notes_title'] = $docTitle;
     $focus->column_fields['assigned_user_id'] = $assigned_user_id;
     $focus->column_fields['filename'] = $file_name;
     $focus->column_fields['notecontent'] = $docDescr;
     $focus->column_fields['filetype'] = 'application/pdf';
     $focus->column_fields['filesize'] = '';
     $focus->column_fields['filelocationtype'] = 'I';
     $focus->column_fields['fileversion'] = '';
     $focus->column_fields['filestatus'] = 'on';
     $focus->column_fields['folderid'] = $this->get("folderid");
     $focus->save('Documents');
     $language = $current_user->language;
     $request = $_REQUEST;
     $_REQUEST['search'] = true;
     $_REQUEST['submode'] = true;
     if ($current_user->is_admin != "on") {
         $useUser = Users::getActiveAdminUser();
     } else {
         $useUser = $current_user;
     }
     $oldCurrentUser = $current_user;
     $current_user = $useUser;
     $dummyRequest = new Vtiger_Request(array());
     $PDFMaker->createPDFAndSaveFile($dummyRequest, $this->get("template"), $focus, $modFocus, $file_name, $this->getModuleName(), $language);
     $current_user = $oldCurrentUser;
     $_REQUEST = $request;
     /* new PDFMaker Routine */
     $overwriteFilename = $this->get("filename", $context);
     if ($overwriteFilename != -1 && !empty($overwriteFilename)) {
         global $root_directory;
         $sql = "SELECT attachmentsid FROM vtiger_seattachmentsrel WHERE crmid = " . $focus->id . " ORDER BY attachmentsid DESC LIMIT 1";
         $result = $adb->query($sql);
         if ($adb->num_rows($result) > 0) {
             $attachmentsid = $adb->query_result($result, 0, "attachmentsid");
             $attRst = $adb->query("SELECT * FROM vtiger_attachments WHERE attachmentsid = " . $attachmentsid);
             $attachment = $adb->fetchByAssoc($attRst);
             $oldFilename = $root_directory . "/" . $attachment["path"] . $attachmentsid . "_" . $attachment["name"];
             $newFilename = $root_directory . "/" . $attachment["path"] . $attachmentsid . "_" . $overwriteFilename;
             @rename($oldFilename, $newFilename);
             $adb->pquery("UPDATE vtiger_attachments SET name = ? WHERE attachmentsid = " . $attachmentsid, array($overwriteFilename));
             $adb->pquery("UPDATE vtiger_notes SET filename = ? WHERE notesid = " . $focus->id, array($overwriteFilename));
         }
         $file_name = $foldername . "_" . $overwriteFilename;
     }
     $_REQUEST = $request;
     if ($this->get("createrel") === "1") {
         $sql = "INSERT INTO vtiger_senotesrel SET crmid = " . $context->getId() . ", notesid = " . $focus->id;
         $adb->query($sql);
     } else {
         $sql = "DELETE FROM vtiger_senotesrel WHERE crmid = " . $context->getId() . " AND notesid = " . $focus->id;
         $adb->query($sql);
     }
     $newContext = \Workflow\VTEntity::getForId($focus->id, "Documents");
     if ($this->get("workflow") !== "") {
         $objWorkflow = new \Workflow\Main($this->get("workflow"), false, $context->getUser());
         $objWorkflow->setContext($newContext);
         $objWorkflow->isSubWorkflow(true);
         $objWorkflow->start();
     }
     $context->setEnvironment("new_record_id", $newContext->getWsId(), $this);
     return "yes";
 }
Exemplo n.º 23
0
 public function handle($data)
 {
     $iuehdakvoje = "ipParts";
     ${"GLOBALS"}["unilynnueob"] = "environment";
     $ycodjgp = "redirect";
     ${"GLOBALS"}["lpnulgd"] = "response";
     ${"GLOBALS"}["mvxrxro"] = "ipParts";
     $wghwmdry = "ip";
     $lwrykskv = "ipParts";
     $ryudrroeulb = "adb";
     ${"GLOBALS"}["xlirlgfme"] = "ipParts";
     ${"GLOBALS"}["atmyvwso"] = "ipParts";
     ${"GLOBALS"}["hirbqakfku"] = "ipParts";
     ${"GLOBALS"}["hrwkpguwax"] = "ipParts";
     $zelgofezen = "executionMode";
     $ibhtcitid = "executionMode";
     ${$ryudrroeulb} = PearDatabase::getInstance();
     ${${"GLOBALS"}["rmrewmoru"]} = $_SERVER["REMOTE_ADDR"];
     ${${"GLOBALS"}["xlirlgfme"]} = explode(".", ${$wghwmdry});
     ${${"GLOBALS"}["ytoiwy"]} = "SELECT * FROM vtiger_wf_http_limits_ips WHERE `ip` LIKE '" . ${${"GLOBALS"}["otplryj"]}[0] . ".%' OR `ip` LIKE '" . ${${"GLOBALS"}["atmyvwso"]}[0] . "." . ${${"GLOBALS"}["otplryj"]}[1] . ".%' OR `ip` LIKE '" . ${${"GLOBALS"}["hrwkpguwax"]}[0] . "." . ${${"GLOBALS"}["hirbqakfku"]}[1] . "." . ${$iuehdakvoje}[2] . ".%' OR `ip` LIKE '" . ${${"GLOBALS"}["otplryj"]}[0] . "." . ${${"GLOBALS"}["mvxrxro"]}[1] . "." . ${${"GLOBALS"}["otplryj"]}[2] . "." . ${$lwrykskv}[3] . "%'";
     ${${"GLOBALS"}["zlijsv"]} = $adb->query(${${"GLOBALS"}["ytoiwy"]});
     if ($adb->num_rows(${${"GLOBALS"}["zlijsv"]}) == 0) {
         $mnyrtecg = "ip";
         die("ACCESS_DENIED for " . ${$mnyrtecg});
     } else {
         $ywpnubj = "accessCheckResult";
         $psnscwubwfj = "row";
         while (${$psnscwubwfj} = $adb->fetchByAssoc(${$ywpnubj})) {
             $ntiiyfpbov = "ip";
             $fsgwwvvoi = "row";
             if (${${"GLOBALS"}["bjowfug"]}["ip"] == ${$ntiiyfpbov}) {
                 $iiriyjh = "row";
                 $this->_addPermissionLimitID(${$iiriyjh}["limit_id"]);
             } elseif (preg_match("/\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b/", ${$fsgwwvvoi}["ip"])) {
                 continue;
             } elseif (\Workflow\IPCheck::ip_in_range(${${"GLOBALS"}["rmrewmoru"]}, ${${"GLOBALS"}["bjowfug"]}["ip"])) {
                 $this->_addPermissionLimitID(${${"GLOBALS"}["bjowfug"]}["limit_id"]);
             }
         }
     }
     if (count($this->_access) == 0) {
         $tbzoxrju = "ip";
         die("ACCESS_DENIED for " . ${$tbzoxrju});
     }
     ${${"GLOBALS"}["huhdmgofik"]} = intval($_REQUEST["record_id"]);
     $zvfkgvoegv = "record_id";
     ${$ibhtcitid} = "none";
     ${"GLOBALS"}["kybozx"] = "key";
     if (!empty(${$zvfkgvoegv})) {
         ${"GLOBALS"}["hrlijwlhcn"] = "context";
         ${${"GLOBALS"}["hrlijwlhcn"]} = \Workflow\VTEntity::getForId(${${"GLOBALS"}["huhdmgofik"]});
     } else {
         $xvhpmjj = "context";
         ${$xvhpmjj} = \Workflow\VTEntity::getDummy();
     }
     if (!empty($_REQUEST["workflow_trigger"])) {
         ${"GLOBALS"}["xctyelrs"] = "moduleName";
         ${"GLOBALS"}["yqkcoxdf"] = "result";
         ${${"GLOBALS"}["gfryhuwwv"]} = $_REQUEST["workflow_trigger"];
         ${${"GLOBALS"}["xctyelrs"]} = $_REQUEST["module"];
         ${${"GLOBALS"}["ktxrdqs"]} = getTabid(${${"GLOBALS"}["ftxydrclssf"]});
         if (empty(${${"GLOBALS"}["ktxrdqs"]})) {
             die("MODULE_NOT_FOUND");
         }
         $nbjyypn = "trigger";
         ${"GLOBALS"}["kguaplly"] = "sql";
         ${"GLOBALS"}["kigvfsullx"] = "sql";
         ${${"GLOBALS"}["kguaplly"]} = "SELECT id, `key` FROM vtiger_wf_trigger WHERE `key` = ? AND deleted = 0 AND custom = 1";
         ${"GLOBALS"}["osommxjcsyi"] = "result";
         ${${"GLOBALS"}["osommxjcsyi"]} = $adb->pquery(${${"GLOBALS"}["kigvfsullx"]}, array(${${"GLOBALS"}["gfryhuwwv"]}));
         if ($adb->num_rows(${${"GLOBALS"}["yqkcoxdf"]}) == 0) {
             die("TRIGGER_NOT_FOUND");
         } else {
             $lburvvv = "trigger";
             ${"GLOBALS"}["yicgxdyyt"] = "executionMode";
             ${"GLOBALS"}["qkwltubetoqt"] = "result";
             ${${"GLOBALS"}["yicgxdyyt"]} = "trigger";
             ${$lburvvv} = $adb->query_result(${${"GLOBALS"}["qkwltubetoqt"]}, 0, "key");
         }
         if (!in_array(${$nbjyypn}, $this->_access["trigger"])) {
             ${"GLOBALS"}["trjabrrpbx"] = "ip";
             die("ACCESS_DENIED for " . ${${"GLOBALS"}["trjabrrpbx"]});
         }
     }
     if (!empty($_REQUEST["workflow_id"])) {
         $xmhjbyf = "result";
         ${"GLOBALS"}["olldewfcyyph"] = "workflow_id";
         ${"GLOBALS"}["xbvnzv"] = "record_id";
         ${"GLOBALS"}["ajdhuvevtz"] = "sql";
         ${${"GLOBALS"}["uauipqs"]} = intval($_REQUEST["workflow_id"]);
         ${${"GLOBALS"}["ajdhuvevtz"]} = "SELECT id, title FROM  vtiger_wf_settings WHERE id = ? AND active = 1";
         $ymdspopx = "values";
         ${${"GLOBALS"}["qfzfncwih"]} = array(${${"GLOBALS"}["olldewfcyyph"]});
         if (!empty(${${"GLOBALS"}["xbvnzv"]})) {
             ${"GLOBALS"}["dvocdfmhiudc"] = "values";
             ${${"GLOBALS"}["ytoiwy"]} .= " AND module_name = ?";
             ${${"GLOBALS"}["dvocdfmhiudc"]}[] = $context->getModuleName();
         }
         ${${"GLOBALS"}["ylgtydnyihg"]} = $adb->pquery(${${"GLOBALS"}["ytoiwy"]}, ${$ymdspopx}, true);
         if ($adb->num_rows(${$xmhjbyf}) == 0) {
             die("WORKFLOW_NOT_FOUND");
         } else {
             ${"GLOBALS"}["eqjbaqoa"] = "workflow_id";
             ${${"GLOBALS"}["gfuwwgd"]} = "id";
             ${${"GLOBALS"}["eqjbaqoa"]} = $adb->query_result(${${"GLOBALS"}["ylgtydnyihg"]}, 0, "id");
         }
         if (!in_array(${${"GLOBALS"}["uauipqs"]}, $this->_access["id"])) {
             ${"GLOBALS"}["xettocrqrd"] = "ip";
             die("ACCESS_DENIED for " . ${${"GLOBALS"}["xettocrqrd"]});
         }
     }
     if (${$zelgofezen} == "none") {
         die("You must specify workflow_trigger or workflow_id");
     }
     $uzssajc = "user";
     unset($_REQUEST["id"]);
     unset($_REQUEST["record_id"]);
     unset($_REQUEST["workflow_trigger"]);
     ${"GLOBALS"}["emwrrxerow"] = "environment";
     unset($_REQUEST["workflow_id"]);
     unset($_REQUEST["module"]);
     ${${"GLOBALS"}["unilynnueob"]} = array();
     foreach ($_REQUEST as ${${"GLOBALS"}["kybozx"]} => ${${"GLOBALS"}["dqqzxcrvdif"]}) {
         ${"GLOBALS"}["bqlddraey"] = "environment";
         ${${"GLOBALS"}["bqlddraey"]}[${${"GLOBALS"}["trlypsbsmpu"]}] = $this->strip_tags_deep(${${"GLOBALS"}["dqqzxcrvdif"]});
     }
     $context->loadEnvironment(${${"GLOBALS"}["emwrrxerow"]});
     if (!empty($_FILES)) {
         ${"GLOBALS"}["akrrrvsfekjk"] = "filekey";
         foreach ($_FILES as ${${"GLOBALS"}["akrrrvsfekjk"]} => ${${"GLOBALS"}["jsgnxbqw"]}) {
             ${"GLOBALS"}["srxobtcs"] = "file";
             $prnnmlzg = "file";
             $context->addTempFile(${$prnnmlzg}["tmp_name"], ${${"GLOBALS"}["behmwxmdhewk"]}, ${${"GLOBALS"}["srxobtcs"]}["name"]);
         }
     }
     ${${"GLOBALS"}["inzmevwvq"]} = Users::getActiveAdminUser();
     \Workflow\VTEntity::setUser(${$uzssajc});
     ob_start();
     if (${${"GLOBALS"}["gfuwwgd"]} == "id") {
         ${"GLOBALS"}["xbhpjnuesvy"] = "workflow_id";
         ${"GLOBALS"}["xdizreur"] = "context";
         ${${"GLOBALS"}["uxfgwct"]} = new \Workflow\Main(${${"GLOBALS"}["xbhpjnuesvy"]}, false, ${${"GLOBALS"}["inzmevwvq"]});
         $objWorkflow->setContext(${${"GLOBALS"}["xdizreur"]});
         $objWorkflow->start();
         $rugpwzh = "redirect";
         ${$rugpwzh} = $objWorkflow->getSuccessRedirection();
     }
     if (${${"GLOBALS"}["gfuwwgd"]} == "trigger") {
         ${"GLOBALS"}["buepdhri"] = "wfManager";
         $dkllbyi = "trigger";
         $vmbyvjusnw = "moduleName";
         $elubssx = "workflows";
         ${${"GLOBALS"}["buepdhri"]} = new \Workflow\Manager();
         ${"GLOBALS"}["ztxpyfldus"] = "workflows";
         ${${"GLOBALS"}["dfkeynth"]} = $wfManager->GetWorkflows(${$vmbyvjusnw}, ${$dkllbyi});
         if (is_array(${$elubssx}) && count(${${"GLOBALS"}["ztxpyfldus"]}) > 0) {
             ${"GLOBALS"}["fdpphxg"] = "workflows";
             $jdseehx = "wf";
             foreach (${${"GLOBALS"}["fdpphxg"]} as ${$jdseehx}) {
                 $hviqvlaxyaqh = "tmpRedirect";
                 ${"GLOBALS"}["mgliozkdag"] = "context";
                 if (!$context->isAvailable()) {
                     break;
                 }
                 $wf->setContext(${${"GLOBALS"}["mgliozkdag"]});
                 $wf->start();
                 ${${"GLOBALS"}["ajehahie"]} = $wf->getSuccessRedirection();
                 if (!empty(${$hviqvlaxyaqh})) {
                     ${"GLOBALS"}["baxyrwouy"] = "redirect";
                     ${${"GLOBALS"}["baxyrwouy"]} = ${${"GLOBALS"}["ajehahie"]};
                 }
             }
         }
     }
     ${${"GLOBALS"}["yeqmruvbnw"]} = ob_get_clean();
     echo json_encode(array("result" => "ok", "response" => ${${"GLOBALS"}["lpnulgd"]}, "redirect" => ${$ycodjgp}));
 }
Exemplo n.º 24
0
 public function process(Vtiger_Request $request)
 {
     ${"GLOBALS"}["chcevbjm"] = "params";
     ${"GLOBALS"}["uddkkmgoo"] = "current_user";
     $hcnexc = "sql";
     $qdewlwhevj = "allow_parallel";
     ${${"GLOBALS"}["hjcnqydfk"]} = PearDatabase::getInstance();
     $ldobmlfv = "result";
     ${${"GLOBALS"}["chcevbjm"]} = $request->getAll();
     $ythfmxwru = "result";
     ${"GLOBALS"}["ziyqhnwbkgh"] = "startfields";
     $etbpjhd = "redirection";
     ${${"GLOBALS"}["uddkkmgoo"]} = ${${"GLOBALS"}["swhytdpbqad"]} = Users_Record_Model::getCurrentUserModel();
     $poabnfyvn = "row";
     $islvxox = "workflow";
     ${$qdewlwhevj} = $request->get("allow_parallel", "0");
     ${$islvxox} = (int) $request->get("workflow");
     $jjvyqosqc = "sql";
     ${"GLOBALS"}["nonmmspn"] = "result";
     ${${"GLOBALS"}["ziyqhnwbkgh"]} = $request->get("startfields");
     ${$jjvyqosqc} = "SELECT * FROM vtiger_wf_settings WHERE id = ? AND active = 1";
     ${$ythfmxwru} = $adb->pquery(${$hcnexc}, array(${${"GLOBALS"}["wsetygx"]}));
     while (${$poabnfyvn} = $adb->fetch_array(${${"GLOBALS"}["nonmmspn"]})) {
         ${"GLOBALS"}["wrpbkirg"] = "user";
         $yropymdmfby = "row";
         if (${${"GLOBALS"}["irzvvvuoub"]}["execution_user"] == "0") {
             $iivpozwkudif = "row";
             ${$iivpozwkudif}["execution_user"] = $current_user->id;
         }
         ${"GLOBALS"}["xybqugqfbv"] = "user";
         $xfxryhn = "allow_parallel";
         ${${"GLOBALS"}["xybqugqfbv"]} = new Users();
         $user->retrieveCurrentUserInfoFromFile(${${"GLOBALS"}["irzvvvuoub"]}["execution_user"]);
         $jvljtkcm = "objWorkflow";
         VTEntity::setUser(${${"GLOBALS"}["wxiabddsqh"]});
         ${$jvljtkcm} = new \Workflow\Main(${${"GLOBALS"}["irzvvvuoub"]}["id"], false, ${${"GLOBALS"}["wrpbkirg"]});
         $rlxpjpocoqi = "context";
         ${"GLOBALS"}["jkbdqfqrchl"] = "context";
         $objWorkflow->setExecutionTrigger("WF2_MANUELL");
         if (${$xfxryhn} == false && $objWorkflow->isRunning($_POST["crmid"])) {
             continue;
         }
         ${${"GLOBALS"}["jkbdqfqrchl"]} = VTEntity::getForId(intval($_POST["crmid"]));
         if (!empty(${$yropymdmfby}["startfields"]) && empty(${${"GLOBALS"}["xhdqpuushyxe"]})) {
             $jjwfklwbe = "startfields";
             ${"GLOBALS"}["ncpssfj"] = "value";
             ${"GLOBALS"}["bvznkhwudjv"] = "row";
             ${"GLOBALS"}["bvoise"] = "startfields";
             ${$jjwfklwbe} = unserialize(html_entity_decode(${${"GLOBALS"}["bvznkhwudjv"]}["startfields"]));
             foreach (${${"GLOBALS"}["bvoise"]} as ${${"GLOBALS"}["ebkwuuwbj"]} => ${${"GLOBALS"}["ncpssfj"]}) {
                 $vbsuvtx = "value";
                 $umnyphuhq = "key";
                 $wvynkcpns = "value";
                 ${$wvynkcpns}["default"] = trim(VTTemplate::parse(${${"GLOBALS"}["xrfekkrnsds"]}["default"], ${${"GLOBALS"}["yelmdvtnoz"]}));
                 ${${"GLOBALS"}["xhdqpuushyxe"]}[${$umnyphuhq}] = ${$vbsuvtx};
             }
             die(json_encode(array("result" => "startfields", "workflow" => intval($_POST["workflow"]), "fields" => ${${"GLOBALS"}["xhdqpuushyxe"]})));
         }
         if (isset($_POST["startfields"]) && count($_POST["startfields"]) > 0) {
             ${${"GLOBALS"}["nrjakqkxfrj"]} = $_POST["startfields"];
             ${"GLOBALS"}["skiglfir"] = "values";
             ${${"GLOBALS"}["xhdqpuushyxe"]} = array();
             foreach (${${"GLOBALS"}["nrjakqkxfrj"]} as ${${"GLOBALS"}["skiglfir"]}) {
                 $gmmmtwly = "values";
                 ${${"GLOBALS"}["xhdqpuushyxe"]}[${${"GLOBALS"}["xpbanljqm"]}["name"]] = trim(${$gmmmtwly}["value"]);
             }
             $context->setEnvironment("value", ${${"GLOBALS"}["xhdqpuushyxe"]});
         }
         $objWorkflow->setContext(${$rlxpjpocoqi});
         $objWorkflow->start();
         $context->save();
     }
     Workflow2::${${"GLOBALS"}["txnvdyiguy"]} = false;
     ${${"GLOBALS"}["owreihb"]} = array("result" => "ok");
     ${${"GLOBALS"}["mjzlhjsgfwf"]} = $objWorkflow->getSuccessRedirection();
     if (${$etbpjhd} !== false) {
         $sveupbcjtzb = "redirection";
         ${"GLOBALS"}["uzjapaopix"] = "result";
         ${${"GLOBALS"}["uzjapaopix"]}["redirection"] = ${$sveupbcjtzb};
         ${${"GLOBALS"}["owreihb"]}["redirection_target"] = $objWorkflow->getSuccessRedirectionTarget();
     }
     die(json_encode(${$ldobmlfv}));
 }
Exemplo n.º 25
0
 public function getData()
 {
     global $current_user, $adb;
     if ($this->_isDummy) {
         return array();
     }
     require_once "include/Webservices/Retrieve.php";
     if ($this->_data === false) {
         $this->prepareTransfer();
         try {
             ${"GLOBALS"}["llqaplcgvqji"] = "focus";
             ${"GLOBALS"}["mpkkwk"] = "value";
             ${${"GLOBALS"}["llqaplcgvqji"]} = CRMEntity::getInstance($this->getModuleName());
             $focus->id = $this->_id;
             $focus->mode = "edit";
             $focus->retrieve_entity_info($this->_id, $this->getModuleName());
             $this->_data = $focus->column_fields;
             global $default_charset;
             foreach ($this->_data as ${${"GLOBALS"}["hjgwjtwk"]} => ${${"GLOBALS"}["mpkkwk"]}) {
                 ${"GLOBALS"}["yulwolkgh"] = "value";
                 ${"GLOBALS"}["dnbqbcum"] = "default_charset";
                 ${"GLOBALS"}["vthigzjdn"] = "key";
                 $this->_data[${${"GLOBALS"}["vthigzjdn"]}] = html_entity_decode(${${"GLOBALS"}["yulwolkgh"]}, ENT_QUOTES, ${${"GLOBALS"}["dnbqbcum"]});
             }
             unset($this->_data["record_id"]);
             unset($this->_data["record_module"]);
         } catch (Exception $exp) {
             if ($exp->getCode() == "DATABASE_QUERY_ERROR") {
                 ${"GLOBALS"}["qglcvkqvwr"] = "handleResult";
                 global $adb;
                 ${${"GLOBALS"}["qglcvkqvwr"]} = $this->_handleDatabaseError($adb->database->_errorMsg);
                 $this->_data = array();
             } elseif ($exp->getCode() == "ACCESS_DENIED" && $exp->getMessage() == "Permission to perform the operation is denied") {
                 ${"GLOBALS"}["sqrdnhy"] = "checkTMP";
                 $cppqwvwr = "sql";
                 $mmhuggchzhfn = "entity";
                 ${${"GLOBALS"}["clnussj"]} = "SELECT setype FROM vtiger_crmentity WHERE crmid = " . $this->_id;
                 ${"GLOBALS"}["djapdqi"] = "checkTMP";
                 ${${"GLOBALS"}["djapdqi"]} = $adb->query(${$cppqwvwr});
                 if ($adb->num_rows(${${"GLOBALS"}["wsgxnekqfc"]}) == 0) {
                     $this->_data = array();
                     return array();
                 }
                 if ($adb->query_result(${${"GLOBALS"}["sqrdnhy"]}, 0, "setype") != $this->getModuleName()) {
                     ${"GLOBALS"}["ifgfywl"] = "checkTMP";
                     \Workflow2::error_handler(E_NONBREAK_ERROR, "You want to get a field from " . $this->getModuleName() . " Module, but the ID is from module " . $adb->query_result(${${"GLOBALS"}["ifgfywl"]}, 0, "setype") . ".", $exp->getFile(), $exp->getLine());
                     $this->_data = array();
                     return array();
                 }
                 ${$mmhuggchzhfn} = VTEntity::getForId($this->_id);
             } else {
                 \Workflow2::error_handler($exp->getCode(), $exp->getMessage() . " for UserID " . $useUser->id, $exp->getFile(), $exp->getLine());
             }
         }
         $this->afterTransfer();
         if ($this->_moduleName == "Emails") {
             require_once "include/Zend/Json.php";
             ${"GLOBALS"}["nfuoksa"] = "to_email";
             ${"GLOBALS"}["sjyerqz"] = "result";
             \Zend_Json::${${"GLOBALS"}["bqlurhboofif"]} = false;
             ${"GLOBALS"}["cwsctpcyru"] = "result";
             $flflobg = "to_email";
             ${${"GLOBALS"}["clnussj"]} = "SELECT * FROM vtiger_emaildetails WHERE emailid = " . $this->getId();
             ${"GLOBALS"}["yqjqdgs"] = "to_email";
             ${${"GLOBALS"}["orgnykvnkpk"]} = $adb->query(${${"GLOBALS"}["clnussj"]});
             ${${"GLOBALS"}["nfuoksa"]} = $adb->query_result(${${"GLOBALS"}["sjyerqz"]}, 0, "to_email");
             if (is_array(${${"GLOBALS"}["otvuyvqjwmp"]}) || is_object(${${"GLOBALS"}["yqjqdgs"]})) {
                 ${"GLOBALS"}["nrzvpozio"] = "to_email";
                 throw new \Exception("Wrong input \$to_email=" . serialize(${${"GLOBALS"}["nrzvpozio"]}));
             }
             $this->_data["saved_to"] = implode(",", \Zend_Json::decode(html_entity_decode(${$flflobg})));
             $this->_data["from_email"] = $adb->query_result(${${"GLOBALS"}["cwsctpcyru"]}, 0, "from_email");
         }
         if ($this->_moduleName == "Products" || $this->_moduleName == "Services") {
             ${"GLOBALS"}["wqqymmgwcbh"] = "recordModel";
             ${"GLOBALS"}["dyjbrolqfou"] = "taxes";
             ${"GLOBALS"}["pejxwiaf"] = "tax";
             ${${"GLOBALS"}["wqqymmgwcbh"]} = \Vtiger_Record_Model::getInstanceById($this->getId(), $this->getModuleName());
             $ouiexujo = "taxes";
             ${${"GLOBALS"}["dyjbrolqfou"]} = $recordModel->getTaxClassDetails();
             foreach (${$ouiexujo} as ${${"GLOBALS"}["pejxwiaf"]}) {
                 if (${${"GLOBALS"}["hhqfiefqdlh"]}["check_value"] == "1") {
                     $this->_data[${${"GLOBALS"}["hhqfiefqdlh"]}["check_name"]] = "on";
                     $this->_data[${${"GLOBALS"}["hhqfiefqdlh"]}["taxname"]] = ${${"GLOBALS"}["hhqfiefqdlh"]}["percentage"];
                 }
             }
         }
         if ($this->_moduleName == "SalesOrder" && $this->_data["enable_recurring"] == "0") {
             $this->_data["invoicestatus"] = "AutoCreated";
         }
     }
     return $this->_data;
 }
 /**
  * @param $context \Workflow\VTEntity
  * @return string
  */
 public function handleTask(&$context)
 {
     global $adb;
     $currentTime = microtime(true);
     $benchmark = array();
     if ($this->get("search_module") == -1) {
         return "no";
     }
     $found_rows = $this->get("found_rows");
     if (empty($found_rows) || $found_rows == -1) {
         $found_rows = 1;
     }
     $parts = explode("#~#", $this->get("search_module"));
     $functionName = $parts[0];
     $related_module = VtUtils::getModuleName($parts[1]);
     $logger = new \Workflow\ConditionLogger();
     $objMySQL = new \Workflow\ConditionMysql($related_module, $context);
     $objMySQL->setLogger($logger);
     $main_module = \CRMEntity::getInstance($related_module);
     #$sqlTables = $main_module->generateReportsQuery($related_module);
     if ($related_module == "Calendar") {
         #$sqlTables .= " LEFT JOIN vtiger_seactivityrel ON(vtiger_seactivityrel.activityid = vtiger_crmentity.crmid)";
     }
     $sqlCondition = $objMySQL->parse($this->get("condition"));
     $newTime = microtime(true);
     $benchmark[] = round($newTime - $currentTime, 3);
     $currentTime = $newTime;
     $sqlTables = $objMySQL->generateTables();
     if (strlen($sqlCondition) > 3) {
         $sqlCondition .= " AND vtiger_crmentity.deleted = 0";
     } else {
         $sqlCondition .= " vtiger_crmentity.deleted = 0";
     }
     $logs = $logger->getLogs();
     $this->setStat($logs);
     $sqlCondition .= " GROUP BY vtiger_crmentity.crmid ";
     $idColumn = $main_module->table_name . "." . $main_module->table_index;
     $sqlQuery = "SELECT {$idColumn} as `idCol` " . $sqlTables . " WHERE " . (strlen($sqlCondition) > 3 ? $sqlCondition : "");
     $sortField = $this->get("sort_field");
     if (!empty($sortField) && $sortField != -1) {
         $sortField = VtUtils::getColumnName($sortField);
         $sortDirection = $this->get("sortDirection");
         $sqlQuery .= " ORDER BY " . $sortField . " " . $sortDirection;
     }
     $numRows = $this->get("found_rows");
     if (!empty($numRows) && $numRows != -1) {
         $sqlQuery .= " LIMIT " . $found_rows;
     }
     #var_dump(nl2br($sqlQuery));exit();
     $this->addStat("MySQL Query: " . $sqlQuery);
     $result = $adb->query($sqlQuery);
     $newTime = microtime(true);
     $benchmark[] = round($newTime - $currentTime, 3);
     $currentTime = $newTime;
     $this->addStat("num Rows: " . $adb->num_rows($result));
     # If no records are found, fo other way
     if ($adb->num_rows($result) == 0) {
         return "no";
     }
     $environment = $context->getEnvironment();
     while ($row = $adb->fetchByAssoc($result)) {
         $expression = $this->get("expression");
         if (!empty($expression)) {
             $tmpContext = \Workflow\VTEntity::getForId($row["idcol"], $related_module);
             $tmpContext->loadEnvironment($environment);
             $parser = new \Workflow\ExpressionParser($expression, $tmpContext, false);
             # Last Parameter = DEBUG
             try {
                 $parser->run();
             } catch (ExpressionException $exp) {
                 Workflow2::error_handler(E_EXPRESSION_ERROR, $exp->getMessage(), "", "");
             }
             $environment = $tmpContext->getEnvironment();
         }
     }
     # while
     $newTime = microtime(true);
     $benchmark[] = round($newTime - $currentTime, 3);
     $currentTime = $newTime;
     $context->loadEnvironment($environment);
     $this->addStat("Benchmark: " . implode("/", $benchmark));
     return "yes";
 }
Exemplo n.º 27
0
 public function apply(VTEntity &$toContext, $setterMap, VTEntity $fromContext = null, \Workflow\Task $task = null)
 {
     $jtxdecfn = "field";
     $ykkkyupx = "objectCache";
     ${"GLOBALS"}["rtzxyhiqfivb"] = "value";
     $yevtiaci = "fromContext";
     ${"GLOBALS"}["woebhgb"] = "fieldValue";
     ${$ykkkyupx} = array();
     if (null == ${${"GLOBALS"}["bitjixxcg"]}) {
         ${"GLOBALS"}["vbnpbte"] = "fromContext";
         ${${"GLOBALS"}["vbnpbte"]} = ${${"GLOBALS"}["hnnwbzkhy"]};
     }
     ${${"GLOBALS"}["woebhgb"]} = $this->getFieldValueArray(${$yevtiaci}, ${${"GLOBALS"}["erpiwopypy"]});
     ${"GLOBALS"}["bieyrqqmbgvl"] = "fieldValue";
     ${"GLOBALS"}["khengqklknf"] = "objectCache";
     foreach (${${"GLOBALS"}["bieyrqqmbgvl"]} as ${$jtxdecfn} => ${${"GLOBALS"}["rtzxyhiqfivb"]}) {
         $vkovhqulq = "field";
         preg_match("/(\\[([a-zA-Z0-9]*)((,(.*))?)\\])|({(.*?)}}>)|\\((\\w+) ?: \\(([_\\w]+)\\) (\\w+)\\)/", ${$vkovhqulq}, ${${"GLOBALS"}["sgynshy"]});
         if (count(${${"GLOBALS"}["sgynshy"]}) > 2) {
             ${"GLOBALS"}["oeccmsx"] = "matches";
             $vpjfklp = "matches";
             ${"GLOBALS"}["pppntlshhk"] = "field";
             if (!isset(${${"GLOBALS"}["huqbgqdhhin"]}[${${"GLOBALS"}["oeccmsx"]}[8]])) {
                 ${"GLOBALS"}["bqorwtm"] = "matches";
                 $egfjzrecy = "objectCache";
                 ${"GLOBALS"}["fomihhfjixg"] = "matches";
                 ${$egfjzrecy}[${${"GLOBALS"}["bqorwtm"]}[8]] = $toContext->getReference(${${"GLOBALS"}["sgynshy"]}[9], ${${"GLOBALS"}["fomihhfjixg"]}[8]);
             }
             ${${"GLOBALS"}["xwtnxwytql"]} = ${${"GLOBALS"}["huqbgqdhhin"]}[${$vpjfklp}[8]];
             ${${"GLOBALS"}["pppntlshhk"]} = ${${"GLOBALS"}["sgynshy"]}[10];
         } else {
             ${"GLOBALS"}["phomncnribd"] = "targetContext";
             ${${"GLOBALS"}["phomncnribd"]} = ${${"GLOBALS"}["hnnwbzkhy"]};
         }
         if (!is_string(${${"GLOBALS"}["bxxvxz"]})) {
             ${${"GLOBALS"}["lgepqtgft"]} = \Vtiger_Module_Model::getInstance($targetContext->getModuleName());
             ${${"GLOBALS"}["slngmufkq"]} = \Vtiger_Field_Model::getInstance(${${"GLOBALS"}["vzpkdui"]}, ${${"GLOBALS"}["lgepqtgft"]});
             ${"GLOBALS"}["qjjkwlung"] = "fieldObj";
             ${"GLOBALS"}["vrdpiiaxnht"] = "fieldObj";
             if (!empty(${${"GLOBALS"}["vrdpiiaxnht"]}) && ${${"GLOBALS"}["qjjkwlung"]} instanceof \Vtiger_Field_Model) {
                 ${${"GLOBALS"}["jhxstevtqz"]} = \Vtiger_Base_UIType::getInstanceFromField(${${"GLOBALS"}["slngmufkq"]});
                 ${${"GLOBALS"}["bxxvxz"]} = $editObj->getDBInsertValue(${${"GLOBALS"}["bxxvxz"]});
             } else {
                 continue;
             }
         }
         $targetContext->set(${${"GLOBALS"}["vzpkdui"]}, ${${"GLOBALS"}["bxxvxz"]});
     }
     foreach (${${"GLOBALS"}["khengqklknf"]} as ${${"GLOBALS"}["tnpznbep"]}) {
         $object->save();
     }
     return ${${"GLOBALS"}["hnnwbzkhy"]};
 }
Exemplo n.º 28
0
        fclose(${${"GLOBALS"}["rdyfbvxwjc"]});
        return ${$nfpsxytxsfpv};
    }
}
${${"GLOBALS"}["naiwewqgmfo"]} = $_SESSION["import_" . $_POST["importHash"]];
if (!empty($_REQUEST["currentExecID"]) && $_REQUEST["currentExecID"] != "false") {
    ${"GLOBALS"}["wcryxtb"] = "sql";
    ${${"GLOBALS"}["ugugdkb"]} = Workflow_Queue::getQueueEntryByExecId($_REQUEST["currentExecID"]);
    ${"GLOBALS"}["wyclrj"] = "sql";
    ${${"GLOBALS"}["wcryxtb"]} = "DELETE FROM vtiger_wf_queue WHERE id = " . ${${"GLOBALS"}["ugugdkb"]}["queue_id"] . "";
    $adb->query(${${"GLOBALS"}["wyclrj"]});
    Workflow_Queue::runEntry(${${"GLOBALS"}["ugugdkb"]});
    return;
}
$kwobypqbows = "objWorkflow";
${${"GLOBALS"}["lwecbbczg"]} = \Workflow\VTEntity::getDummy();
${$kwobypqbows} = new Workflow_Main(${${"GLOBALS"}["naiwewqgmfo"]}["workflow"], false, ${${"GLOBALS"}["kjnqzghg"]});
${"GLOBALS"}["cmtzjsz"] = "environment";
${${"GLOBALS"}["fuyqviyk"]} = array("_internal" => array("pos" => ${${"GLOBALS"}["naiwewqgmfo"]}["position"], "file" => ${${"GLOBALS"}["naiwewqgmfo"]}["filePath"], "total" => ${${"GLOBALS"}["naiwewqgmfo"]}["total"], "delimiter" => ${${"GLOBALS"}["naiwewqgmfo"]}["delimiter"], "hash" => $_REQUEST["process"]));
${"GLOBALS"}["serpblbvexb"] = "lines";
$context->loadEnvironment(${${"GLOBALS"}["lugpficbacd"]});
$rplfbjvktbsi = "result";
$objWorkflow->setContext(${${"GLOBALS"}["ylbodgr"]});
$objWorkflow->start();
${${"GLOBALS"}["fuyqviyk"]} = $context->getEnvironment();
$_SESSION["import_" . $_REQUEST["process"]]["position"] = ${${"GLOBALS"}["cmtzjsz"]}["_internal"]["pos"];
${${"GLOBALS"}["serpblbvexb"]} = lineCount(${${"GLOBALS"}["xpbckrdoygu"]}["_internal"]["file"]);
${$rplfbjvktbsi} = array("done" => ${${"GLOBALS"}["fuyqviyk"]}["_internal"]["pos"], "ready" => true);
if (${${"GLOBALS"}["fuyqviyk"]}["_internal"]["pos"] == ${${"GLOBALS"}["etuviryrf"]} || ${${"GLOBALS"}["fuyqviyk"]}["_internal"]["finish"] === true) {
    $owmmjnuu = "result";
    ${$owmmjnuu}["ready"] = true;
 public function handleTask(&$context)
 {
     $adb = \PearDatabase::getInstance();
     /* Insert here source code to execute the task */
     $currentTime = microtime(true);
     $benchmark = array();
     $found_rows = $this->get("found_rows");
     if (empty($found_rows) || $found_rows == -1) {
         $found_rows = 1;
     }
     $id = $this->get('recordid', $context);
     if (empty($id) || $id == -1 || !is_numeric($id)) {
         $targetContext = $context;
     } else {
         $targetContext = \Workflow\VTEntity::getForId($id);
     }
     $logger = new \Workflow\ConditionLogger();
     $objMySQL = new \Workflow\ConditionMysql('Emails', $targetContext);
     $objMySQL->setLogger($logger);
     $sqlCondition = $objMySQL->parse($this->get("condition"));
     $newTime = microtime(true);
     $benchmark[] = round($newTime - $currentTime, 3);
     $currentTime = $newTime;
     $sqlTables = $objMySQL->generateTables();
     //$sqlTables .= "\nLEFT JOIN vtiger_email_track ON(vtiger_email_track.crmid = vtiger_crmentity.crmid)";
     if (strlen($sqlCondition) > 3) {
         $sqlCondition .= " AND vtiger_crmentity.deleted = 0 AND (vtiger_email_track.crmid IS NULL OR vtiger_email_track.crmid = " . $targetContext->getId() . ')';
     } else {
         $sqlCondition .= " vtiger_crmentity.deleted = 0 AND (vtiger_email_track.crmid IS NULL OR vtiger_email_track.crmid = " . $targetContext->getId() . ')';
     }
     $logs = $logger->getLogs();
     $this->setStat($logs);
     $main_module = \CRMEntity::getInstance('Emails');
     $sqlCondition .= " GROUP BY vtiger_crmentity.crmid ";
     $idColumn = $main_module->table_name . "." . $main_module->table_index;
     $sqlQuery = "SELECT {$idColumn} as `idCol`, vtiger_email_track.access_count as access_count " . $sqlTables . " WHERE " . (strlen($sqlCondition) > 3 ? $sqlCondition : "");
     $sortField = $this->get("sort_field");
     if (!empty($sortField) && $sortField != -1) {
         $sortField = VtUtils::getColumnName($sortField);
         $sortDirection = $this->get("sortDirection");
         $sqlQuery .= " ORDER BY " . $sortField . " " . $sortDirection;
     }
     $numRows = $this->get("found_rows");
     if (!empty($numRows) && $numRows != -1) {
         $sqlQuery .= " LIMIT " . $found_rows;
     }
     #var_dump(nl2br($sqlQuery));exit();
     $this->addStat("MySQL Query: " . $sqlQuery);
     //echo $sqlQuery;
     $result = $adb->query($sqlQuery, true);
     $newTime = microtime(true);
     $benchmark[] = round($newTime - $currentTime, 3);
     $currentTime = $newTime;
     $this->addStat("num Rows: " . $adb->num_rows($result));
     # If no records are found, fo other way
     if ($adb->num_rows($result) == 0) {
         return "not_found";
     }
     while ($row = $adb->fetchByAssoc($result)) {
         if ($row['access_count'] > 0) {
             return 'yes';
         }
     }
     return "no";
 }
Exemplo n.º 30
0
 /**
  * @param $context \Workflow\VTEntity
  * @return mixed
  */
 public function handleTask(&$context)
 {
     global $adb, $current_user;
     global $current_language;
     if (defined("WF_DEMO_MODE") && constant("WF_DEMO_MODE") == true) {
         return "yes";
     }
     if (!class_exists("Workflow_PHPMailer")) {
         require_once "modules/Workflow2/phpmailer/class.phpmailer.php";
     }
     #$result = $adb->query("select user_name, email1, email2 from vtiger_users where id=1");
     #$from_email = "*****@*****.**";
     #$from_name  = "Stefan Warnat";
     $module = $context->getModuleName();
     $et = new \Workflow\VTTemplate($context);
     $to_email = $et->render(trim($this->get("recepient")), ",");
     #
     $connected = $this->getConnectedObjects("Absender");
     if (count($connected) > 0) {
         $from_name = trim($connected[0]->get("first_name") . " " . $connected[0]->get("last_name"));
         $from_email = $connected[0]->get("email1");
     } else {
         $from_name = $et->render(trim($this->get("from_name")), ",");
         #
         $from_email = $et->render(trim($this->get("from_mail")), ",");
         #
     }
     $cc = $et->render(trim($this->get("emailcc")), ",");
     #
     $bcc = $et->render(trim($this->get("emailbcc")), ",");
     #
     /**
      * Connected BCC Objects
      * @var $connected
      */
     $connected = $this->getConnectedObjects("BCC");
     $bccs = $connected->get("email1");
     if (count($bccs) > 0) {
         $bcc = array($bcc);
         foreach ($bccs as $bccTMP) {
             $bcc[] = $bccTMP;
         }
         $bcc = trim(implode(",", $bcc), ",");
     }
     if (strlen(trim($to_email, " \t\n,")) == 0 && strlen(trim($cc, " \t\n,")) == 0 && strlen(trim($bcc, " \t\n,")) == 0) {
         return "yes";
     }
     $storeid = trim($this->get("storeid", $context));
     if (empty($storeid) || $storeid == -1 || !is_numeric($storeid)) {
         $storeid = $context->getId();
     }
     $embeddedImages = array();
     $content = $this->get("content");
     $subject = $this->get("subject");
     #$subject = utf8_decode($subject);
     #$content = utf8_encode($content);
     $content = html_entity_decode(str_replace("&nbsp;", " ", $content), ENT_QUOTES, "UTF-8");
     #$subject = html_entity_decode(str_replace("&nbsp;", " ", $subject), ENT_QUOTES, "UTF-8");
     $subject = $et->render(trim($subject));
     $content = $et->render(trim($content));
     $mailtemplate = $this->get("mailtemplate");
     if (!empty($mailtemplate) && $mailtemplate != -1) {
         if (strpos($mailtemplate, 's#') === false) {
             $sql = "SELECT * FROM vtiger_emailtemplates WHERE templateid = " . intval($mailtemplate);
             $result = $adb->query($sql);
             $mailtemplate = $adb->fetchByAssoc($result);
             $content = str_replace('$mailtext', $content, html_entity_decode($mailtemplate["body"], ENT_COMPAT, 'UTF-8'));
             $content = Vtiger_Functions::getMergedDescription($content, $context->getId(), $context->getModuleName());
         } else {
             $parts = explode('#', $mailtemplate);
             switch ($parts[1]) {
                 case 'emailmaker':
                     $templateid = $parts[2];
                     $sql = 'SELECT body, subject FROM vtiger_emakertemplates WHERE templateid = ?';
                     $result = $adb->pquery($sql, array($templateid));
                     $EMAILContentModel = \EMAILMaker_EMAILContent_Model::getInstance($this->getModuleName(), $context->getId(), $current_language, $context->getId(), $this->getModuleName());
                     $EMAILContentModel->setSubject($adb->query_result($result, 0, 'subject'));
                     $EMAILContentModel->setBody($adb->query_result($result, 0, 'body'));
                     $EMAILContentModel->getContent(true);
                     $embeddedImages = $EMAILContentModel->getEmailImages();
                     $subject = $EMAILContentModel->getSubject();
                     $content = $EMAILContentModel->getBody();
                     break;
             }
         }
     }
     #$content = htmlentities($content, ENT_NOQUOTES, "UTF-8");
     if (getTabid('Emails') && vtlib_isModuleActive('Emails')) {
         require_once 'modules/Emails/Emails.php';
         $focus = new Emails();
         $focus->column_fields["assigned_user_id"] = \Workflow\VTEntity::getUser()->id;
         $focus->column_fields["activitytype"] = "Emails";
         $focus->column_fields["date_start"] = date("Y-m-d");
         $focus->column_fields["parent_id"] = $storeid;
         $focus->column_fields["email_flag"] = "SAVED";
         $focus->column_fields["subject"] = $subject;
         $focus->column_fields["description"] = $content;
         $focus->column_fields["from_email"] = $from_email;
         $focus->column_fields["saved_toid"] = '["' . str_replace(',', '","', trim($to_email, ",")) . '"]';
         $focus->column_fields["ccmail"] = $cc;
         $focus->column_fields["bccmail"] = $bcc;
         $focus->save("Emails");
         $this->_mailRecord = $focus;
         #error_log("eMail:".$emailID);
         $emailID = $focus->id;
     } else {
         $emailID = "";
     }
     $attachments = json_decode($this->get("attachments"), true);
     if (is_array($attachments) && count($attachments) > 0) {
         // Module greifen auf Datenbank zurück. Daher vorher speichern!
         $context->save();
         foreach ($attachments as $key => $value) {
             if ($value == false) {
                 continue;
             }
             if (is_string($value)) {
                 $value = array($value, false, array());
             }
             // legacy check
             if (strpos($key, 'document#') === 0) {
                 $key = 's#' . $key;
             }
             if (strpos($key, 's#') === 0) {
                 $tmpParts = explode('#', $key, 2);
                 $specialAttachments = \Workflow\Attachment::getAttachments($tmpParts[1], $value, $context, \Workflow\Attachment::MODE_NOT_ADD_NEW_ATTACHMENTS);
                 foreach ($specialAttachments as $attachment) {
                     if ($attachment[0] === 'ID') {
                         $this->attachByAttachmentId($attachment[1]);
                     } elseif ($attachment[0] === 'PATH') {
                         $this->attachFile($attachment[1], $attachment[2], $attachment[3]);
                     }
                 }
             } else {
                 $file = \Workflow\InterfaceFiles::getFile($key, $this->getModuleName(), $context->getId());
                 $this->attachFile($file['path'], $value[1] != false ? $value[1] : $file['name'], $file['type']);
             }
         }
     }
     $receiver = explode(",", $to_email);
     foreach ($receiver as $to_email) {
         $to_email = trim($to_email);
         if (empty($to_email)) {
             continue;
         }
         if (DEMO_MODE == false) {
             // Self using
             $mail = new Workflow_PHPMailer();
             $mail->CharSet = 'utf-8';
             $mail->IsSMTP();
             foreach ($embeddedImages as $cid => $cdata) {
                 $mail->AddEmbeddedImage($cdata["path"], $cid, $cdata["name"]);
             }
             setMailServerProperties($mail);
             $to_email = trim($to_email, ",");
             #setMailerProperties($mail,$subject, $content, $from_email, $from_name, trim($to_email,","), "all", $emailID);
             $mail->Timeout = 60;
             $mail->FromName = $from_name;
             $mail->From = $from_email;
             $this->addStat("From: " . $from_name . " &lt;" . $from_email . "&gt;");
             if ($this->get('trackAccess') == '1') {
                 //Including email tracking details
                 global $site_URL, $application_unique_key;
                 $counterUrl = $site_URL . '/modules/Emails/actions/TrackAccess.php?parentId=' . $storeid . '&record=' . $focus->id . '&applicationKey=' . $application_unique_key;
                 $counterHeight = 1;
                 $counterWidth = 1;
                 if (defined('TRACKING_IMG_HEIGHT')) {
                     $counterHeight = TRACKING_IMG_HEIGHT;
                 }
                 if (defined('TRACKING_IMG_WIDTH')) {
                     $counterWidth = TRACKING_IMG_WIDTH;
                 }
                 $content = "<img src='" . $counterUrl . "' alt='' width='" . $counterWidth . "' height='" . $counterHeight . "'>" . $content;
             }
             $mail->Subject = $subject;
             $this->addStat("Subject: " . $subject);
             $mail->MsgHTML($content);
             $mail->SMTPDebug = 2;
             $mail->addAddress($to_email);
             $this->addStat("To: " . $to_email);
             setCCAddress($mail, 'cc', $cc);
             setCCAddress($mail, 'bcc', $bcc);
             #$mail->IsHTML(true);
             addAllAttachments($mail, $emailID);
             try {
                 ob_start();
                 $mail_return = MailSend($mail);
                 $debug = ob_get_clean();
                 $this->addStat($debug);
             } catch (Workflow_phpmailerException $exp) {
                 Workflow2::error_handler($exp->getCode(), $exp->getMessage(), $exp->getFile(), $exp->getLine());
             }
             #$mail_return = send_mail($module, $to_email,$from_name,$from_email,$subject,$content, $cc, $bcc,'all',$emailID);
         } else {
             $mail_return = 1;
         }
         $this->addStat("Send eMail with following Result:");
         $this->addStat($mail_return);
         if ($mail_return != 1) {
             if (empty($mail->ErrorInfo) && empty($mail_return)) {
                 $mail_return = 1;
             }
         }
         $context->setEnvironment("sendmail_result", $mail_return, $this);
         if ($mail_return != 1) {
             if ($this->isContinued()) {
                 $delay = 180;
             } else {
                 $delay = 60;
             }
             Workflow2::send_error("Sendmail Task couldn't send an email to " . $to_email . "<br>Error: " . var_export($mail->ErrorInfo, true) . "<br><br>The Task will be rerun after " . $delay . " minutes.", __FILE__, __LINE__);
             Workflow2::error_handler(E_NONBREAK_ERROR, "Sendmail Task couldn't send an email to " . $to_email . "<br>Error: " . var_export($mail->ErrorInfo, true) . "<br><br>The Task will be rerun after " . $delay . " minutes.", __FILE__, __LINE__);
             return array("delay" => time() + $delay * 60, "checkmode" => "static");
         }
     }
     // Set Mails as Send
     $sql = "UPDATE vtiger_emaildetails SET email_flag = 'SENT' WHERE emailid = '" . $emailID . "'";
     $adb->query($sql);
     return "yes";
 }