Esempio n. 1
0
 /**
  * Event method sharing the contacts with the Co-Workers
  * @param object $evtcl
  */
 function eventShareContactsMultiple(EventControler $evtcl)
 {
     $contacts = $evtcl->getParam("idcontacts");
     $co_workers = $evtcl->getParam("cwid");
     $count = 0;
     $no_coworker = 0;
     if (is_array($contacts) && is_array($co_workers)) {
         $do_tag = new Tag();
         foreach ($co_workers as $co) {
             foreach ($contacts as $cont) {
                 if (!$this->checkCoWorkerContactRel($cont, $co)) {
                     $this->addContactSharings($cont, $co);
                     $do_tag->addTagOnContactSharing($cont, $co);
                     $count++;
                 }
             }
         }
     }
     if ($count) {
         $msg = 'Sharing Updated succesfully';
     } else {
         $msg = 'No Data updated,you may be trying to duplicate some contact access';
     }
     $goto = $evtcl->goto;
     $dispError = new Display($goto);
     $dispError->addParam("message", $msg);
     $evtcl->setDisplayNext($dispError);
 }
Esempio n. 2
0
 function eventVCardImport(EventControler $evtcl)
 {
     $msg = "";
     $goto = $evtcl->getParam("goto");
     $uploaded_file = $_FILES['fields']['name']['contact_vcard'];
     if ($uploaded_file) {
         $target_path = 'files/' . $uploaded_file;
         if (!move_uploaded_file($_FILES['fields']['tmp_name']['contact_vcard'], $target_path)) {
             $msg = "There was an error uploading the file, please try again!";
         } else {
             chmod($target_path, 0755);
             $_SESSION['vcard_file'] = $uploaded_file;
             $_SESSION['import_tag'] = trim($evtcl->fields['import_tag']);
             $retVal = $this->print_vcard_address_book($target_path, 'ofuz vCard Import', '', '', '');
             if ($retVal) {
                 $msg = "Your vCard contacts have been imported successfully.";
             } else {
                 $msg = $this->errMsg;
             }
         }
     } else {
         $msg = "Please select a file to be imported.";
     }
     $disp = new Display($goto);
     $disp->addParam("msg", $msg);
     if ($evtcl->getParam("fromReg") == 'Yes') {
         //if importing while registration
         $_SESSION["page_from"] = 'reg';
     }
     $evtcl->setDisplayNext($disp);
 }
 function eventChangeGoto(Eventcontroler $evtcl)
 {
     $fields = $evtcl->fields;
     $dispError = new Display("settings_auto_responder_email.php");
     $dispError->addParam("id", $fields["idautoresponder"]);
     $evtcl->setDisplayNext($dispError);
 }
Esempio n. 4
0
 /**   
  * Event function to update the group
  * Also updates the related member information of the group
  * @param object $evctl
  * @see modules/Settings/group_edit.php
  */
 public function eventEditGroup(EventControler $evctl)
 {
     $permission = $_SESSION["do_user"]->is_admin == 1 ? true : false;
     if (true === $permission) {
         if ($evctl->idgroup != '' && $evctl->group_name) {
             $qry = "\n\t\t\t\tUPDATE `" . $this->getTable() . "` \n\t\t\t\tset `group_name` = ?,\n\t\t\t\t`description` = ?\n\t\t\t\twhere `idgroup` = ? LIMIT 1";
             $this->query($qry, array(CommonUtils::purify_input($evctl->group_name), CommonUtils::purify_input($evctl->description), $evctl->idgroup));
             if (is_array($evctl->select_to) && count($evctl->select_to) > 0) {
                 $do_group_user_rel = new GroupUserRelation();
                 $do_group_user_rel->update_group_related_to_user($evctl->select_to, $evctl->idgroup);
             }
             $_SESSION["do_crm_messages"]->set_message('success', _('Group has been updated successfully !'));
             $dis = new Display($evctl->next_page);
             $dis->addParam("sqrecord", $evctl->idgroup);
             $evctl->setDisplayNext($dis);
         } else {
             $_SESSION["do_crm_messages"]->set_message('error', _('Unable to update the group, either group name or id is missing !'));
             $dis = new Display($evctl->error_page);
             $evctl->setDisplayNext($dis);
         }
     } else {
         $_SESSION["do_crm_messages"]->set_message('error', _('You do not have permission to edit record !'));
         $next_page = NavigationControl::getNavigationLink("Settings", "index");
         $dis = new Display($next_page);
         $evctl->setDisplayNext($dis);
     }
 }
Esempio n. 5
0
 function eventCheckEmptyFields(Eventcontroler $evtcl)
 {
     $field_selected = $evtcl->field_selected;
     if (empty($field_selected)) {
         $_SESSION['in_page_message'] = _("Please select some labels");
         $evtcl->doSave = 'no';
         $evtcl->goto = 'settings_wf.php';
         $dispError = new Display("settings_wf.php");
         $dispError->addParam("e", 'yes');
         $evtcl->setDisplayNext($dispError);
     }
 }
 /**
  * event function to add a custom view
  * @param object $evctl
  * @return void
  */
 public function eventAddRecord(EventControler $evctl)
 {
     if (trim($evctl->cvname) == '') {
         $_SESSION["do_crm_messages"]->set_message('error', _('Please add a custom view name before saving !'));
         $next_page = NavigationControl::getNavigationLink("CustomView", "add");
         $dis = new Display($next_page);
         $dis->addParam("target_module_id", (int) $evctl->target_module_id);
         $evctl->setDisplayNext($dis);
     } elseif ((int) $evctl->target_module_id == 0) {
         $_SESSION["do_crm_messages"]->set_message('error', _('Missing target module for custom view !'));
         $next_page = NavigationControl::getNavigationLink("CustomView", "add");
         $dis = new Display($next_page);
         $evctl->setDisplayNext($dis);
     } elseif (false === $_SESSION["do_crm_action_permission"]->action_permitted('add', 17)) {
         $_SESSION["do_crm_messages"]->set_message('error', _('You do not have permission to add record !'));
         $next_page = NavigationControl::getNavigationLink($_SESSION["do_module"]->modules_full_details[$evctl->target_module_id]["name"], "list");
         $dis = new Display($next_page);
         $evctl->setDisplayNext($dis);
     } else {
         $this->addNew();
         $this->name = $evctl->cvname;
         $this->iduser = $_SESSION["do_user"]->iduser;
         $this->is_default = $evctl->is_default == 'on' ? 1 : 0;
         if ($_SESSION["do_user"]->is_admin == 1) {
             $this->is_public = $evctl->is_public == 'on' ? 1 : 0;
         }
         $this->idmodule = (int) $evctl->target_module_id;
         $this->is_editable = 1;
         $this->add();
         $idcustom_view = $this->getInsertId();
         //reset default custom view if is_default is set
         if ($evctl->is_default == 'on') {
             $this->reset_default_custom_view($idcustom_view, $evctl->target_module_id);
         }
         //add custom view fields
         $do_custom_view_fields = new CustomViewFields();
         $do_custom_view_fields->add_custom_view_fields($idcustom_view, $evctl->cv_fields);
         //add custom view filter
         $do_custom_view_filter = new CustomViewFilter();
         $do_custom_view_filter->add_custom_view_date_filter($idcustom_view, $evctl->cv_date_field, $evctl->cv_date_field_type, $evctl->cv_date_start, $evctl->cv_date_end);
         //add advanced filter
         $adv_filter_data = array("cv_adv_fields_1" => $evctl->cv_adv_fields_1, "cv_adv_fields_type_1" => $evctl->cv_adv_fields_type_1, "cv_adv_fields_val_1" => $_POST["cv_adv_fields_val_1"], "cv_adv_fields_2" => $evctl->cv_adv_fields_2, "cv_adv_fields_type_2" => $evctl->cv_adv_fields_type_2, "cv_adv_fields_val_2" => $_POST["cv_adv_fields_val_2"], "cv_adv_fields_3" => $evctl->cv_adv_fields_3, "cv_adv_fields_type_3" => $evctl->cv_adv_fields_type_3, "cv_adv_fields_val_3" => $_POST["cv_adv_fields_val_3"], "cv_adv_fields_4" => $evctl->cv_adv_fields_4, "cv_adv_fields_type_4" => $evctl->cv_adv_fields_type_4, "cv_adv_fields_val_4" => $_POST["cv_adv_fields_val_4"], "cv_adv_fields_5" => $evctl->cv_adv_fields_5, "cv_adv_fields_type_5" => $evctl->cv_adv_fields_type_5, "cv_adv_fields_val_5" => $_POST["cv_adv_fields_val_5"]);
         $do_custom_view_filter->add_custom_view_adv_filter($idcustom_view, $adv_filter_data);
         //redirect after adding the custom view
         $next_page = NavigationControl::getNavigationLink($_SESSION["do_module"]->modules_full_details[$evctl->target_module_id]["name"], "list", '', '&custom_view_id=' . $idcustom_view);
         $dis = new Display($next_page);
         $evctl->setDisplayNext($dis);
     }
 }
