/**
  * 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);
 }
示例#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);
 }
示例#3
0
 function eventStopSharingNotes(EventControler $evtcl)
 {
     $dispMsg = new Display($evtcl->goto);
     $q = new sqlQuery($this->getDbCon());
     $q->query("UPDATE contact SET portal_code = '' WHERE idcontact =" . $this->idcontact);
     $_SESSION['in_page_message'] = 'url portal stoped';
     $evtcl->setDisplayNext($dispMsg);
 }
 /**
  * function to update the datashare permission across the module
  * @param object $evctl
  */
 public function eventUpdateModuleDataShareRel(EventControler $evctl)
 {
     $permission = $_SESSION["do_user"]->is_admin == 1 ? true : false;
     if (true === $permission) {
         $qry = "select idmodule_datashare_rel,idmodule from `" . $this->getTable() . "`";
         $stmt = $this->getDbConnection()->executeQuery($qry);
         while ($data = $stmt->fetch()) {
             $datashare_permission_form_name = 'mod_' . $data["idmodule"];
             $permission_flag = $evctl->{$datashare_permission_form_name};
             $this->cleanValues();
             $this->permission_flag = $permission_flag;
             $this->update($data["idmodule_datashare_rel"]);
         }
         $dis = new Display($evctl->next_page);
         $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);
     }
 }
示例#5
0
 /**
    Event Method to delete a note from the db and keep the data in the session for undo
    calls to member method deleteNote()
    @param Intinger id : id of the note
    @param String context : can be now ContactNote or ProjectDiscuss
 */
 function eventTempDelNoteById(EventControler $evtcl)
 {
     $idnote = $evtcl->id;
     $context = $evtcl->context;
     if ($this->isdeletePermitted($idnote, $context) === true) {
         if (!is_object($_SESSION['NoteDeleted'])) {
             $this->sessionPersistent("NoteDeleted", "logout.php", OFUZ_TTL);
         }
         $this->deleteNote($idnote, $context);
     } else {
         $_SESSION['errorMessage'] = _('Opps !! Looks like you are trying to delete a record which does not belong to you.');
         $evtcl->setDisplayNext(new Display("error.php"));
     }
 }
示例#6
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);
     }
 }
示例#8
0
 /**
  * event function to activate a plugin from setting page
  * @param object $evctl
  */
 public function eventActivatePlugin(EventControler $evctl)
 {
     $permission = $_SESSION["do_user"]->is_admin == 1 ? true : false;
     if (true === $permission) {
         if (trim($evctl->plugin_name) != '') {
             if (false === $this->get_plugin_by_name($evctl->plugin_name)) {
                 $this->addNew();
                 $this->name = trim($evctl->plugin_name);
                 $this->add();
                 $plugin_id = $this->getInsertId();
                 $this->do_sorting_on_activate(trim($evctl->plugin_name));
                 echo $plugin_id;
             }
         }
     } else {
         $_SESSION["do_crm_messages"]->set_message('error', _('You do not have permission to delete record !'));
         $next_page = NavigationControl::getNavigationLink("Settings", "plugins");
         $dis = new Display($next_page);
         $evctl->setDisplayNext($dis);
     }
 }
示例#9
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);
     }
 }
示例#10
0
 /**
  * event function to delete the role
  * before deleting it will set the idrole of users to a new selected role which were earlier attached with the role to be deleted
  * @param object $evctl
  * @see popups/role_delete.php
  */
 public function eventDeleteRole(EventControler $evctl)
 {
     $permission = $_SESSION["do_user"]->is_admin == 1 ? true : false;
     if (true === $permission) {
         $do_delete = false;
         $msg = '';
         if ($evctl->idrole != '') {
             if ($evctl->idrole == 'N1' || $evctl->idrole == 'N2') {
                 $msg = _('The role you are trying to delete is not allowd !');
             } else {
                 $role_detail = $this->get_role_detail($evctl->idrole);
                 if (count($role_detail) > 0) {
                     if ($evctl->role_transfer == 'yes') {
                         if ($evctl->idrole_transfer == '') {
                             $msg = _('No role selected to re-assign users !');
                         } else {
                             $do_delete = true;
                         }
                     } else {
                         $do_delete = true;
                     }
                 } else {
                     $msg = _('The role you are trying to delete does not exist !');
                 }
             }
         } else {
             $msg = _('Invalid roleid to perform delete operation !');
         }
         if ($do_delete === false) {
             $_SESSION["do_crm_messages"]->set_message('error', $msg);
             $dis = new Display($evctl->next_page);
             $evctl->setDisplayNext($dis);
         } else {
             $qry = "select * from `role` where `parentrole` like ? AND `idrole` <> ?";
             $this->query($qry, array($role_detail["parentrole"] . '%', $role_detail["idrole"]));
             if ($this->getNumRows() > 0) {
                 while ($this->next()) {
                     $depth = $this->depth;
                     $depth = $depth - 1;
                     $qry1 = "update `role` set `depth` = ? where `idrole` = ? ";
                     $this->getDbConnection()->executeQuery($qry1, array($depth, $this->idrole));
                 }
             }
             $this->query("delete from `role` where `idrole` = ?", array($role_detail["idrole"]));
             $this->query("delete from `role_profile_rel` where `idrole` = ?", array($role_detail["idrole"]));
             if ($evctl->idrole_transfer != '') {
                 $q_upd = "\n\t\t\t\t\tupdate `user` \n\t\t\t\t\tset `idrole` = ?\n\t\t\t\t\twhere `idrole` = ?\n\t\t\t\t\t";
                 $this->query($q_upd, array($evctl->idrole_transfer, $role_detail["idrole"]));
             }
             $_SESSION["do_crm_messages"]->set_message('success', _('Role has been deleted successfully ! '));
             $dis = new Display($evctl->next_page);
             $evctl->setDisplayNext($dis);
         }
     } else {
         $_SESSION["do_crm_messages"]->set_message('error', _('You do not have permission to delete record !'));
         $next_page = NavigationControl::getNavigationLink("Settings", "index");
         $dis = new Display($next_page);
         $evctl->setDisplayNext($dis);
     }
 }
示例#11
0
 /**
  * event function to signout
  * @param object $evctl
  */
 public function eventLogout(\EventControler $evctl)
 {
     //do login audit
     $this->setFree();
     $this->free();
     // Unset all of the session variables.
     $_SESSION = array();
     // If it's desired to kill the session, also delete the session cookie.
     // Note: This will destroy the session, and not just the session data!
     if (isset($_COOKIE[session_name()])) {
         setcookie(session_name(), '', time() - 42000, '/cpanel/');
     }
     // Finally, destroy the session.
     session_destroy();
     $dis = new \Display('/cpanel/modules/User/login');
     $evctl->setDisplayNext($dis);
 }