Esempio n. 7
0
 function eventCheckEmptyFields(Eventcontroler $evtcl)
 {
     $fields = $evtcl->fields;
     if ($fields['name'] == '') {
         $evtcl->doSave = 'no';
         $_SESSION['in_page_message'] = _("Please provide one name for the autoresponder");
     } elseif ($fields['tag_name'] == '') {
         $evtcl->doSave = 'no';
         $_SESSION['in_page_message'] = _("Please Select One Tag");
     }
     if ($evtcl->doSave == 'no') {
         $evtcl->goto = 'settings_auto_responder.php';
         $dispError = new Display("settings_auto_responder.php");
         $dispError->addParam("e", 'yes');
         $evtcl->setDisplayNext($dispError);
     }
 }
Esempio n. 8
0
 /**
  * Event Function used while updating a company
  * Checks if the updated Company is already in the database
  * If there then do not update and set doSave = mo
  * Else continue with other events from the called page
  * 
  */
 function eventCheckDuplicateCompanyInUpdate(EventControler $evtcl)
 {
     $fields = $evtcl->getParam('fields');
     $q_company = new sqlQuery($this->getDbCon());
     $q_company->query("select name from company where idcompany = " . $this->getPrimaryKeyValue());
     $q_company->fetch();
     $comp_name = $q_company->getData("name");
     $q = new sqlQuery($this->getDbCon());
     $q->query("select * from company where name='" . trim($fields['name']) . "' \r\n      AND name <> '" . trim($comp_name) . "'");
     // need to have the iduser as well
     if ($q->getNumRows() > 0) {
         $dispError = new Display($evtcl->goto);
         $dispError->addParam("message", "This company is already in the database");
         $evtcl->addParam("doSave", "no");
         $evtcl->setDisplayNext($dispError);
     }
 }
 function eventCancelAccount(EventControler $evtcl)
 {
     //echo 'No cancellation after registration....';
     //echo '<br /> and for the reson that u have given <br />'.$evtcl->fields["reason"].'<br /> no way, no cancellation ';
     //exit;
     if ($evtcl->fields["reason"] != '') {
         $this->deleteContactRelated();
         $this->deleteUserContactNote();
         $this->deleteUserContactSharing();
         $this->deleteUserEmailTemplate();
         $this->deleteInvoiceRelated();
         $this->deleteMessage();
         $this->deleteProjectRelated();
         $this->deleteTask();
         $this->deletewebformuser();
         $this->deleteworkfeed();
         $this->deletenotedraft();
         $this->deletetwitteraccount();
         $this->deletetbreadcrumb();
         $this->deleteUserRel();
         $this->deleteUserSettings();
         $this->deleteUserTags();
         $this->dropContactView();
         $email_template = new EmailTemplate("ofuz_cancel_account_notification");
         $email_template->setSenderName($_SESSION['do_User']->getFullName());
         $email_template->setSenderEmail($_SESSION['do_User']->email);
         $email_data = array('name' => $_SESSION['do_User']->getFullName(), 'email' => $_SESSION['do_User']->email, 'reason' => $evtcl->fields["reason"]);
         $emailer = new Radria_Emailer();
         $emailer->setEmailTemplate($email_template);
         $emailer->mergeArray($email_data);
         $emailer->addTo("*****@*****.**");
         //$emailer->addTo("*****@*****.**");
         $emailer->send();
         $this->deleteUser();
     } else {
         $_SESSION['in_page_message'] = _("Please Provide a reason before cancelling the account");
         $dispError = new Display('cancel_account.php');
         $dispError->addParam("m", 'e');
         $evtcl->setDisplayNext($dispError);
     }
 }
Esempio n. 10
0
 /**
  * function to edit the combo values
  * @param object $evctl
  */
 public function eventEditComboValues(EventControler $evctl)
 {
     $idfields = (int) $evctl->idfields;
     if ($idfields > 0) {
         $referrar_module_id = (int) $evctl->referrar_module_id;
         $pick_values_seperated = preg_split('/[\\r\\n]+/', $evctl->pick_values, -1, PREG_SPLIT_NO_EMPTY);
         $this->update_combo_values($idfields, $pick_values_seperated);
         //check if the field is mapped with some other fields and if yes then update the mapped fields also
         $do_crm_fields_mapping = new CRMFieldsMapping();
         $mapped_fields = $do_crm_fields_mapping->is_mapped($idfields);
         if (is_array($mapped_fields) && count($mapped_fields) > 0) {
             foreach ($mapped_fields as $mapped_fieldid) {
                 $this->update_combo_values($mapped_fieldid, $pick_values_seperated);
             }
         }
         $_SESSION["do_crm_messages"]->set_message('success', _('Data has been updated successfully.'));
         $next_page = NavigationControl::getNavigationLink("Settings", "picklist");
         $dis = new Display($next_page);
         $dis->addParam("cmid", $referrar_module_id);
         $evctl->setDisplayNext($dis);
     }
 }
Esempio n. 11
0
 /**
  * event function for cpanel login
  * @param object $evctl
  * @return void
  */
 public function eventLogin(\EventControler $evctl)
 {
     $login_success = false;
     if ($evctl->user_name != '' && $evctl->user_password != '') {
         $qry = "\n\t\t\tselect cu.*,c.firstname,c.lastname,c.contact_avatar from " . $this->getTable() . " cu\n\t\t\tjoin contacts c on c.idcontacts = cu.idcontacts\n\t\t\twhere \n\t\t\tcu.`email` = ? \n\t\t\tAND cu.`password` = ?\n\t\t\tAND c.deleted = 0\n\t\t\tAND c.portal_user = 1\n\t\t\t";
         $this->query($qry, array($evctl->user_name, MD5($evctl->user_password)));
         if ($this->getNumRows() == 1) {
             $this->next();
             $idcpanel_user = $this->idcpanel_user;
             $login_success = true;
         } elseif ($this->getNumRows() > 1) {
             $msg = _('Looks like you have multiple login for the customer portal for different organization, please ask the provider to reset the password for one');
         } else {
             $msg = _('Authentication failed ! Invalid login details');
         }
         if (true === $login_success) {
             $this->set_subordinates($this->idcpanel_user, $this->idorganization);
             $_SESSION["do_cpanel_action_permission"]->load_cpanel_user_modules($this->idorganization);
             $this->sessionPersistent("do_cpaneluser", "logout.php", TTL_LONG);
             if (!is_object($_SESSION["do_global_settings"])) {
                 $do_global_settings = new \CRMGlobalSettings();
                 $do_global_settings->sessionPersistent("do_global_settings", "logout.php", TTL);
             }
             $dis = new \Display($evctl->goto);
             //@see view/login_view
             if ((int) $evctl->sqrecord > 0) {
                 $dis->addParam("sqrecord", (int) $evctl->sqrecord);
             }
             $evctl->setDisplayNext($dis);
         } else {
             $_SESSION["do_cpanel_messages"]->set_message('error', $msg);
         }
     } else {
         $_SESSION["do_cpanel_messages"]->set_message('error', _('Missing email or password for authentication'));
     }
 }
Esempio n. 12
0
 /**
  * event function to add a new role
  * @param object $evctl
  */
 public function eventAddNewRole(EventControler $evctl)
 {
     $permission = $_SESSION["do_user"]->is_admin == 1 ? true : false;
     if (true === $permission) {
         if ($evctl->rolename != '' && $evctl->parentrole != '') {
             $role_detail = $this->get_role_detail($evctl->parentrole);
             if (is_array($role_detail) && count($role_detail) > 0) {
                 $depth_lookup = $role_detail["depth"] + 1;
                 $qry = "select max(idrole) as max_role from `role`";
                 $stmt = $this->getDbConnection()->executeQuery($qry);
                 $data = $stmt->fetch();
                 $max_role = $data["max_role"];
                 if ($max_role != '') {
                     $role_int = str_replace("N", "", $max_role);
                     $new_role_int = $role_int + 1;
                     $new_role = "N" . $new_role_int;
                     $new_parent_role = $role_detail["parentrole"] . "::" . $new_role;
                     $this->insert($this->getTable(), array("idrole" => $new_role, "rolename" => CommonUtils::purify_input($evctl->rolename), "parentrole" => $new_parent_role, "depth" => $depth_lookup, "editable" => 1));
                     // Adding role profile relation
                     $profiles = $evctl->select_to;
                     foreach ($profiles as $idprofile) {
                         $do_role_prof_rel = new RoleProfileRelation();
                         $do_role_prof_rel->addNew();
                         $do_role_prof_rel->idrole = $new_role;
                         $do_role_prof_rel->idprofile = $idprofile;
                         $do_role_prof_rel->add();
                         $do_role_prof_rel->free();
                     }
                     $dis = new Display($evctl->next_page);
                     $dis->addParam("sqrecord", $idprofile);
                     $evctl->setDisplayNext($dis);
                 }
             }
         }
     } else {
         $_SESSION["do_crm_messages"]->set_message('error', _('You do not have permission to add record !'));
         $next_page = NavigationControl::getNavigationLink("Settings", "index");
         $dis = new Display($next_page);
         $evctl->setDisplayNext($dis);
     }
 }
    $datastructure = fread($fp, filesize($conx->getProjectDirectory() . "backupsync.struct.sql"));
    fclose($fp);
    $queries = getSQLStatements($datastructure);
    $conx->setBackupSync(false);
    $runquery = new sqlQuery($conx);
    foreach ($queries as $query) {
        $query = trim($query);
        if (strlen($query) > 3) {
            $runquery->query($query);
        }
    }
    $fp = fopen($conx->getProjectDirectory() . "backupsync.struct.sql", "w");
    fclose($fp);
    $error = false;
    if (strlen($runquery->getError()) > 5) {
        $this->setError("SQL query Error during structure importation : " . $runquery->getError());
        $error = true;
    }
    if ($error) {
        $message = "Error, Datastructure import one or more query didn't go true during the structure importation";
        $this->setError($message);
    } else {
        $message = "Importation done";
    }
} else {
    $message = "Error, Event Controler, Data Structure : mydb_key doesn't match";
    $this->setError($message);
}
$disp = new Display($this->getMessagePage());
$disp->addParam("message", $message);
$this->setDisplayNext($disp);
        $suplier = 53;
    }
    if (eregi("TRAFFICSWARM", $do_import_expense->description)) {
        $category = 16;
    }
    if (eregi("DELL", $do_import_expense->description)) {
        $category = 13;
        $suplier = 73;
    }
    if (eregi("T-MOBILE", $do_import_expense->description)) {
        $category = 12;
        $category = 119;
    }
    if ($category != 0) {
        $do_expense->newRecord();
        $do_expense->num = $do_import_expense->idexpense_import;
        $do_expense->description = $do_import_expense->description;
        $do_expense->datepayed = $do_import_expense->debit_date;
        $do_expense->daterecieve = $do_import_expense->debit_date;
        $do_expense->amount = $do_import_expense->amount;
        $do_expense->type = $category;
        if ($suplier != 0) {
            $do_expense->suplier = $suplier;
        }
        $do_expense->add();
        $do_import_expense->delete();
    }
}
$disp = new Display($goto);
$disp->addParam("message", "Import completed");
$this->setDisplayNext($disp);
Esempio n. 15
0
 /**
  * function to add a custom field
  * It will recieve the custom field information for custom field add form
  * Add the data in the fields table and then to the custom field table
  * @see CustomFields::get_custom_fields_tablename()
  * @see popups/add_custom_field_modal.php
  */
 public function eventAddCustomField(EventControler $evctl)
 {
     $idmodule = $evctl->idmodule;
     $custom_field_type = $evctl->custom_field_type;
     $req = $evctl->cf_req;
     $field_validation = array();
     $is_required = false;
     if ($req == 'on') {
         $is_required = true;
         $field_validation["required"] = true;
     }
     $field_data_type = '';
     switch ($custom_field_type) {
         case 1:
             $fld_length = (int) $evctl->cf_len;
             $field_data_type = 'VARCHAR(' . $fld_length . ')';
             if ($is_required === true) {
                 if ($evctl->cf_max_len != '' || (int) $evctl->cf_max_len > 0) {
                     $field_validation["maxlength"] = (int) $evctl->cf_max_len;
                 }
                 if ($evctl->cf_min_len != '' || (int) $evctl->cf_min_len > 0) {
                     $field_validation["minlength"] = (int) $evctl->cf_min_len;
                 }
             }
             break;
         case 2:
             $field_data_type = 'TEXT';
             break;
         case 3:
             $field_data_type = 'VARCHAR(3)';
             break;
         case 5:
             $pick_values = $evctl->cf_pick;
             $not_equal = $evctl->cf_pick_notequal;
             if ($is_required === true) {
                 $field_validation["notEqual"] = $not_equal;
             }
             $field_data_type = 'VARCHAR(100)';
             break;
         case 6:
             $pick_values = $evctl->cf_pick;
             $field_data_type = 'VARCHAR(100)';
             break;
         case 7:
             $fld_length = (int) $evctl->cf_len;
             $field_data_type = 'VARCHAR(' . $fld_length . ')';
             break;
         case 8:
             $fld_length = (int) $evctl->cf_len;
             $field_data_type = 'VARCHAR(' . $fld_length . ')';
             break;
         case 9:
             $field_data_type = 'DATE';
             break;
         case 10:
             $field_data_type = 'VARCHAR(10)';
             break;
         case 210:
             $field_data_type = 'VARCHAR(15)';
             break;
     }
     if (count($field_validation) > 0) {
         $field_validation_entry = json_encode($field_validation);
     } else {
         $field_validation_entry = '';
     }
     $qry = "select * from " . $this->getTable() . " where field_name like '%ctf_%' order by idfields desc limit 1 ";
     $stmt = $this->getDbConnection()->executeQuery($qry);
     if ($stmt->rowCount() > 0) {
         $data = $stmt->fetch();
         $last_custom_field = $data["field_name"];
         $field_sequence = $data["field_sequence"];
         $last_custom_field_explode = explode("_", $last_custom_field);
         $custom_field_suffix = $last_custom_field_explode[1];
         $new_custom_field_suffix = $custom_field_suffix + 1;
         $custom_field_name = "ctf_" . $new_custom_field_suffix;
         $custom_field_sequence = $field_sequence + 1;
     } else {
         $custom_field_name = "ctf_1";
         $custom_field_sequence = 1;
     }
     $insert_data = array('field_name' => $custom_field_name, 'field_label' => CommonUtils::purify_input($evctl->cf_label), 'field_sequence' => $custom_field_sequence, 'idblock' => $this->get_custom_field_blocks($idmodule), 'idmodule' => $idmodule, 'table_name' => $this->get_custom_fields_tablename($idmodule), 'field_type' => $custom_field_type, 'field_validation' => $field_validation_entry);
     $this->insert($this->getTable(), $insert_data);
     $idfields = $this->getInsertId();
     if ($idfields > 0) {
         if ($custom_field_type == 5 || $custom_field_type == 6) {
             //$pick_values_seperated = explode(PHP_EOL,$evctl->cf_pick);
             $pick_values_seperated = preg_split('/[\\r\\n]+/', $evctl->cf_pick, -1, PREG_SPLIT_NO_EMPTY);
             $do_combo_values = new ComboValues();
             $do_combo_values->add_combo_values($idfields, $pick_values_seperated);
         }
         // add field to the custom field table for the moduleedit_custom_field_modal
         $qry_alter = "\n\t\t\talter table `" . $this->get_custom_fields_tablename($idmodule) . "` \n\t\t\tadd column `{$custom_field_name}` {$field_data_type}\n\t\t\t";
         $this->query($qry_alter);
         $_SESSION["do_crm_messages"]->set_message('success', _('Custom field added successfully.'));
         $next_page = NavigationControl::getNavigationLink("Settings", "customfield");
         $dis = new Display($next_page);
         $dis->addParam("cmid", $idmodule);
         $evctl->setDisplayNext($dis);
     } else {
         $_SESSION["do_crm_messages"]->set_message('error', _('Custom field could not be added, please try again ! '));
     }
 }