示例#12
0
 /**
  * function to delete a group
  * while deleting a group the related data will be transferred to user or group which is selected
  * which is selected during the delete process
  * @param object $evctl
  * @see self :: transfer_group_data_to_user()
  * @see self :: transfer_group_data_to_group()
  * @see popups/delete_group_modal.php
  */
 public function eventDeleteRecord(EventControler $evctl)
 {
     $permission = $_SESSION["do_user"]->is_admin == 1 ? true : false;
     if (true === $permission) {
         $id = (int) $evctl->id;
         $group_transfer_opt = false;
         $transfer_to_user = false;
         $transfer_to_group = false;
         if ($evctl->group_transfer_opt == 'yes') {
             $group_transfer_opt = true;
         }
         if ($group_transfer_opt === true) {
             if ($evctl->assigned_to_selector == 'user') {
                 $transfer_to_user = true;
             } elseif ($evctl->assigned_to_selector == 'group') {
                 $transfer_to_group = true;
             }
         } else {
             $transfer_to_user = true;
         }
         if (($transfer_to_user === true || $transfer_to_group === true) && $id > 0) {
             $do_module = new Module();
             $do_module->getAll();
             while ($do_module->next()) {
                 if ($do_module->idmodule == 1 || $do_module->idmodule == 7 || $do_module->idmodule == 8 || $do_module->idmodule == 9) {
                     continue;
                 }
                 $module_name = $do_module->name;
                 $object = new $module_name();
                 if ($transfer_to_user === true) {
                     // transfer group data to selected user
                     $idtransfer = (int) $evctl->user_selector;
                     $this->transfer_group_data_to_user($object, $id, $idtransfer);
                 } elseif ($transfer_to_group === true) {
                     // transfer group data to selected group
                     $idtransfer = (int) $evctl->group_selector;
                     $this->transfer_group_data_to_group($object, $id, $idtransfer);
                 }
             }
             $this->query("delete from `group` where `idgroup` = ?", array($id));
             $_SESSION["do_crm_messages"]->set_message('success', _('Group has been deleted successfully and related data has been transferred !'));
         } else {
             $_SESSION["do_crm_messages"]->set_message('error', _('Unable to delete the group,id is missing !'));
         }
     } else {
         $_SESSION["do_crm_messages"]->set_message('error', _('You do not have permission to delete record !'));
         $next_page = NavigationControl::getNavigationLink("Settings", "index");
         $dis = new Display($next_page);
         $evctl->setDisplayNext($dis);
     }
 }
示例#13
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 ! '));
     }
 }
示例#14
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);
 }
示例#15
0
 /**
  * eventGetForMailMerge
  * Get the list of contact for mailmerge
  * load in the current contact object the list of
  * selected contacts from the contacts.php
  * Then redirect to the contact_sendemail.php.
  */
 function eventGetForMailMerge(EventControler $event_controler)
 {
     $idcontacts = $event_controler->getParam("ck");
     $sql_in = "(";
     foreach ($idcontacts as $idcontact) {
         $sql_in .= $idcontact . ",";
     }
     $sql_in = substr($sql_in, 0, -1);
     $sql_in .= ")";
     $tag_search = $this->getSearchTags();
     if (is_array($tag_search) && count($tag_search > 0)) {
         $_SESSION['searched_tags'] = $tag_search;
     }
     $this->clearSearch();
     $this->setSqlQuery("SELECT * FROM contact WHERE idcontact in " . $sql_in);
     $event_controler->goto = "contact_sendemail.php";
     $event_controler->setDisplayNext(new Display("contact_sendemail.php"));
 }
示例#16
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);
     }
 }
示例#17
0
 /**
  * event function to signout
  * @param object $evctl
  */
 public function eventLogout(EventControler $evctl)
 {
     //do login audit
     $do_login_audit = new LoginAudit();
     $do_login_audit->do_login_audit("Logout");
     $this->setFree();
     $this->free();
     // Unset all of the session variables.
     $_SESSION = array();
     // If it's desired to kill the session, also delete the session cookie.
     // Note: This will destroy the session, and not just the session data!
     if (isset($_COOKIE[session_name()])) {
         setcookie(session_name(), '', time() - 42000, '/');
     }
     // Finally, destroy the session.
     session_destroy();
     $dis = new Display(NavigationControl::getNavigationLink("User", "login"));
     $evctl->setDisplayNext($dis);
 }