Esempio n. 16
0
if (!isset($strWrongEmail)) {
    $strWrongEmail = "The email you entered doesn't exist";
}
global $HTTP_SERVER_VARS;
if ($submitbutton != "Cancel") {
    if (isset($emailfield)) {
        $nbremail = count($emailfield);
        for ($i = 0; $i < $nbremail; $i++) {
            $tmp_emailname = $emailfield[$i];
            if (strlen($fields[$tmp_emailname]) > 0) {
                list($user, $domain) = explode("@", $fields[$tmp_emailname]);
                if (!eregi("Win32", $HTTP_SERVER_VARS["SERVER_SOFTWARE"])) {
                    if (strlen($domain) > 0 && strlen($user) > 0) {
                        if (!checkdnsrr($domain, "ANY")) {
                            if (strlen($errorpage) > 0) {
                                $urlerror = $errorpage;
                            } else {
                                $urlerror = $this->getMessagePage();
                            }
                            $disp = new Display($urlerror);
                            $disp->addParam("message", $strWrongEmail);
                            $this->setDisplayNext($disp);
                            $this->updateParam("doSave", "no");
                        }
                    }
                }
            }
        }
        reset($emailfield);
    }
}
Esempio n. 17
0
 /**
  *   Event method to add a Co-Worker for a project
  */
 function eventShareProjects(EventControler $evtcl)
 {
     $idproject = $evtcl->idproject;
     $fields = $evtcl->fields;
     $idcoworker = $fields["co_worker"];
     if ($idcoworker != '') {
         if (!$this->isProjectSharedToCoworker($idcoworker, $idproject)) {
             $this->addProjectCoWorker($idcoworker, $idproject);
             $message = _("Co-Worker is assigned successfuly for the project");
         } else {
             $message = _("Co-Worker is already assigned this project");
         }
     } else {
         $message = _("You must select a Co-Worker");
     }
     $goto = $evtcl->goto;
     $dispError = new Display($goto);
     $dispError->addParam("message", $message);
     $evtcl->setDisplayNext($dispError);
 }
Esempio n. 18
0
 /**
  * Process to the next page based on the $urlNext
  * @access public
  */
 function doForward()
 {
     global $globalevents;
     if (strlen($this->getUrlNext()) == 0) {
         if (strlen($this->getParam("event_referer") > 0)) {
             $this->setUrlNext($this->getParam("event_referer"));
         } elseif (strlen($_SERVER['HTTP_REFERER']) > 0) {
             $this->setUrlNext($_SERVER['HTTP_REFERER']);
         } else {
             $disp = new Display($this->getMessagePage());
             $disp->addParam("message", "No redirection set for this event. Please click back and try again");
         }
     }
     if ($this->getUniqueUrl()) {
         //if (ereg("uniqid", $this->getUrlNext())) {
         if (preg_match("/uniqid/", $this->getUrlNext())) {
             //$this->urlNext = ereg_replace("uniqid=.*", "uniqid=".uniqid(rand()), $this->getUrlNext()) ;
             $this->urlNext = preg_replace("uniqid=.*", "uniqid=" . uniqid(rand()), $this->getUrlNext());
             //} elseif (ereg("\?", $this->getUrlNext())) {
         } elseif (preg_match("/\\?/", $this->getUrlNext())) {
             $this->urlNext .= "&uniqid=" . uniqid(rand());
         } else {
             $this->urlNext .= "?uniqid=" . uniqid(rand());
         }
     }
     $this->setLog("\n Forward to URL:" . $this->getUrlNext());
     header("Location: " . $this->getUrlNext());
     exit;
 }
Esempio n. 19
0
<?php

// Copyright 2001 - 2007 SQLFusion LLC, Author: Philippe Lewicki           info@sqlfusion.com
// For licensing, reuse, modification and distribution see license.txt
/**   Event Mydb.tableorder
 *
 * This event set the value to display the fields in a specific order..
 * It works with the reportTable objects.
 * <br>- param int recordpos position number in the result set of the first record to display
 * <br>- param string orderfield name of the field to order on
 * <br>- param string orderdir direction of the order (ASC, DESC)
 * <br>- param string goto url of the page to go to display the order
 *
 * @note this is a bad and dangerous Event, should be rewrite ASAP using sessions
 *
 * @package RadriaEvents
 * @author Philippe Lewicki  <*****@*****.**>
 * @copyright  SQLFusion LLC 2001-2007
 * @version 3.0
 */