示例#18
0
 /**
  * Event method to check the invoice logo extension
  * GIF is not supported by the html2pdf for PDF generation so if user 
  * try to upload gif file give them a message
  */
 function eventCheckInvLogoExtension(EventControler $evtcl)
 {
     // print_r($_FILES);
     $filename = $_FILES['userfile']['name'][0];
     if (is_array($_FILES['userfile']['type'])) {
         $file_type = strtolower($_FILES['userfile']['type'][0]);
     }
     $filename = strtolower($filename);
     $exts = split("[/\\.]", $filename);
     $n = count($exts) - 1;
     $exts = $exts[$n];
     if ($exts == "gif" || $file_type == "image/gif") {
         $evtcl->updateparam("doSave", "no");
         unset($_FILES);
         $_SESSION['in_page_message'] = _("GIF files for logo is not supported");
         $evtcl->setDisplayNext(new Display("settings_invoice.php"));
     }
 }
示例#19
0
 function eventSelectExtraAmount(EventControler $evtcl)
 {
     $_SESSION['extra_amt'] = $evtcl->extra_amt;
     $_SESSION['ref_num'] = $evtcl->ref_num;
     $_SESSION['last_paylogid'] = $evtcl->idpaymentlog;
     //$evtcl->addParam("status","Overdue");
     //$evtcl->addParam("goto","invoices.php");
     //$evtcl->addParam("type","User");
     //$_SESSION['do_invoice_list']->eventFilterInvoice($evtcl);
     $evtcl->setDisplayNext(new Display("invoices_unpaid.php"));
 }
 function eventAddTranslateLanguage(EventControler $evtcl)
 {
     unset($_SESSION["et_content_src"]);
     $this->key_name = $evtcl->key_name;
     $this->content = $evtcl->et_content_dst;
     $this->language = $this->dest_lng;
     $this->context = $evtcl->context;
     $this->can_close = $evtcl->can_close;
     $this->close_duration = $evtcl->close_duration;
     $this->plan = $evtcl->plan;
     $this->add();
     $evtcl->setDisplayNext(new Display($evtcl->goto));
 }
示例#21
0
 /**
  * Function to delete the invoice payment
  * For single payment and single invoice it will delete the data straight away
  * If the payment is attached to multiple invoices then it will first show the alert to the user and 
  * if user wants to delete the payment then it will delete the payment from the attached invoices
  * @param object $evtcl
  */
 function eventDeletePaymentLog(EventControler $evtcl)
 {
     if ($evtcl->id) {
         $q = new sqlQuery($this->getDbCon());
         $q1 = new sqlQuery($this->getDbCon());
         $sql = "SELECT COUNT(payment_invoice.idpayment) AS num_inv \n              FROM payment_invoice INNER JOIN paymentlog \n              ON paymentlog.idpaymentlog = payment_invoice.idpayment\n              WHERE paymentlog.idpaymentlog = {$evtcl->id}\n                    ";
         $q->query($sql);
         if ($q->getNumRows()) {
             $q->fetch();
             $num_inv = $q->getData("num_inv");
             if ($num_inv == 1) {
                 $do_inv = new Invoice();
                 $this->getId($evtcl->id);
                 $idinvoice = $this->idinvoice;
                 $sql_del_paymentlog = "DELETE FROM {$this->table} WHERE idpaymentlog = '{$evtcl->id}'";
                 $sql_del_paymentinv = "DELETE FROM payment_invoice WHERE idpayment = '{$evtcl->id}'";
                 $sql_del_ext_amt = "DELETE FROM paymentlog_extra_amount WHERE idpaymentlog = '{$evtcl->id}'";
                 $q->query($sql_del_paymentlog);
                 $q->query($sql_del_paymentinv);
                 $q->query($sql_del_ext_amt);
                 $do_inv->deletePaymentFromInvoice($idinvoice, $evtcl->amt);
                 $_SESSION['in_page_message'] = _("Payment has been deducted from the invoice.");
             }
             if ($num_inv > 1) {
                 $do_inv = new Invoice();
                 if ($evtcl->del_mul_confirm != 'Yes') {
                     $_SESSION['in_page_message'] = _("This Payment is shared with multiple invoices.");
                     $_SESSION['in_page_message_inv_mul_pay_del'] = 'Yes';
                     $_SESSION['in_page_message_inv_idpaymentlog'] = (int) $evtcl->id;
                     $evtcl->setDisplayNext(new Display("invoice_alert.php"));
                 } else {
                     $sql = "SELECT payment_invoice.* \n                                FROM payment_invoice \n                                INNER JOIN paymentlog \n                                ON paymentlog.idpaymentlog = payment_invoice.idpayment\n                                WHERE paymentlog.idpaymentlog = {$evtcl->id}\n                          ";
                     $q1->query($sql);
                     if ($q1->getNumRows() > 0) {
                         while ($q1->fetch()) {
                             $idinvoice = $q1->getData("idinvoice");
                             $idpayment = $q1->getData("idpayment");
                             $amt = $q1->getData("amount");
                             $do_inv->deletePaymentFromInvoice($idinvoice, $amt);
                         }
                         $sql_del_paymentlog = "DELETE FROM {$this->table} WHERE idpaymentlog = '{$idpayment}'";
                         $sql_del_paymentinv = "DELETE FROM payment_invoice WHERE idpayment = '{$idpayment}'";
                         $sql_del_ext_amt = "DELETE FROM paymentlog_extra_amount WHERE idpaymentlog = '{$idpayment}'";
                         $q1->query($sql_del_paymentlog);
                         $q1->query($sql_del_paymentinv);
                         $q1->query($sql_del_ext_amt);
                         $evtcl->setDisplayNext(new Display("/Invoice/" . $_SESSION['do_invoice']->idinvoice));
                     }
                 }
             }
         }
     }
 }
示例#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);
 }
示例#23
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);
     }
 }
示例#24
0
 function eventUpdateTeamCWs(EventControler $evtcl)
 {
     $this->query("DELETE FROM team_users WHERE idteam = {$evtcl->idteam}");
     foreach ($evtcl->coworker as $idcoworker) {
         $con = new sqlQuery($this->getDbCon());
         echo $sql = "INSERT INTO team_users VALUES(null,{$evtcl->idteam}, {$idcoworker})";
         $con->query($sql);
     }
     $evtcl->setDisplayNext(new Display($evtcl->goto));
 }
示例#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);
     }
 }
示例#26
0
 /**
  * Event Method Cancel Multi Payment for a session
  * @param $evtcl -- Object
  */
 function eventCancelMultiPayment(EventControler $evtcl)
 {
     $_SESSION['show_past_due'] = '';
     $_SESSION['extra_amt'] = '';
     $_SESSION['last_paylogid'] = '';
     $_SESSION['ref_num'] = '';
     $evtcl->setDisplayNext(new Display("invoices.php"));
 }
示例#27
0
 /**
  * Function to add git repo for the project
  * @param eventcontroller 
  **/
 function eventAddProjectGitRepo(EventControler $evtcl)
 {
     $goto = $evtcl->goto;
     $q = new sqlQuery($this->getDbCon());
     $q->query("Insert Into git_project (iduser_gitrepo,idproject) values('" . $evtcl->iduser_gitrepo . "','" . $evtcl->idproject . "')");
     $evtcl->setDisplayNext(new Display($goto));
 }
示例#28
0
 function eventSetDestinationLanguage(EventControler $evtcl)
 {
     $_SESSION["src_lang"] = $evtcl->src_lang;
     $_SESSION["dest_lang"] = $evtcl->dest_lang;
     $evtcl->setDisplayNext(new Display($evtcl->goto));
 }