$page = basename($goto);
$disp = new Display($goto);
$disp->addParam("recordpos", $recordpos);
$disp->addParam("orderfield", $orderfield);
$disp->addParam("orderdir", $orderdir);
$disp->addParam("mydb_num", $mydb_num);
$disp->save("displayTableOrder");
$this->setDisplayNext($disp);
Esempio n. 20
0
 /**
  * Custom method to update the user info from the setting page.
  * @param object $evtcl
  */
 function eventUpdateUserInfo(EventControler $evtcl)
 {
     $fields = $evtcl->fields;
     if ($evtcl->doSave == "yes") {
         $qry = "update " . $this->table . " set \n                      firstname = '" . $fields["firstname"] . "',\n                      lastname = '" . $fields["lastname"] . "',\n                      email = '" . $fields["email"] . "',\n                      username = '******',\n                      password = '******',\n                      company = '" . $fields["company"] . "',\n                      position = '" . $fields["position"] . "',\n                      address1 = '" . $fields["address1"] . "',\n                      address2 = '" . $fields["address2"] . "',\n                      city = '" . $fields["city"] . "',\n                      zip = '" . $fields["zip"] . "',\n                      state = '" . $fields["state"] . "',\n                      country = '" . $fields["country"] . "'\n                      where iduser = "******"Data has been updated.";
         $dispError = new Display($evtcl->errPage);
         $dispError->addParam("message", $msg);
         $evtcl->setDisplayNext($dispError);
     }
 }
 */
if (!is_object($_SESSION['do_User'])) {
    $disp = new Display("user_login.php");
    $disp->addParam("message", "Your session has expired, please sign-in again");
    //$disp->addParam("entry", $_SERVER['REQUEST_URI']);
    $_SESSION['entry'] = $_SERVER['REQUEST_URI'];
    header("Location: /" . $disp->getUrl());
    exit;
}
if (is_object($_SESSION['do_User'])) {
    try {
        if (!$_SESSION['do_User']->iduser) {
            $disp = new Display("user_login.php");
            $disp->addParam("message", "Error with your user record, please sign-in again");
            //$disp->addParam("entry", $_SERVER['REQUEST_URI']);
            $_SESSION['entry'] = $_SERVER['REQUEST_URI'];
            header("Location: /" . $disp->getUrl());
        }
    } catch (Exception $e) {
        $disp = new Display("user_login.php");
        $disp->addParam("message", "Error with your user record, please sign-in again");
        //$disp->addParam("entry", $_SERVER['REQUEST_URI']);
        $_SESSION['entry'] = $_SERVER['REQUEST_URI'];
        header("Location: /" . $disp->getUrl());
    }
    /* This is for api_upgrade_invoice.php */
    if ($_SESSION['upgrade'] === true) {
        $tt = "api_upgrade_invoice.php";
        echo "<script language=\"javascript\">\n        window.location.href='{$tt}';\n\t\t</script>";
    }
}
Esempio n. 22
0
 /** 
  * eventApplyFilter
  * This event check process all the imported expenses and based on their description
  * categorize them and set the proper suplier.
  * Then it insert it into Expense table and delete it from the ExpenseImport.
  */
 public function eventApplyFilters(EventControler $evctl)
 {
     $this->getUserAll();
     $do_expense = new Expense();
     while ($this->next()) {
         $account = 0;
         $suplier = 0;
         if ($this->category == "Airlines / Transportation") {
             $account = 16;
         }
         if ($this->category == "ATM Withdrawals") {
             $account = 44;
         }
         if ($this->category == "Auto / Gas") {
             $account = 5;
         }
         if ($this->category == "Building Supply / Wholesale") {
             $account = 13;
         }
         if ($this->category == "Entertainment") {
             $account = 21;
         }
         if ($this->category == "Groceries") {
             $account = 47;
         }
         if ($this->category == "Insurance / Financial Services") {
             $account = 23;
         }
         if ($this->category == "Office Supply / Stationery") {
             $account = 15;
         }
         if ($this->category == "Postage / Delivery") {
             $account = 33;
         }
         if ($this->category == "Restaurants") {
             $account = 4;
         }
         if ($this->category == "Utilities / Telecom") {
             $account = 14;
         }
         if (preg_match("/DIRECTNIC COM/", $this->description)) {
             $account = 49;
             $suplier = 32;
         }
         if (preg_match("/GANDI/i", $this->description)) {
             $account = 49;
             $suplier = 48;
         }
         if (preg_match("/THAWTE INC/i", $this->description)) {
             $account = 49;
             $suplier = 47;
         }
         if (preg_match("/GEOTRUST/i", $this->description)) {
             $account = 49;
             $suplier = 27;
         }
         if (preg_match("/BANKCARD/i", $this->description)) {
             $account = 17;
             $suplier = 39;
         }
         if (preg_match("/FXOL FGN/i", $this->description)) {
             $account = 17;
             $suplier = 39;
         }
         if (preg_match("/MEMBERSHIP FEE/i", $this->description)) {
             $account = 17;
             $suplier = 39;
         }
         if (preg_match("/ADP TX/i", $this->description)) {
             $account = 26;
             $suplier = 30;
         }
         if (preg_match("/Arctern/i", $this->description)) {
             $account = 42;
             $suplier = 8;
         }
         if (preg_match("/INR AT/i", $this->description)) {
             $account = 42;
             $suplier = 71;
         }
         if (preg_match("/WORD LIONS/i", $this->description)) {
             $account = 9;
             $suplier = 73;
         }
         if (preg_match("/NETFLIX/i", $this->description)) {
             $account = 23;
             $suplier = 18;
         }
         if (preg_match("/BLUE SHIELD/i", $this->description)) {
             $account = 43;
             $suplier = 4;
         }
         if (preg_match("/KAIZER/i", $this->description)) {
             $account = 43;
             $suplier = 51;
         }
         if (preg_match("/NET2EZ/i", $this->description)) {
             $account = 3;
             $suplier = 19;
         }
         if (preg_match("/FRY\\'S/i", $this->description)) {
             $account = 13;
             $suplier = 28;
         }
         if (preg_match("/YAHOO SEARCH/i", $this->description)) {
             $account = 10;
             $suplier = 37;
         }
         if (preg_match("/CISLO/i", $this->description)) {
             $account = 11;
             $suplier = 2;
         }
         if (preg_match("/VERIZON/i", $this->description)) {
             $account = 14;
             $suplier = 38;
         }
         if (preg_match("/CINGULAR/i", $this->description) || preg_match("/at\\&t/i", $this->description) || preg_match("/IPHONE/i", $this->description)) {
             $account = 14;
             $suplier = 7;
         }
         if (preg_match("/CALLCENTRIC/i", $this->description)) {
             $account = 3;
             $suplier = 107;
         }
         if (preg_match("/SIPPHONE/i", $this->description) || preg_match("/GIZMO/i", $this->description)) {
             $account = 14;
             $suplier = 26;
         }
         if (preg_match("/ADWS/i", $this->description)) {
             $account = 10;
             $suplier = 26;
         }
         if (preg_match("/AMZN PMTS/i", $this->description) || preg_match("/Amazon Payments/i", $this->description)) {
             $account = 3;
             $suplier = 11;
         }
         if (preg_match("/OFFICE DEPOT/i", $this->description)) {
             $account = 15;
             $suplier = 52;
         }
         if (preg_match("/OFFICE MAX/i", $this->description)) {
             $account = 15;
             $suplier = 72;
         }
         if (preg_match("/STAPLES/i", $this->description)) {
             $account = 15;
             $suplier = 13;
         }
         if (preg_match("/WEBEX/i", $this->description)) {
             $account = 50;
             $suplier = 40;
         }
         if (preg_match("/PAYCYCLE/i", $this->description)) {
             $account = 11;
             $suplier = 16;
         }
         if (preg_match("/INTUIT/i", $this->description)) {
             $account = 50;
             $suplier = 16;
         }
         if (preg_match("/EXPERTPAY/i", $this->description)) {
             $account = 46;
         }
         if (preg_match("/PAYROLL/i", $this->description)) {
             $account = 46;
         }
         if (preg_match("/USATAXPYMT/i", $this->description)) {
             $account = 26;
             $suplier = 30;
         }
         if (preg_match("/Tax/i", $this->description)) {
             $account = 8;
             $suplier = 30;
         }
         if (preg_match("/GRAND CASINO/i", $this->description)) {
             $account = 4;
             $suplier = 113;
         }
         if (preg_match("/IN-N-OUT/i", $this->description)) {
             $account = 4;
             $suplier = 14;
         }
         if (preg_match("/STARBUCKS/i", $this->description)) {
             $account = 4;
             $suplier = 14;
         }
         if (preg_match("/SAFARIBOOKSONL/i", $this->description)) {
             $account = 21;
             $suplier = 67;
         }
         if (preg_match("/BEST BUY/i", $this->description)) {
             $account = 13;
             $suplier = 5;
         }
         if (preg_match("/LAW OFFICES/i", $this->description)) {
             $account = 11;
             $suplier = 68;
         }
         if (preg_match("/CA BOE/i", $this->description)) {
             $account = 8;
             $suplier = 53;
         }
         if (preg_match("/TRAFFICSWARM/i", $this->description)) {
             $account = 50;
             $suplier = 69;
         }
         if (preg_match("/DELL/i", $this->description)) {
             $account = 13;
             $suplier = 34;
         }
         if (preg_match("/T\\-MOBILE/i", $this->description)) {
             $account = 14;
             $suplier = 45;
         }
         if (preg_match("/Amazon Prime/i", $this->description)) {
             $account = 23;
             $suplier = 10;
         }
         if (preg_match("/FRONTIER/i", $this->description)) {
             $account = 16;
             $suplier = 49;
         }
         if (preg_match("/YOGAGLO/i", $this->description)) {
             $account = 50;
             $suplier = 50;
         }
         if (preg_match("/SNCF/i", $this->description)) {
             $account = 47;
             $suplier = 70;
         }
         if (preg_match("/ITUNES/i", $this->description)) {
             $account = 12;
             $suplier = 9;
         }
         if ($account != 0) {
             $do_expense->newRecord();
             $do_expense->num = $this->idexpense_import;
             $do_expense->description = $this->description;
             $do_expense->date_paid = $this->debit_date;
             $do_expense->date_receive = $this->debit_date;
             $do_expense->amount = $this->amount;
             $do_expense->iduser = $_SESSION['do_User']->iduser;
             $do_expense->idledger_account = $account;
             if ($suplier != 0) {
                 $do_expense->idsuplier = $suplier;
             }
             $do_expense->add();
             $this->delete();
         }
     }
     $disp = new Display($evctl->goto);
     $disp->addParam("message", "Import completed");
     $evctl->setDisplayNext($disp);
 }