示例#29
0
 function eventExportContacts(EventControler $evtcl)
 {
     $iduser = $_SESSION['do_User']->iduser;
     $do_contact = new Contact();
     $do_contact->getAllContactsForAUser();
     $num_contacts = $do_contact->getNumRows();
     $report_name = "ofuz_" . $iduser . "_report" . ".xls";
     $fname = "xls_report/{$report_name}";
     $workbook =& new writeexcel_workbook($fname);
     $worksheet =& $workbook->addworksheet('Report');
     $heading =& $workbook->addformat(array('align' => 'center', 'bold' => 1, 'fg_color' => 'yellow'));
     $right =& $workbook->addformat(array('align' => 'right'));
     $left =& $workbook->addformat(array('align' => 'left'));
     # Create a border format
     $border1 =& $workbook->addformat();
     $border1->set_color('magenta');
     $border1->set_bold();
     $border1->set_size(15);
     $border1->set_pattern(0x1);
     $border1->set_fg_color('aqua');
     $border1->set_border_color('yellow');
     $border1->set_top(6);
     $border1->set_bottom(6);
     $border1->set_left(6);
     $border1->set_align('center');
     $border1->set_align('vcenter');
     $border1->set_merge();
     # This is the key feature
     # Create another border format.
     $border2 =& $workbook->addformat();
     $border2->set_color('magenta');
     $border2->set_bold();
     $border2->set_size(15);
     $border2->set_pattern(0x1);
     $border2->set_fg_color('aqua');
     $border2->set_border_color('yellow');
     $border2->set_top(6);
     $border2->set_bottom(6);
     $border2->set_right(6);
     $border2->set_align('center');
     $border2->set_align('vcenter');
     $border2->set_merge();
     # This is the key feature
     /*
     		# Set the row height for row 0 (heading current date)
     		$worksheet->set_row(0, 24);
     	
     		$worksheet->write      (0, 0, "Welcome", $border1);
     		$worksheet->write_blank(0, 1,                        $border2);
     		$worksheet->write_blank(0, 2,                        $border2);
     */
     # Set the row height for row 0 (heading current date)
     $worksheet->set_row(1, 24);
     $current_date = _("As on ") . date('m/d/Y h:i:s') . ", ";
     $heading_total_contacts = $current_date . _("Total Contacts : ") . $num_contacts;
     $worksheet->write(1, 0, $heading_total_contacts, $border1);
     $worksheet->write_blank(1, 1, $border2);
     $worksheet->write_blank(1, 2, $border2);
     $worksheet->write_blank(1, 3, $border2);
     $worksheet->write_blank(1, 4, $border2);
     $worksheet->write_blank(1, 5, $border2);
     $report_heading = array('First Name', 'Last Name', 'Company', 'Position', 'Email', 'Phone', 'Tags');
     $col = 0;
     foreach ($report_heading as $colum) {
         $worksheet->write(3, $col, $colum, $heading);
         $col++;
     }
     $row = 4;
     if ($num_contacts) {
         while ($do_contact->next()) {
             $col = 0;
             $worksheet->write($row, $col, $do_contact->getData('firstname'), $left);
             $col++;
             $worksheet->write($row, $col, $do_contact->getData('lastname'), $left);
             $col++;
             $worksheet->write($row, $col, $do_contact->getData('company'), $left);
             $col++;
             $worksheet->write($row, $col, $do_contact->getData('position'), $left);
             $col++;
             $worksheet->write($row, $col, $do_contact->getData('email_address'), $left);
             $col++;
             $worksheet->write($row, $col, $do_contact->getData('phone_number'), $left);
             $col++;
             $worksheet->write($row, $col, $do_contact->getData('tags'), $left);
             $row++;
         }
     } else {
     }
     $workbook->close();
     //header("Location: {$fname}");
     $evtcl->setDisplayNext(new Display($fname));
 }
 /**
  * This event un-suspends (makes active) a User.Just changes the status to 'active'.
  * @param obj : EventControler
  * @return void
  */
 public function eventUnsuspendUser(EventControler $evtcl)
 {
     $sql = "UPDATE `user`\n            SET `status` = 'active'\n            WHERE `iduser` = " . $evtcl->iduser . "\n          ";
     $this->query($sql);
     $evtcl->setDisplayNext(new Display($evtcl->goto));
 }