Esempio n. 23
0
 /**
  * Event function for login
  * @param object $evctl 
  */
 public function eventLogin(EventControler $evctl)
 {
     $login_success = false;
     if ($evctl->user_name != '' && $evctl->user_password != '') {
         $qry = "\n\t\t\tselect * from " . $this->getTable() . " \n\t\t\twhere `user_name` = ? AND `password` = ?";
         $this->query($qry, array($evctl->user_name, MD5($evctl->user_password)));
         if ($this->getNumRows() == 1) {
             $this->next();
             // fetch the first row
             $iduser = $this->iduser;
             if ($this->is_active != 'Yes') {
                 $_SESSION["do_crm_messages"]->set_message('error', _('The account is not active, please ask your admin to check this !'));
             } else {
                 $login_success = true;
             }
         } elseif ($this->getNumRows() > 1) {
             $_SESSION["do_crm_messages"]->set_message('info', _('This is not your fault, you have entered correct login details but some other user has same login details, which is very unlikely. Please ask your admin to change the username or password. !'));
         } else {
             $_SESSION["do_crm_messages"]->set_message('error', _('Wrong login details !'));
         }
     } else {
         $_SESSION["do_crm_messages"]->set_message('error', _('Please enter a valid username and password !'));
     }
     if ($login_success === true) {
         $this->sessionPersistent("do_user", "logout.php", TTL_LONG);
         $this->set_user_crm_privileges();
         $subordinate_users = $this->get_subordinate_users_by_iduser($iduser);
         $this->set_subordinate_users($subordinate_users);
         $do_mod_datashare_permission = new ModuleToDatashareRelation();
         $this->set_module_data_share_permissions($do_mod_datashare_permission->get_all_datashare_permissions());
         $dis = new Display($evctl->goto);
         //@see view/login_view
         if ((int) $evctl->sqrecord > 0) {
             $dis->addParam("sqrecord", (int) $evctl->sqrecord);
         }
         //do login audit
         $do_login_audit = new LoginAudit();
         $do_login_audit->do_login_audit();
         //load the global setting object
         if (!is_object($_SESSION["do_global_settings"])) {
             $do_global_settings = new CRMGlobalSettings();
             $do_global_settings->sessionPersistent("do_global_settings", "logout.php", TTL);
         }
         //update the unseen feed to viewed = 1 on login
         $do_livefeed_display = new LiveFeedDisplay();
         $do_livefeed_display->set_feed_viewed_onlogin($iduser);
         //finally do the re-direct
         $evctl->setDisplayNext($dis);
     }
 }
Esempio n. 24
0
 /**
  * event function to send sales order by email
  * @param object $evctl
  */
 public function sendSalesOrderWithEmail(EventControler $evctl)
 {
     $record_id = $evctl->idsales_order;
     $sales_order_email = $evctl->sales_order_email;
     $crm_global_settings = new CRMGlobalSettings();
     $inventory_prefixes = $crm_global_settings->get_inventory_prefixes();
     $company_address = $crm_global_settings->get_setting_data_by_name('company_address');
     $export_inventory = new ExportInventoryData();
     if ((int) $record_id > 0) {
         if (is_array($sales_order_email) && count($sales_order_email) > 0) {
             $email_template = new EmailTemplate("send_sales_order_email");
             $emailer = new SQEmailer();
             $pdf_filename = $export_inventory->generate_inventory_pdf((int) $record_id, 14, true);
             foreach ($sales_order_email as $key => $val) {
                 $val_exploded = explode(':::', $val);
                 $to_email = $val_exploded[0];
                 $name = $val_exploded[1];
                 $name_explode = explode('::', $name);
                 $email_data = array("sales_order_number" => $inventory_prefixes["salesorder_num_prefix"] . $record_id, "company_name" => CRM_NAME, "firstname" => array_key_exists(0, $name_explode) ? $name_explode[0] : '', "lastname" => array_key_exists(1, $name_explode) ? $name_explode[1] : '', "company_address" => nl2br($company_address));
                 $to_name = (array_key_exists(0, $name_explode) ? $name_explode[0] : '') . ' ' . (array_key_exists(1, $name_explode) ? $name_explode[1] : '');
                 $emailer->IsSendmail();
                 $emailer->setEmailTemplate($email_template);
                 $emailer->mergeArray($email_data);
                 $emailer->AddAddress($to_email, $to_name);
                 $emailer->AddAttachment(OUTBOUND_PATH . '/' . $pdf_filename);
                 $emailer->send();
                 $_SESSION["do_crm_messages"]->set_message('success', _('Email has been sent !'));
                 $next_page = NavigationControl::getNavigationLink($evctl->module, "detail");
                 $dis = new Display($next_page);
                 $dis->addParam("sqrecord", $record_id);
                 $evctl->setDisplayNext($dis);
             }
         } else {
             $_SESSION["do_crm_messages"]->set_message('error', _('Operation failed! No email id specified.'));
             $next_page = NavigationControl::getNavigationLink($evctl->module, "detail");
             $dis = new Display($next_page);
             $dis->addParam("sqrecord", $record_id);
             $evctl->setDisplayNext($dis);
         }
     } else {
         $_SESSION["do_crm_messages"]->set_message('error', _('Operation failed! No record id specified.'));
         $next_page = NavigationControl::getNavigationLink($evctl->module, "detail");
         $dis = new Display($next_page);
         $dis->addParam("sqrecord", $record_id);
         $evctl->setDisplayNext($dis);
     }
 }
Esempio n. 25
0
 /**
  * event function to activate the cpanel login
  * @param object $evctl
  * @return void
  */
 function eventActivateCpanelLogin(EventControler $evctl)
 {
     if ((int) $evctl->record_id > 0) {
         $this->getId((int) $evctl->record_id);
         $err = '';
         if ((int) $this->idorganization == 0) {
             $err = _('Contact must be associated with an organization for portal login activation');
         }
         if (strlen(trim($this->email)) == 0) {
             $err = _('Missing the primary email id for portal login activation');
         }
     } else {
         $err = _('Missing idcontacts for portal activation');
     }
     if (strlen($err) == 0) {
         $pass = $this->activate_cpanel_login((int) $evctl->record_id, $this->email, (int) $this->idorganization);
         $contact_data = array("firstname" => $this->firstname, "lastname" => $this->lastname, "email" => $this->email, "password" => $pass);
         $this->send_cpanel_login_details($contact_data);
         $_SESSION["do_crm_messages"]->set_message('success', _('Portal user is created and email sent with the details ! '));
         $next_page = NavigationControl::getNavigationLink('Contacts', "detail");
         $dis = new Display($next_page);
         $dis->addParam("sqrecord", $evctl->record_id);
         $evctl->setDisplayNext($dis);
     } else {
         $_SESSION["do_crm_messages"]->set_message('error', $err);
         $next_page = NavigationControl::getNavigationLink('Contacts', "detail");
         $dis = new Display($next_page);
         $dis->addParam("sqrecord", $evctl->record_id);
         $evctl->setDisplayNext($dis);
     }
 }
                     $error_message = "Missing a temporary folder.";
                     break;
                 case UPLOAD_ERR_CANT_WRITE:
                     $error_message = "Failed to write file to disk";
                     break;
                 default:
                     $error_message = "Unknown File Error";
             }
             $this->setError("<b>File Upload</b> " . $error_message . " - " . $this->getErrorMessage());
             if (strlen($errorpage) > 0) {
                 $urlerror = $errorpage;
             } else {
                 $urlerror = $this->getMessagePage();
             }
             $disp = new Display($urlerror);
             $disp->addParam("message", $strUnabletoSave . "  " . $error_message);
             $this->updateparam("doSave", "no");
             $this->setDisplayNext($disp);
         } else {
             move_uploaded_file($userfile, $destpath);
             copy($destpath, $thumbdestpath);
         }
         $fields[$filefield[$fidx]] = $val;
         $this->updateparam("fields", $fields);
     }
     $uploaded_files[$filefield[$fidx]] = $destpath;
     $uploaded_thumbfiles[$filefield[$fidx]] = $thumbdestpath;
     $this->setLog("\n Uploaded files: " . $filefield[$fidx] . " = " . $destpath);
     $this->setLog("\n Uploaded Thumb files: " . $filefield[$fidx] . " = " . $thumbdestpath);
 }
 $this->updateParam("uploaded_files", $uploaded_files);
Esempio n. 27
0
 /**
  * Event function to update the organization data
  * @param object $evctl
  */
 public function eventEditRecord(EventControler $evctl)
 {
     $id_entity = (int) $evctl->sqrecord;
     if ($id_entity > 0 && true === $_SESSION["do_crm_action_permission"]->action_permitted('edit', 11, (int) $evctl->sqrecord)) {
         $obj = $this->getId($id_entity);
         $obj = (object) $obj;
         // convert the data array to Object
         $do_process_plugins = new CRMPluginProcessor();
         // process before update plugin. If any error is raised display that.
         $do_process_plugins->process_action_plugins((int) $evctl->idmodule, $evctl, 3, $id_entity, $obj);
         if (strlen($do_process_plugins->get_error()) > 2) {
             $_SESSION["do_crm_messages"]->set_message('error', $do_process_plugins->get_error());
             $next_page = NavigationControl::getNavigationLink($evctl->module, "edit");
             $dis = new Display($next_page);
             $dis->addParam("sqrecord", $id_entity);
             if ($evctl->return_page != '') {
                 $dis->addParam("return_page", $evctl->return_page);
             }
             $evctl->setDisplayNext($dis);
         } else {
             $do_crm_fields = new CRMFields();
             $crm_fields = $do_crm_fields->get_field_information_by_module_as_array((int) $evctl->idmodule);
             $table_entity = 'vendor';
             $table_entity_address = 'vendor_address';
             $table_entity_custom = 'vendor_custom_fld';
             $table_entity_to_grp = 'vendor_to_grp_rel';
             $entity_data_array = array();
             $custom_data_array = array();
             $addr_data_array = array();
             $assigned_to_as_group = false;
             foreach ($crm_fields as $crm_fields) {
                 $field_name = $crm_fields["field_name"];
                 $field_value = $do_crm_fields->convert_field_value_onsave($crm_fields, $evctl, 'edit');
                 if (is_array($field_value) && count($field_value) > 0) {
                     if ($field_value["field_type"] == 15) {
                         $field_name = 'iduser';
                         $value = $field_value["value"];
                         $assigned_to_as_group = $field_value["assigned_to_as_group"];
                         $group_id = $field_value["group_id"];
                     } elseif ($field_value["field_type"] == 12) {
                         $value = $field_value["name"];
                         $avatar_array[] = $field_value;
                     }
                 } else {
                     $value = $field_value;
                 }
                 if ($crm_fields["table_name"] == $table_entity && $crm_fields["idblock"] > 0) {
                     $entity_data_array[$field_name] = $value;
                 }
                 if ($crm_fields["table_name"] == $table_entity_address && $crm_fields["idblock"] > 0) {
                     $addr_data_array[$field_name] = $value;
                 }
                 if ($crm_fields["table_name"] == $table_entity_custom && $crm_fields["idblock"] > 0) {
                     $custom_data_array[$field_name] = $value;
                 }
             }
             $this->update(array($this->primary_key => $id_entity), $table_entity, $entity_data_array);
             //updating the last_modified,last_modified_by
             $q_upd = "\n\t\t\t\tupdate `" . $this->getTable() . "` set \n\t\t\t\t`last_modified` = ? ,\n\t\t\t\t`last_modified_by` = ? \n\t\t\t\twhere `" . $this->primary_key . "` = ?";
             $this->query($q_upd, array(date("Y-m-d H:i:s"), $_SESSION["do_user"]->iduser, $id_entity));
             if (count($custom_data_array) > 0) {
                 $this->update(array($this->primary_key => $id_entity), $table_entity_custom, $custom_data_array);
             }
             if (count($addr_data_array) > 0) {
                 $this->update(array($this->primary_key => $id_entity), $table_entity_address, $addr_data_array);
             }
             if ($assigned_to_as_group === false) {
                 $qry_grp_rel = "DELETE from `{$table_entity_to_grp}` where idvendor = ? LIMIT 1";
                 $this->query($qry_grp_rel, array($id_entity));
             } else {
                 $qry_grp_rel = "select * from `{$table_entity_to_grp}` where idvendor = ?";
                 $this->query($qry_grp_rel, array($id_entity));
                 if ($this->getNumRows() > 0) {
                     $this->next();
                     $id_grp_rel = $this->idvendor_to_grp_rel;
                     $q_upd = "\n\t\t\t\t\t\tupdate `{$table_entity_to_grp}` set \n\t\t\t\t\t\t`idgroup` = ?\n\t\t\t\t\t\twhere `idvendor_to_grp_rel` = ? LIMIT 1";
                     $this->query($q_upd, array($group_id, $id_grp_rel));
                 } else {
                     $this->insert($table_entity_to_grp, array("idvendor" => $id_entity, "idgroup" => $group_id));
                 }
             }
             // Record the history
             $do_data_history = new DataHistory();
             $do_data_history->add_history($id_entity, (int) $evctl->idmodule, 'edit');
             $do_data_history->add_history_value_changes($id_entity, (int) $evctl->idmodule, $obj, $evctl);
             //record the feed
             $feed_other_assigne = array();
             if ($assigned_to_as_group === true) {
                 $feed_other_assigne = array("related" => "group", "data" => array("key" => "newgroup", "val" => $group_id));
             }
             $do_feed_queue = new LiveFeedQueue();
             $do_feed_queue->add_feed_queue($id_entity, (int) $evctl->idmodule, $evctl->vendor_name, 'edit', $feed_other_assigne);
             // process after update plugin
             $do_process_plugins->process_action_plugins((int) $evctl->idmodule, $evctl, 4, $id_entity, $obj);
             $_SESSION["do_crm_messages"]->set_message('success', _('Data updated successfully !'));
             $next_page = NavigationControl::getNavigationLink($evctl->module, "detail");
             $dis = new Display($next_page);
             $dis->addParam("sqrecord", $id_entity);
             $evctl->setDisplayNext($dis);
         }
     } else {
         $_SESSION["do_crm_messages"]->set_message('error', _('You do not have permission to edit the record ! '));
         $next_page = NavigationControl::getNavigationLink($evctl->module, "list");
         $dis = new Display($next_page);
         $evctl->setDisplayNext($dis);
     }
 }
Esempio n. 28
0
 /**
  * Event function to discard the last import
  * will set the deleted = 0 for the last imported data for the module
  * @param object $evctl
  */
 public function eventDiscardImport(EventControler $evctl)
 {
     $import_module_id = $this->get_import_module_id();
     switch ($import_module_id) {
         case 3:
             $import_object = new LeadsImport();
             break;
         case 4:
             $import_object = new ContactsImport();
             break;
         case 5:
             $import_object = new PotentialsImport();
             break;
         case 6:
             $import_object = new OrganizationImport();
             break;
         case 11:
             $import_object = new VendorImport();
             break;
         case 12:
             $import_object = new ProductsImport();
             break;
     }
     $qry = "\n\t\tselect * from " . $this->getTable() . " \n\t\twhere \n\t\t`idmodule` = " . $import_module_id . " \n\t\tAND `iduser` = " . $_SESSION["do_user"]->iduser;
     $stmt = $this->getDbConnection()->executeQuery($qry, array("idmodule" => $import_module_id, "iduser" => $_SESSION["do_user"]->iduser));
     if ($stmt->rowCount() > 0) {
         while ($data = $stmt->fetch()) {
             $qry = "\n\t\t\t\tupdate " . $import_object->getTable() . " \n\t\t\t\tset `deleted` = 1\n\t\t\t\twhere `" . $import_object->primary_key . "` = ?\n\t\t\t\tAND `iduser` =  ? limit 1 ";
             $import_object->query($qry, array($data["idrecord"], $data["iduser"]));
         }
     }
     $this->clean_previous_imports();
     $next_page = NavigationControl::getNavigationLink("Import", "index");
     $dis = new Display($next_page);
     $dis->addParam("return_module", $this->get_import_module_id());
     $evctl->setDisplayNext($dis);
 }
Esempio n. 29
0
if (!isset($strNo)) {
    $strNo = "No";
}
//$table = $this->getParam("table");
$primary_key_var = $this->getParam("primary_key_var");
$primary_key_value = $this->getParam($primary_key_var);
$submitbutton = $this->getParam("submitbutton");
if ($submitbutton != "Cancel") {
    global $PHP_SELF;
    $this->setLogRun(false);
    if (defined("RADRIA_LOG_RUN_MYDB_EVENTS")) {
        $this->setLogRun(RADRIA_LOG_RUN_MYDB_EVENTS);
    }
    $this->setLog("\n\n Start mydb.manageRecord " . date("Y/m/d H:i:s"));
    $disp = new Display($formpage);
    $disp->addParam("mydb_num", $mydb_num);
    if (strlen($errorpage) > 0) {
        $dispError = new Display($errorpage);
    } else {
        $dispError = new Display($this->getMessagePage());
    }
    if ($eventaction == "Add") {
        if (strlen($goto) > 0 && strlen($table) > 0 && strlen($formpage) > 0) {
            if (ereg("\\?", $goto)) {
                $sep = "&";
            } else {
                $sep = "?";
            }
            $urlnext = $goto;
            $goto = urlencode($urlnext);
            $disp->addParam("table", $table);
Esempio n. 30
0
         $fieldlist = ereg_replace(', $', '', $fieldlist);
         $valuelist = ereg_replace(', $', '', $valuelist);
         $query = "INSERT INTO `{$table}` ({$fieldlist}) VALUES ({$valuelist})";
     }
     $this->setLog("\n Running query:\n" . $query);
     $message = urlencode($strInsertOk);
     $sql_query = $query;
     $qSaveData = new sqlQuery($this->dbc);
     $result = $qSaveData->query($query);
     $uniqid = $qSaveData->getInsertId($table, "id" . $table);
     $this->addParam("insertid", $uniqid);
     if (!$result) {
         $error = $qSaveData->getError();
         $this->addParam("recordinserted", "no");
         $disp->setPage($urlerror);
         $disp->addParam("message", $strInsertError . $error);
     } else {
         $disp->setPage($goto);
         if (strlen($setmessage) > 0) {
             $strInsertOk = $setmessage;
         }
         $this->addParam("recordinserted", "yes");
         $disp->addParam("message", $strInsertOk);
         $disp->addParam("insertid", $uniqid);
         $disp->addParam("updage", "no");
     }
     $this->setDisplayNext($disp);
 }
 if (!empty($_SERVER['PHP_SELF'])) {
     $disp->save("displayAddRecord", $_SERVER['PHP_SELF']);
 }