Exemplo n.º 1
2
    /**
     * Upload documents
     * @param $uploadType
     * @param bool $withoutMessage
     * @return int
     */
    public static function uploadDocuments($uploadType, $withoutMessage = false) {

        if(isset($_SESSION[$uploadType]) && count($_SESSION[$uploadType]) > 0) {
            $settings = UsersSettings::model()->findByAttributes(array(
                'User_ID' => Yii::app()->user->userID,
            ));

            //get default bank account
            $condition = new CDbCriteria();
            $condition->condition = "users_project_list.User_ID = '" . Yii::app()->user->userID . "'";
            $condition->addCondition("users_project_list.Client_ID = '" . Yii::app()->user->clientID . "'");
            $condition->addCondition("t.Account_Num_ID = '" . $settings->Default_Bank_Acct . "'");
            $condition->join = "LEFT JOIN projects ON projects.Project_ID = t.Project_ID
                                LEFT JOIN users_project_list ON users_project_list.Project_ID = t.Project_ID";
            $bankAcct = BankAcctNums::model()->with('client.company', 'project')->find($condition);
            $defaultBankAcct = 0;
            if ($bankAcct) {
                $defaultBankAcct = $settings->Default_Bank_Acct;
            }

            //get user to send email
            $person_to_email = false;
            if (Yii::app()->user->id != 'user' && Yii::app()->user->id != 'single_user') {
                $person_to_email = Users::model()->with('person')->findByPk(Yii::app()->user->userID);
            } else {
                $condition = new CDbCriteria();
                $condition->join = "LEFT JOIN users_client_list ON users_client_list.User_ID = t.User_ID";
                $condition->addInCondition('users_client_list.User_Type', array(UsersClientList::APPROVER, UsersClientList::PROCESSOR, UsersClientList::CLIENT_ADMIN));
                $condition->addInCondition('t.User_Type', array(Users::ADMIN, Users::DB_ADMIN, Users::DATA_ENTRY_CLERK), "OR");
                $condition->addCondition("users_client_list.Client_ID = '" . Yii::app()->user->clientID . "'");
                $person_to_email = Users::model()->with('person')->find($condition);
            }


            foreach ($_SESSION[$uploadType] as $key => $current_upload_file) {
                // check fed id
                if ($current_upload_file['doctype'] == self::W9) {
                    if (!preg_match('/^(\d{2}\-\d{7})|(\d{3}\-\d{2}\-\d{4})|(IN[-]\d{6})|(T0[-]\d{7})$/', $current_upload_file['fed_id'])) {
                        return 2;
                    }
                }
            }


            // insert documents into DB
            foreach ($_SESSION[$uploadType] as $key => $current_upload_file) {

                if (file_exists($current_upload_file['filepath'])) {
                    // create document

                    $document = new Documents();
                    $document->Document_Type = $current_upload_file['doctype'];
                    $document->User_ID = Yii::app()->user->userID;
                    $document->Client_ID = Yii::app()->user->clientID;
                    $document->Project_ID = Yii::app()->user->projectID;
                    $document->Created = date("Y-m-d H:i:s");
                    $document->save();
                    $new_doc_id=$document->Document_ID;

                    Audits::LogAction($document->Document_ID ,Audits::ACTION_UPLOAD);

                    // insert image
                    $image = new Images();
                    $imageData = addslashes(fread(fopen($current_upload_file['filepath'],"rb"),filesize($current_upload_file['filepath'])));
                    //$imageData = FileModification::ImageToPdfByFilePath($current_upload_file['filepath']);
                    $image->Document_ID = $document->Document_ID;
                    $image->Img = $imageData;
                    $image->File_Name = $current_upload_file['name'];
                    $image->Mime_Type = $current_upload_file['mimetype'];
                    $image->File_Hash = sha1_file($current_upload_file['filepath']);
                    $image->File_Size = intval(filesize($current_upload_file['filepath']));
                    $image->Pages_Count = FileModification::calculatePagesByPath($current_upload_file['filepath']);

                    $image->save();

                    $infile = @file_get_contents($current_upload_file['filepath'], FILE_BINARY);
                    if (($current_upload_file['mimetype'] == 'application/pdf' && $image->findPdfText($infile) == '')
                        || $current_upload_file['mimetype'] != 'application/pdf') {
                        Documents::crateDocumentThumbnail($current_upload_file['filepath'], 'thumbs', $current_upload_file['mimetype'], $document->Document_ID, 80);
                    }

                    // delete file from temporary catalog and from cache table
                    //unlink($current_upload_file['filepath']);
                    FileCache::deleteBothFromCacheById($current_upload_file['file_id']);

                    if ($current_upload_file['doctype'] == self::W9) {
                        // if document is W9
                        // get additional fields
                        $fedId = trim($current_upload_file['fed_id']);
                        $newCompanyName = trim($current_upload_file['company_name']);

                        // get company info
                        $company = Companies::model()->with('client')->findByAttributes(array(
                            'Company_Fed_ID' => $fedId,
                        ));

                        // create w9
                        $W9 = new W9();
                        $W9->Document_ID = $document->Document_ID;
                        $W9->W9_Owner_ID = Yii::app()->user->clientID;
                        $W9->Creator_ID = Yii::app()->user->userID;
                        $W9->Business_Name = trim($current_upload_file['bus_name']);
                        $W9->Tax_Class =  trim($current_upload_file['tax_name']);

                        // get user info
                        $user = Users::model()->with('person')->findByPk(Yii::app()->user->userID);

                        if ($company) {
                            // if company exisits
                            $client = $company->client;

                            //fill created company with dataentry values from session
                            Companies::fillWithSessionDataEntry($company,$current_upload_file);

                            $existingW9 = W9::model()->findByAttributes(array(
                                'Client_ID' => $client->Client_ID,
                                'W9_Owner_ID' => Yii::app()->user->clientID,
                            ));

                            if ($existingW9) {
                                $W9->Revision_ID = -1;
                            } else {
                                $W9->Revision_ID = 0;
                            }

                            $vendor = Vendors::model()->findByAttributes(array(
                                'Client_Client_ID' => Yii::app()->user->clientID,
                                'Vendor_Client_ID' => $client->Client_ID,
                            ));

                            if (isset($vendor->Active_Relationship) && $vendor->Active_Relationship == Vendors::NOT_ACTIVE_RELATIONSHIP) {
                                $vendor->Active_Relationship = Vendors::ACTIVE_RELATIONSHIP;
                                $vendor->save();
                            } else if (!$vendor && Yii::app()->user->clientID != 0 && Yii::app()->user->clientID != $client->Client_ID) {
                                $vendor = new Vendors();
                                $vendor->Vendor_ID_Shortcut = '';
                                $vendor->Vendor_Client_ID = $client->Client_ID;
                                $vendor->Client_Client_ID = Yii::app()->user->clientID;
                                $vendor->Vendor_Name_Checkprint = '';
                                $vendor->Vendor_1099 = '';
                                $vendor->Vendor_Default_GL = '';
                                $vendor->Vendor_Default_GL_Note = '';
                                $vendor->Vendor_Note_General = '';

                                $vendor->Vendor_Contact = trim($current_upload_file['contact']);
                                $vendor->Vendor_Phone = trim($current_upload_file['phone']);

                                $vendor->save();
                            }
                        } else {
                            //if company does not exists, create new company
                            $client = Companies::createEmptyCompany($fedId, $newCompanyName);
                            $company_model = Companies::model()->findByPk($client->Company_ID);
                            //fill created company with dataentry values from session
                            Companies::fillWithSessionDataEntry($company_model,$current_upload_file);

                            if (Yii::app()->user->clientID != 0) {
                                $vendor = new Vendors();
                                $vendor->Vendor_ID_Shortcut = '';
                                $vendor->Vendor_Client_ID = $client->Client_ID;
                                $vendor->Client_Client_ID = Yii::app()->user->clientID;
                                $vendor->Vendor_Name_Checkprint = '';
                                $vendor->Vendor_1099 = '';
                                $vendor->Vendor_Default_GL = '';
                                $vendor->Vendor_Default_GL_Note = '';
                                $vendor->Vendor_Note_General = '';

                                $vendor->Vendor_Contact = trim($current_upload_file['contact']);
                                $vendor->Vendor_Phone = trim($current_upload_file['phone']);

                                $vendor->save();
                            }

                            $W9->Revision_ID = 0;
                        }

                        // save w9
                        $W9->Client_ID = $client->Client_ID;
                        $W9->save();

                        if ($person_to_email) {
                            Mail::sendNewW9ForDataEntry($person_to_email->person->Email, $person_to_email->person->First_Name, $person_to_email->person->Last_Name);
                        }
                    } else if ($current_upload_file['doctype'] == self::AP) {
                        //create aps
                        $aps = new Aps();
                        $aps->Document_ID = $document->Document_ID;
                        $aps->Vendor_ID = 0;
                        $aps->PO_ID = 0;
                        $aps->AP_Approval_Value = Aps::NOT_READY_FOR_APPROVAL;
                        $aps->Invoice_Number = 0;
                        $aps->save();
                    } else if ($current_upload_file['doctype'] ==  self::PM) {
                        //create payment
                        $payment = new Payments();
                        $payment->Document_ID = $document->Document_ID;
                        $payment->Vendor_ID = 0;
                        $payment->Payment_Check_Number = 0;
                        $payment->Payment_Amount = 0;
                        if ($defaultBankAcct != 0) {
                            $payment->Account_Num_ID = $defaultBankAcct;
                        } else {
                            $payment->Account_Num_ID = 0;
                        }
                        $payment->save();
                    } else if ($current_upload_file['doctype'] == self::PO) {
                        //create pos
                        $po = new Pos();
                        $po->Document_ID = $document->Document_ID;
                        $po->Vendor_ID = 0;
                        $po->PO_Number = Pos::getNewPoNumber();
                        $po->PO_Date = date('Y-m-d');
                        $po->PO_Backup_Document_ID = 0;
                        $po->save();
                    } else if ($current_upload_file['doctype'] == self::PR) {
                        $payroll = new Payrolls();
                        $payroll->Document_ID = $document->Document_ID;
                        $payroll->save();
                    } else if ($current_upload_file['doctype'] == self::JE) {
                        $je = new Journals();
                        $je->Document_ID = $document->Document_ID;
                        $je->save();
                    } else if ($current_upload_file['doctype'] == self::PC) {
                        $pc = new Pcs();
                        $pc->Document_ID = $document->Document_ID;
                        $pc->save();
                    } else if ($current_upload_file['doctype'] == self::AR) {
                        $ar = new Ars();
                        $ar->Document_ID = $document->Document_ID;
                        $ar->save();
                    }
                }
                $arr[$current_upload_file['name']]['string']= Images::getAjaxStringForLastUploadSection($new_doc_id);
                $arr[$current_upload_file['name']]['key']=$key;

            }

            $_SESSION[$uploadType] = array();
            if (!$withoutMessage) {
                Yii::app()->user->setFlash('success', "Documents have been uploaded!");
            }
            return json_encode($arr);
        } else {
            $answer['empty']=1;
            return json_encode($answer);
        }
    }
 function buildDocumentModel()
 {
     global $app_strings;
     try {
         $model = parent::buildDocumentModel();
         $this->generateEntityModel($this->focus, 'PurchaseOrder', 'purchaseorder_', $model);
         $entity = new Contacts();
         if ($this->focusColumnValue('contact_id')) {
             $entity->retrieve_entity_info($this->focusColumnValue('contact_id'), 'Contacts');
         }
         $this->generateEntityModel($entity, 'Contacts', 'contact_', $model);
         $entity = new Vendors();
         if ($this->focusColumnValue('vendor_id')) {
             $entity->retrieve_entity_info($this->focusColumnValue('vendor_id'), 'Vendors');
         }
         $this->generateEntityModel($entity, 'Vendors', 'vendor_', $model);
         $this->generateUi10Models($model);
         $this->generateRelatedListModels($model);
         $model->set('purchaseorder_no', $this->focusColumnValue('purchaseorder_no'));
         return $model;
     } catch (Exception $e) {
         echo '<meta charset="utf-8" />';
         if ($e->getMessage() == $app_strings['LBL_RECORD_DELETE']) {
             echo $app_strings['LBL_RECORD_INCORRECT'];
             echo '<br><br>';
         } else {
             echo $e->getMessage();
             echo '<br><br>';
         }
         return null;
     }
 }
Exemplo n.º 3
0
 /** Constructor which will set the importable_fields as $this->importable_fields[$key]=1 in this object where key is the fieldname in the field table
  */
 function ImportVendors()
 {
     parent::Vendors();
     $this->log = LoggerManager::getLogger('import_vendors');
     $this->db = PearDatabase::getInstance();
     $this->db->println("IMP ImportVendors");
     $this->initImportableFields("Vendors");
     $this->db->println($this->importable_fields);
 }
 public function approveAction()
 {
     $vid = $this->_getParam('vid');
     $v = new Vendors($vid);
     $v->status = Constants::VENDOR_STATUS_APPROVED;
     $v->save();
     // Sending mail
     $subject = "GLAM ME";
     $body = "<p>Congratulations! You have been approved! for next step, please click <br/><a href='http://dev.greatnetsolutions.com" . $this->view->baseUrl() . "/vendor/signup/submission/vid/" . $v->id . "'>This Link</a></p>";
     $mail = Mail::factory();
     $mail->setSubject($subject);
     $mail->addTo($v->email);
     $mail->setBodyHtml($body);
     $mail->send();
     // Set message
     $msg = "You approved!";
     $params = array('msg' => $msg);
     $this->_forward('thankyou', 'signup', 'vendor', $params);
 }
Exemplo n.º 5
0
 /**	function used to create or map with existing vendor if the product has mapped with an vendor during import
  */
 function add_create_vendor()
 {
     global $imported_ids;
     global $current_user;
     $vendor_name = trim($this->column_fields['vendor_id']);
     if (!isset($vendor_name) || $vendor_name == '') {
         return;
     }
     $arr = array();
     // check if it already exists
     $focus = new Vendors();
     $query = '';
     // if user is defining the ec_vendor id to be associated with this contact..
     //Modified to remove the spaces at first and last in ec_account name -- after 4.2 patch 2
     $vendor_name = trim(addslashes($vendor_name));
     //Modified the query to get the available vendor only ie., which is not deleted
     $query = "select * from ec_vendor WHERE vendorname like '%{$vendor_name}%' and deleted=0";
     $result = $this->db->query($query);
     $row = $this->db->fetchByAssoc($result, -1, false);
     // we found a row with that id
     if (isset($row['vendorid']) && $row['vendorid'] != -1) {
         $focus->id = $row['vendorid'];
     }
     // if we didnt find the ec_account, so create it
     if (!isset($focus->id) || $focus->id == '') {
         $focus->column_fields['vendorname'] = $vendor_name;
         $focus->column_fields['assigned_user_id'] = $current_user->id;
         $focus->column_fields['modified_user_id'] = $current_user->id;
         $focus->save("Vendors");
         $vendor_id = $focus->id;
         // avoid duplicate mappings:
         if (!isset($imported_ids[$vendor_id])) {
             $imported_ids[$vendor_id] = 1;
         }
     }
     // now just link the ec_vendor
     $this->column_fields["vendor_id"] = $focus->id;
 }
Exemplo n.º 6
0
    $lead->column_fields["code"] = '99999';
    $lead->column_fields["country"] = 'USA';
    $key = array_rand($comboFieldArray['leadsource_dom']);
    $lead->column_fields["leadsource"] = $comboFieldArray['leadsource_dom'][$key];
    $key = array_rand($comboFieldArray['lead_status_dom']);
    $lead->column_fields["leadstatus"] = $comboFieldArray['lead_status_dom'][$key];
    $key = array_rand($comboFieldArray['rating_dom']);
    $lead->column_fields["rating"] = $comboFieldArray['rating_dom'][$key];
    $titles = array("President", "VP Operations", "VP Sales", "Director Operations", "Director Sales", "Mgr Operations", "IT Developer", "");
    $key = array_rand($titles);
    $lead->column_fields["designation"] = $titles[$key];
    $lead->save("Leads");
}
//Populating Vendor Data
for ($i = 0; $i < 10; $i++) {
    $vendor = new Vendors();
    $vendor->column_fields["vendorname"] = ucfirst(strtolower($first_name_array[$i]));
    $vendor->column_fields["phone"] = create_phone_number();
    $vendor->column_fields["email"] = strtolower($vendor->column_fields["vendorname"]) . "@company.com";
    $website = str_replace($whitespace, "", strtolower(ucfirst(strtolower($company_name_array[$i]))));
    $vendor->column_fields["website"] = "www." . $website . ".com";
    $vendor->column_fields["assigned_user_id"] = $assigned_user_id;
    // Fill in a bogus address
    $vendor->column_fields["street"] = $street_address_array[rand(0, $street_address_count - 1)];
    $key = array_rand($city_array);
    $vendor->column_fields["city"] = $city_array[$key];
    $vendor->column_fields["state"] = "CA";
    $vendor->column_fields["postalcode"] = '99999';
    $vendor->column_fields["country"] = 'USA';
    $vendor->save("Vendors");
    $vendor_ids[] = $vendor->id;
Exemplo n.º 7
0
    /**
     * Generate or regenerate PDF for AP using FPDF library
     * @param $apId
     * @param bool $approved
     */
    public static function generatePdfFpdf($doc_id, $doc_type, $approved = false)
    {


        if ( $doc_type == 'AP' ) {
            // get AP
            $ap = Aps::model()->with('dists', 'document', 'ck_req_detail')->findByAttributes(
                array('Document_ID' => $doc_id)
            );

            $ckRequest = $ap->ck_req_detail;

            // get PO dists
            $apDists = $ap->dists;

            // get PO formatting
            $poFormatting = PoFormatting::model()->findByAttributes(array(
                'Project_ID' => $ap->document->Project_ID,
            ));

            // get Sign_Requested_By user info
            $signRequestedByUser = Users::model()->with('person')->findByPk($ckRequest->Sign_Requested_By);

            $aproval_detail_list = Audits::getApprovalDetailList($ap->Document_ID);
            // get current vendor info
            $currentVendor = Vendors::model()->with('client.company.adreses')->findByPk($ap->Vendor_ID);

            $condition = UsersClientList::getClientAdminCondition($currentVendor->client->Client_ID);
            $vendorAdmin = UsersClientList::model()->with('user.person')->find($condition);

            $pdf = new FpdfAp('P','mm','Letter');

            $pdf->AddFont('HelveticaB','','helveticab.php');
            $pdf->AddFont('Courier','','courier.php');
            $pdf->AddFont('CourierB','','courierb.php');
            $pdf->SetAutoPageBreak(true, 10);

            $pdf->setVariables($ap,$poFormatting,$ckRequest,$apDists,$currentVendor,$vendorAdmin,$signRequestedByUser,$aproval_detail_list,$approved);
            $pdf->AliasNbPages();
            $pdf->setPageNo(1);
            //$pdf->AliasNbPages();
            $pdf->AddPage('P');
            $pdf->SetFont('Helvetica','',13.5);
            $pdf->SetXY(5,10);
            $pdf->PrintContent();

            //$path=Helper::createDirectory('batches');// creates directory "protected/data/batches" if not exists
            $fileName = 'ApTempPdf'.date('Y-m-d h:i:s').'.pdf';
            $filepath = Helper::createDirectory('ap');
            $filepath = Helper::createDirectory('ap/'.Yii::app()->user->clientID);
            $filepath.= '/'.$fileName;
            $pdf->Output($filepath, 'F');
            //$pdf->Output();

            $last_page = $pdf->custom_page_num;



            $pdf->Close();
        }
        if (( $doc_type == 'PO' )) {

            $po = Pos::model()->findByAttributes(
                array('Document_ID' => $doc_id)
            );

            // get PO dists
            $poDists = $po->dists;

            // get PO details
            $poDecrDetails = $po->decr_details;

            // get PO formatting
            $poFormatting = PoFormatting::model()->findByAttributes(array(
                'Project_ID' => $po->document->Project_ID,
            ));

            // get Sign_Requested_By user info
            $signRequestedByUser = Users::model()->with('person')->findByPk($po->Sign_Requested_By);

            $aproval_detail_list = Audits::getApprovalDetailList($po->Document_ID);

            // get current vendor info
            $currentVendor = Vendors::model()->with('client.company.adreses')->findByPk($po->Vendor_ID);

            $condition = UsersClientList::getClientAdminCondition($currentVendor->client->Client_ID);
            $vendorAdmin = UsersClientList::model()->with('user.person')->find($condition);

            $paymentTypes = array(
                'OA' => 'On Account',
                'CC' => 'Credit Card',
                'DP' => 'Deposit',
                'CK' => 'Payment Check',
                'PC' => 'Petty Cash',
            );


            $pdf = new FpdfPo('P','mm','Letter');

            $pdf->AddFont('HelveticaB','','helveticab.php');
            $pdf->AddFont('Courier','','courier.php');
            $pdf->AddFont('CourierB','','courierb.php');
            $pdf->SetAutoPageBreak(true, 10);

            $pdf->setVariables($po,$poFormatting,$poDecrDetails,$poDists,$currentVendor,$vendorAdmin,$signRequestedByUser,$aproval_detail_list,$approved,$paymentTypes);
            $pdf->AliasNbPages();
            $pdf->setPageNo(1);
            //$pdf->AliasNbPages();
            $pdf->AddPage('P');
            $pdf->SetFont('Helvetica','',13.5);
            $pdf->SetXY(5,10);
            $pdf->PrintContent();

            //$path=Helper::createDirectory('batches');// creates directory "protected/data/batches" if not exists
            $fileName = 'TempFile.pdf';
            $filepath = Helper::createDirectory('po');
            $filepath = Helper::createDirectory('po/'.Yii::app()->user->clientID);
            $filepath.= '/'.$fileName;
            $pdf->Output($filepath, 'F');
            //$pdf->Output();

            $last_page = $pdf->custom_page_num;
            $pdf->Close();
        }


        return array(
          'path' => $filepath,
          'pages'=> $last_page
        );
    }
Exemplo n.º 8
0
 public function cache()
 {
     echo '<pre>';
     \Vendors::cacheLoad();
     print_r(\Vendors::$cache);
     $this->dispatcher->cacheLoad();
     print_r($this->dispatcher->cache);
     echo '</pre>';
 }
Exemplo n.º 9
0
    /**
     * Generate PDF for fake AP using FPDF library without saving to database.
     * @param $poId
     * @param bool $approved
     */
    public static function generatePdfFpdfPreview($ap, $ckRequest, $apDists,$approved = false)
    {
        // get PO formatting
        $poFormatting = PoFormatting::model()->findByAttributes(array(
            'Project_ID' => Yii::app()->user->projectID,
        ));

        // get Sign_Requested_By user info
        $signRequestedByUser = Users::model()->with('person')->findByPk($ckRequest->Sign_Requested_By);

        $aproval_detail_list = Audits::getApprovalDetailList($ap->Document_ID);
        // get current vendor info
        $currentVendor = Vendors::model()->with('client.company.adreses')->findByPk($ap->Vendor_ID);

        $condition = UsersClientList::getClientAdminCondition($currentVendor->client->Client_ID);
        $vendorAdmin = UsersClientList::model()->with('user.person')->find($condition);

        $pdf = new FpdfAp('P','mm','Letter');

        $pdf->AddFont('HelveticaB','','helveticab.php');
        $pdf->AddFont('Courier','','courier.php');
        $pdf->AddFont('CourierB','','courierb.php');
        $pdf->SetAutoPageBreak(true, 10);

        $pdf->setVariables($ap,$poFormatting,$ckRequest,$apDists,$currentVendor,$vendorAdmin,$signRequestedByUser,$aproval_detail_list,$approved);
        $pdf->AliasNbPages();
        $pdf->setPageNo(1);
        //$pdf->AliasNbPages();
        $pdf->AddPage('P');
        $pdf->SetFont('Helvetica','',13.5);
        $pdf->SetXY(5,10);
        $pdf->PrintContent();

        //$path=Helper::createDirectory('batches');// creates directory "protected/data/batches" if not exists
        $fileName = 'ApTempPdf'.date('Y-m-d h:i:s').'.pdf';
        $filepath = Helper::createDirectory('ap');
        $filepath = Helper::createDirectory('ap/'.Yii::app()->user->clientID);
        $filepath.= '/'.$fileName;
        $pdf->Output($filepath, 'F');
        //$pdf->Output();

        $last_page = $pdf->custom_page_num;
        $pdf->Close();


        return array(
            'filename'=>$fileName,
            'filepath'=>$filepath
        );
    }
Exemplo n.º 10
0
function getValue($field_result, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, $mode, $popuptype, $returnset = '', $viewid = '')
{
    global $log, $listview_max_textlength, $app_strings, $current_language, $currentModule;
    $log->debug("Entering getValue(" . $field_result . "," . $list_result . "," . $fieldname . "," . get_class($focus) . "," . $module . "," . $entity_id . "," . $list_result_count . "," . $mode . "," . $popuptype . "," . $returnset . "," . $viewid . ") method ...");
    global $adb, $current_user, $default_charset;
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    $tabname = getParentTab();
    $tabid = getTabid($module);
    $current_module_strings = return_module_language($current_language, $module);
    $uicolarr = $field_result[$fieldname];
    foreach ($uicolarr as $key => $value) {
        $uitype = $key;
        $colname = $value;
    }
    //added for getting event status in Custom view - Jaguar
    if ($module == 'Calendar' && ($colname == "status" || $colname == "eventstatus")) {
        $colname = "activitystatus";
    }
    //Ends
    $field_val = $adb->query_result($list_result, $list_result_count, $colname);
    if (stristr(html_entity_decode($field_val), "<a href") === false && $uitype != 8) {
        $temp_val = textlength_check($field_val);
    } elseif ($uitype != 8) {
        $temp_val = html_entity_decode($field_val, ENT_QUOTES);
    } else {
        $temp_val = $field_val;
    }
    // vtlib customization: New uitype to handle relation between modules
    if ($uitype == '10') {
        $parent_id = $field_val;
        if (!empty($parent_id)) {
            $parent_module = getSalesEntityType($parent_id);
            $valueTitle = $parent_module;
            if ($app_strings[$valueTitle]) {
                $valueTitle = $app_strings[$valueTitle];
            }
            $displayValueArray = getEntityName($parent_module, $parent_id);
            if (!empty($displayValueArray)) {
                foreach ($displayValueArray as $key => $value) {
                    $displayValue = $value;
                }
            }
            $value = "<a href='index.php?module={$parent_module}&action=DetailView&record={$parent_id}' title='{$valueTitle}'>{$displayValue}</a>";
        } else {
            $value = '';
        }
    } else {
        if ($uitype == 53) {
            $value = textlength_check($adb->query_result($list_result, $list_result_count, 'user_name'));
            // When Assigned To field is used in Popup window
            if ($value == '') {
                $user_id = $adb->query_result($list_result, $list_result_count, 'smownerid');
                if ($user_id != null && $user_id != '') {
                    $value = getOwnerName($user_id);
                }
            }
        } elseif ($uitype == 52) {
            $value = getUserName($adb->query_result($list_result, $list_result_count, $colname));
        } elseif ($uitype == 51) {
            $parentid = $adb->query_result($list_result, $list_result_count, "parentid");
            if ($module == 'Accounts') {
                $entity_name = textlength_check(getAccountName($parentid));
            } elseif ($module == 'Products') {
                $entity_name = textlength_check(getProductName($parentid));
            }
            $value = '<a href="index.php?module=' . $module . '&action=DetailView&record=' . $parentid . '&parenttab=' . $tabname . '" style="' . $P_FONT_COLOR . '">' . $entity_name . '</a>';
        } elseif ($uitype == 77) {
            $value = getUserName($adb->query_result($list_result, $list_result_count, 'inventorymanager'));
        } elseif ($uitype == 5 || $uitype == 6 || $uitype == 23 || $uitype == 70) {
            if ($temp_val != '' && $temp_val != '0000-00-00') {
                $value = getDisplayDate($temp_val);
            } elseif ($temp_val == '0000-00-00') {
                $value = '';
            } else {
                $value = $temp_val;
            }
        } elseif ($uitype == 15 || $uitype == 55 && $fieldname == "salutationtype") {
            $temp_val = decode_html($adb->query_result($list_result, $list_result_count, $colname));
            if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $temp_val != '') {
                $temp_acttype = $adb->query_result($list_result, $list_result_count, 'activitytype');
                if ($temp_acttype != 'Task' && $fieldname == "taskstatus") {
                    $temptable = "eventstatus";
                } else {
                    $temptable = $fieldname;
                }
                $roleid = $current_user->roleid;
                $roleids = array();
                $subrole = getRoleSubordinates($roleid);
                if (count($subrole) > 0) {
                    $roleids = $subrole;
                }
                array_push($roleids, $roleid);
                //here we are checking wheather the table contains the sortorder column .If  sortorder is present in the main picklist table, then the role2picklist will be applicable for this table...
                $sql = "select * from vtiger_{$temptable} where {$temptable}=?";
                $res = $adb->pquery($sql, array(decode_html($temp_val)));
                $picklistvalueid = $adb->query_result($res, 0, 'picklist_valueid');
                if ($picklistvalueid != null) {
                    $pick_query = "select * from vtiger_role2picklist where picklistvalueid={$picklistvalueid} and roleid in (" . generateQuestionMarks($roleids) . ")";
                    $res_val = $adb->pquery($pick_query, array($roleids));
                    $num_val = $adb->num_rows($res_val);
                }
                if ($num_val > 0 || $temp_acttype == 'Task' && $fieldname == 'activitytype') {
                    $temp_val = $temp_val;
                } else {
                    $temp_val = "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>";
                }
            }
            $value = $current_module_strings[$temp_val] != '' ? $current_module_strings[$temp_val] : ($app_strings[$temp_val] != '' ? $app_strings[$temp_val] : $temp_val);
            if ($value != "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>") {
                $value = textlength_check($value);
            }
        } elseif ($uitype == 16) {
            $value = getTranslatedString($temp_val, $currentModule);
        } elseif ($uitype == 71 || $uitype == 72) {
            if ($temp_val != '') {
                if ($fieldname == 'unit_price') {
                    $currency_id = getProductBaseCurrency($entity_id, $module);
                    $cursym_convrate = getCurrencySymbolandCRate($currency_id);
                    $value = "<font style='color:grey;'>" . $cursym_convrate['symbol'] . "</font> " . $temp_val;
                } else {
                    $rate = $user_info['conv_rate'];
                    //changes made to remove vtiger_currency symbol infront of each vtiger_potential amount
                    if ($temp_val != 0) {
                        $value = convertFromDollar($temp_val, $rate);
                    } else {
                        $value = $temp_val;
                    }
                }
            } else {
                $value = '';
            }
        } elseif ($uitype == 17) {
            $value = '<a href="http://' . $field_val . '" target="_blank">' . $temp_val . '</a>';
        } elseif ($uitype == 13 || $uitype == 104 && ($_REQUEST['action'] != 'Popup' && $_REQUEST['file'] != 'Popup')) {
            if ($_SESSION['internal_mailer'] == 1) {
                //check added for email link in user detailview
                if ($module == 'Calendar') {
                    if (getActivityType($entity_id) == 'Task') {
                        $tabid = 9;
                    } else {
                        $tabid = 16;
                    }
                } else {
                    $tabid = getTabid($module);
                }
                $fieldid = getFieldid($tabid, $fieldname);
                if (empty($popuptype)) {
                    $value = '<a href="javascript:InternalMailer(' . $entity_id . ',' . $fieldid . ',\'' . $fieldname . '\',\'' . $module . '\',\'record_id\');">' . $temp_val . '</a>';
                } else {
                    $value = $temp_val;
                }
            } else {
                $value = '<a href="mailto:' . $field_val . '">' . $temp_val . '</a>';
            }
        } elseif ($uitype == 56) {
            if ($temp_val == 1) {
                $value = $app_strings['yes'];
            } elseif ($temp_val == 0) {
                $value = $app_strings['no'];
            } else {
                $value = '';
            }
        } elseif ($uitype == 57) {
            if ($temp_val != '') {
                $sql = "SELECT * FROM vtiger_contactdetails WHERE contactid=?";
                $result = $adb->pquery($sql, array($temp_val));
                $value = '';
                if ($adb->num_rows($result)) {
                    $name = getFullNameFromQResult($result, 0, "Contacts");
                    $value = '<a href=index.php?module=Contacts&action=DetailView&record=' . $temp_val . '>' . $name . '</a>';
                }
            } else {
                $value = '';
            }
        } elseif ($uitype == 58) {
            if ($temp_val != '') {
                $sql = "SELECT * FROM vtiger_campaign WHERE campaignid=?";
                $result = $adb->pquery($sql, array($temp_val));
                $campaignname = $adb->query_result($result, 0, "campaignname");
                $value = '<a href=index.php?module=Campaigns&action=DetailView&record=' . $temp_val . '>' . $campaignname . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 59) {
            if ($temp_val != '') {
                $value = getProductName($temp_val);
            } else {
                $value = '';
            }
        } elseif ($uitype == 61) {
            $attachmentid = $adb->query_result($adb->pquery("SELECT * FROM vtiger_seattachmentsrel WHERE crmid = ?", array($entity_id)), 0, 'attachmentsid');
            $value = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $module . '&fileid=' . $attachmentid . '&filename=' . $temp_val . '">' . $temp_val . '</a>';
        } elseif ($uitype == 62) {
            $parentid = $adb->query_result($list_result, $list_result_count, "parent_id");
            $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type");
            if ($parenttype == "Leads") {
                $tablename = "vtiger_leaddetails";
                $fieldname = "lastname";
                $idname = "leadid";
            }
            if ($parenttype == "Accounts") {
                $tablename = "vtiger_account";
                $fieldname = "accountname";
                $idname = "accountid";
            }
            if ($parenttype == "Products") {
                $tablename = "vtiger_products";
                $fieldname = "productname";
                $idname = "productid";
            }
            if ($parenttype == "HelpDesk") {
                $tablename = "vtiger_troubletickets";
                $fieldname = "title";
                $idname = "ticketid";
            }
            if ($parenttype == "Invoice") {
                $tablename = "vtiger_invoice";
                $fieldname = "subject";
                $idname = "invoiceid";
            }
            if ($parentid != '') {
                $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?";
                $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname);
                $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . $fieldvalue . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 66) {
            $parentid = $adb->query_result($list_result, $list_result_count, "parent_id");
            $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type");
            if ($parenttype == "Leads") {
                $tablename = "vtiger_leaddetails";
                $fieldname = "lastname";
                $idname = "leadid";
            }
            if ($parenttype == "Accounts") {
                $tablename = "vtiger_account";
                $fieldname = "accountname";
                $idname = "accountid";
            }
            if ($parenttype == "HelpDesk") {
                $tablename = "vtiger_troubletickets";
                $fieldname = "title";
                $idname = "ticketid";
            }
            if ($parentid != '') {
                $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?";
                $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname);
                $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . $fieldvalue . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 67) {
            $parentid = $adb->query_result($list_result, $list_result_count, "parent_id");
            $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type");
            if ($parenttype == "Leads") {
                $tablename = "vtiger_leaddetails";
                $fieldname = "lastname";
                $idname = "leadid";
            }
            if ($parenttype == "Contacts") {
                $tablename = "vtiger_contactdetails";
                $fieldname = "contactname";
                $idname = "contactid";
            }
            if ($parentid != '') {
                $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?";
                $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname);
                $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . $fieldvalue . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 68) {
            $parentid = $adb->query_result($list_result, $list_result_count, "parent_id");
            $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type");
            if ($parenttype == '' && $parentid != '') {
                $parenttype = getSalesEntityType($parentid);
            }
            if ($parenttype == "Contacts") {
                $tablename = "vtiger_contactdetails";
                $fieldname = "contactname";
                $idname = "contactid";
            }
            if ($parenttype == "Accounts") {
                $tablename = "vtiger_account";
                $fieldname = "accountname";
                $idname = "accountid";
            }
            if ($parentid != '') {
                $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?";
                $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname);
                $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . $fieldvalue . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 78) {
            if ($temp_val != '') {
                $quote_name = getQuoteName($temp_val);
                $value = '<a href=index.php?module=Quotes&action=DetailView&record=' . $temp_val . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($quote_name) . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 79) {
            if ($temp_val != '') {
                $purchaseorder_name = getPoName($temp_val);
                $value = '<a href=index.php?module=PurchaseOrder&action=DetailView&record=' . $temp_val . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($purchaseorder_name) . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 80) {
            if ($temp_val != '') {
                $salesorder_name = getSoName($temp_val);
                $value = "<a href=index.php?module=SalesOrder&action=DetailView&record={$temp_val}&parenttab=" . urlencode($tabname) . ">" . textlength_check($salesorder_name) . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 75 || $uitype == 81) {
            if ($temp_val != '') {
                $vendor_name = getVendorName($temp_val);
                $value = '<a href=index.php?module=Vendors&action=DetailView&record=' . $temp_val . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($vendor_name) . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 98) {
            $value = '<a href="index.php?action=RoleDetailView&module=Settings&parenttab=Settings&roleid=' . $temp_val . '">' . textlength_check(getRoleName($temp_val)) . '</a>';
        } elseif ($uitype == 33) {
            $value = $temp_val != "" ? str_ireplace(' |##| ', ', ', $temp_val) : "";
            if (!$is_admin && $value != '') {
                $value = $field_val != "" ? str_ireplace(' |##| ', ', ', $field_val) : "";
                if ($value != '') {
                    $value_arr = explode(',', trim($value));
                    $roleid = $current_user->roleid;
                    $subrole = getRoleSubordinates($roleid);
                    if (count($subrole) > 0) {
                        $roleids = $subrole;
                        array_push($roleids, $roleid);
                    } else {
                        $roleids = $roleid;
                    }
                    if (count($roleids) > 0) {
                        $pick_query = "select distinct {$fieldname} from vtiger_{$fieldname} inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_{$fieldname}.picklist_valueid where roleid in (" . generateQuestionMarks($roleids) . ") and picklistid in (select picklistid from vtiger_{$fieldname}) order by {$fieldname} asc";
                        $params = array($roleids);
                    } else {
                        $pick_query = "select distinct {$fieldname} from vtiger_{$fieldname} inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_{$fieldname}.picklist_valueid where picklistid in (select picklistid from vtiger_{$fieldname}) order by {$fieldname} asc";
                        $params = array();
                    }
                    $pickListResult = $adb->pquery($pick_query, $params);
                    $picklistval = array();
                    for ($i = 0; $i < $adb->num_rows($pickListResult); $i++) {
                        $picklistarr[] = $adb->query_result($pickListResult, $i, $fieldname);
                    }
                    $value_temp = array();
                    $string_temp = '';
                    $str_c = 0;
                    foreach ($value_arr as $ind => $val) {
                        $notaccess = '<font color="red">' . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>";
                        if (!$listview_max_textlength || !(strlen(preg_replace("/(<\\/?)(\\w+)([^>]*>)/i", "", $string_temp)) > $listview_max_textlength)) {
                            $value_temp1 = in_array(trim($val), $picklistarr) ? $val : $notaccess;
                            if ($str_c != 0) {
                                $string_temp .= ' , ';
                            }
                            $string_temp .= $value_temp1;
                            $str_c++;
                        } else {
                            $string_temp .= '...';
                        }
                    }
                    $value = $string_temp;
                }
            }
        } elseif ($uitype == 85) {
            $value = $temp_val != "" ? "<a href='skype:{$temp_val}?call'>{$temp_val}</a>" : "";
        } elseif ($uitype == 116) {
            $value = $temp_val != "" ? getCurrencyName($temp_val) : "";
        } elseif ($uitype == 117) {
            // NOTE: Without symbol the value could be used for filtering/lookup hence avoiding the translation
            $value = $temp_val != "" ? getCurrencyName($temp_val, false) : "";
        } elseif ($uitype == 26) {
            $sql = "select foldername from vtiger_attachmentsfolder where folderid = ?";
            $res = $adb->pquery($sql, array($temp_val));
            $foldername = $adb->query_result($res, 0, 'foldername');
            $value = $foldername;
        } elseif ($uitype == 11) {
            // Fix added for Trac Id: 6139
            if (vtlib_isModuleActive('PBXManager')) {
                $value = "<a href='javascript:;' onclick='startCall(&quot;{$temp_val}&quot;, &quot;{$entity_id}&quot;)'>" . $temp_val . "</a>";
            } else {
                $value = $temp_val;
            }
        } elseif ($uitype == 25) {
            $contactid = $_REQUEST['record'];
            $emailid = $adb->query_result($list_result, $list_result_count, "activityid");
            $result = $adb->pquery("SELECT access_count FROM vtiger_email_track WHERE crmid=? AND mailid=?", array($contactid, $emailid));
            $value = $adb->query_result($result, 0, "access_count");
            if (!$value) {
                $value = 0;
            }
        } elseif ($uitype == 8) {
            if (!empty($temp_val)) {
                $temp_val = html_entity_decode($temp_val, ENT_QUOTES, $default_charset);
                $json = new Zend_Json();
                $value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val)));
            }
        } else {
            if ($fieldname == $focus->list_link_field) {
                if ($mode == "search") {
                    if ($popuptype == "specific" || $popuptype == "toDospecific") {
                        // Added for get the first name of contact in Popup window
                        if ($colname == "lastname" && $module == 'Contacts') {
                            $temp_val = getFullNameFromQResult($list_result, $list_result_count, "Contacts");
                        }
                        $slashes_temp_val = popup_from_html($temp_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        //Added to avoid the error when select SO from Invoice through AjaxEdit
                        if ($module == 'SalesOrder') {
                            $value = '<a href="javascript:window.close();" onclick=\'set_return_specific("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '","' . $_REQUEST['form'] . '");\'>' . $temp_val . '</a>';
                        } elseif ($module == 'Contacts') {
                            require_once 'modules/Contacts/Contacts.php';
                            $cntct_focus = new Contacts();
                            $cntct_focus->retrieve_entity_info($entity_id, "Contacts");
                            $slashes_temp_val = popup_from_html($temp_val);
                            //ADDED TO CHECK THE FIELD PERMISSIONS FOR
                            $xyz = array('mailingstreet', 'mailingcity', 'mailingzip', 'mailingpobox', 'mailingcountry', 'mailingstate', 'otherstreet', 'othercity', 'otherzip', 'otherpobox', 'othercountry', 'otherstate');
                            for ($i = 0; $i < 12; $i++) {
                                if (getFieldVisibilityPermission($module, $current_user->id, $xyz[$i]) == '0') {
                                    $cntct_focus->column_fields[$xyz[$i]] = $cntct_focus->column_fields[$xyz[$i]];
                                } else {
                                    $cntct_focus->column_fields[$xyz[$i]] = '';
                                }
                            }
                            // For ToDo creation the underlying form is not named as EditView
                            $form = !empty($_REQUEST['form']) ? $_REQUEST['form'] : '';
                            if (!empty($form)) {
                                $form = htmlspecialchars($form, ENT_QUOTES, $default_charset);
                            }
                            $value = '<a href="javascript:window.close();" onclick=\'set_return_contact_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingstreet']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherstreet']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingcity']) . '", "' . popup_decode_html($cntct_focus->column_fields['othercity']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingstate']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherstate']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingzip']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherzip']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingcountry']) . '", "' . popup_decode_html($cntct_focus->column_fields['othercountry']) . '","' . popup_decode_html($cntct_focus->column_fields['mailingpobox']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherpobox']) . '","' . $form . '");\'>' . $temp_val . '</a>';
                        } else {
                            if ($popuptype == 'toDospecific') {
                                $value = '<a href="javascript:window.close();" onclick=\'set_return_toDospecific("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>';
                            } else {
                                $value = '<a href="javascript:window.close();" onclick=\'set_return_specific("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>';
                            }
                        }
                    } elseif ($popuptype == "detailview") {
                        if ($colname == "lastname" && ($module == 'Contacts' || $module == 'Leads')) {
                            $temp_val = getFullNameFromQResult($list_result, $list_result_count, $module);
                        }
                        $slashes_temp_val = popup_from_html($temp_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        $focus->record_id = $_REQUEST['recordid'];
                        if ($_REQUEST['return_module'] == "Calendar") {
                            $value = '<a href="javascript:window.close();" id="calendarCont' . $entity_id . '" LANGUAGE=javascript onclick=\'add_data_to_relatedlist_incal("' . $entity_id . '","' . decode_html($slashes_temp_val) . '");\'>' . $temp_val . '</a>';
                        } else {
                            $value = '<a href="javascript:window.close();" onclick=\'add_data_to_relatedlist("' . $entity_id . '","' . $focus->record_id . '","' . $module . '");\'>' . $temp_val . '</a>';
                        }
                    } elseif ($popuptype == "formname_specific") {
                        $slashes_temp_val = popup_from_html($temp_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        $value = '<a href="javascript:window.close();" onclick=\'set_return_formname_specific("' . $_REQUEST['form'] . '", "' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>';
                    } elseif ($popuptype == "inventory_prod") {
                        $row_id = $_REQUEST['curr_row'];
                        //To get all the tax types and values and pass it to product details
                        $tax_str = '';
                        $tax_details = getAllTaxes();
                        for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) {
                            $tax_str .= $tax_details[$tax_count]['taxname'] . '=' . $tax_details[$tax_count]['percentage'] . ',';
                        }
                        $tax_str = trim($tax_str, ',');
                        $rate = $user_info['conv_rate'];
                        if (getFieldVisibilityPermission('Products', $current_user->id, 'unit_price') == '0') {
                            $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price');
                            if ($_REQUEST['currencyid'] != null) {
                                $prod_prices = getPricesForProducts($_REQUEST['currencyid'], array($entity_id));
                                $unitprice = $prod_prices[$entity_id];
                            }
                        } else {
                            $unit_price = '';
                        }
                        $sub_products = '';
                        $sub_prod = '';
                        $sub_prod_query = $adb->pquery("SELECT vtiger_products.productid,vtiger_products.productname,vtiger_products.qtyinstock,vtiger_crmentity.description from vtiger_products INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_products.productid INNER JOIN vtiger_seproductsrel on vtiger_seproductsrel.crmid=vtiger_products.productid WHERE vtiger_seproductsrel.productid=? and vtiger_seproductsrel.setype='Products'", array($entity_id));
                        for ($i = 0; $i < $adb->num_rows($sub_prod_query); $i++) {
                            //$sub_prod=array();
                            $id = $adb->query_result($sub_prod_query, $i, "productid");
                            $str_sep = '';
                            if ($i > 0) {
                                $str_sep = ":";
                            }
                            $sub_products .= $str_sep . $id;
                            $sub_prod .= $str_sep . " - " . $adb->query_result($sub_prod_query, $i, "productname");
                        }
                        $sub_det = $sub_products . "::" . str_replace(":", "<br>", $sub_prod);
                        $qty_stock = $adb->query_result($list_result, $list_result_count, 'qtyinstock');
                        //fix for T6943
                        $slashes_temp_val = popup_from_html($field_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        $description = popup_from_html($adb->query_result($list_result, $list_result_count, 'description'));
                        $slashes_temp_desc = decode_html(htmlspecialchars($description, ENT_QUOTES, $default_charset));
                        $slashes_desc = str_replace(array("\r", "\n"), array('\\r', '\\n'), $slashes_temp_desc);
                        $tmp_arr = array("entityid" => $entity_id, "prodname" => "" . stripslashes(decode_html(nl2br($slashes_temp_val))) . "", "unitprice" => "{$unitprice}", "qtyinstk" => "{$qty_stock}", "taxstring" => "{$tax_str}", "rowid" => "{$row_id}", "desc" => "{$slashes_desc}", "subprod_ids" => "{$sub_det}");
                        require_once 'include/Zend/Json.php';
                        $prod_arr = Zend_Json::encode($tmp_arr);
                        $value = '<a href="javascript:window.close();" id=\'popup_product_' . $entity_id . '\' onclick=\'set_return_inventory("' . $entity_id . '", "' . decode_html(nl2br($slashes_temp_val)) . '", "' . $unitprice . '", "' . $qty_stock . '","' . $tax_str . '","' . $row_id . '","' . $slashes_desc . '","' . $sub_det . '");\' vt_prod_arr=\'' . $prod_arr . '\' >' . $temp_val . '</a>';
                    } elseif ($popuptype == "inventory_prod_po") {
                        $row_id = $_REQUEST['curr_row'];
                        //To get all the tax types and values and pass it to product details
                        $tax_str = '';
                        $tax_details = getAllTaxes();
                        for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) {
                            $tax_str .= $tax_details[$tax_count]['taxname'] . '=' . $tax_details[$tax_count]['percentage'] . ',';
                        }
                        $tax_str = trim($tax_str, ',');
                        $rate = $user_info['conv_rate'];
                        if (getFieldVisibilityPermission($module, $current_user->id, 'unit_price') == '0') {
                            $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price');
                            if ($_REQUEST['currencyid'] != null) {
                                $prod_prices = getPricesForProducts($_REQUEST['currencyid'], array($entity_id), $module);
                                $unitprice = $prod_prices[$entity_id];
                            }
                        } else {
                            $unit_price = '';
                        }
                        $sub_products = '';
                        $sub_prod = '';
                        $sub_prod_query = $adb->pquery("SELECT vtiger_products.productid,vtiger_products.productname,vtiger_products.qtyinstock,vtiger_crmentity.description from vtiger_products INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_products.productid INNER JOIN vtiger_seproductsrel on vtiger_seproductsrel.crmid=vtiger_products.productid WHERE vtiger_seproductsrel.productid=? and vtiger_seproductsrel.setype='Products'", array($entity_id));
                        for ($i = 0; $i < $adb->num_rows($sub_prod_query); $i++) {
                            //$sub_prod=array();
                            $id = $adb->query_result($sub_prod_query, $i, "productid");
                            $str_sep = '';
                            if ($i > 0) {
                                $str_sep = ":";
                            }
                            $sub_products .= $str_sep . $id;
                            $sub_prod .= $str_sep . " - {$id}." . $adb->query_result($sub_prod_query, $i, "productname");
                        }
                        $sub_det = $sub_products . "::" . str_replace(":", "<br>", $sub_prod);
                        $slashes_temp_val = popup_from_html($field_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        $description = popup_from_html($adb->query_result($list_result, $list_result_count, 'description'));
                        $slashes_temp_desc = decode_html(htmlspecialchars($description, ENT_QUOTES, $default_charset));
                        $slashes_desc = str_replace(array("\r", "\n"), array('\\r', '\\n'), $slashes_temp_desc);
                        $tmp_arr = array("entityid" => $entity_id, "prodname" => "" . stripslashes(decode_html(nl2br($slashes_temp_val))) . "", "unitprice" => "{$unitprice}", "qtyinstk" => "{$qty_stock}", "taxstring" => "{$tax_str}", "rowid" => "{$row_id}", "desc" => "{$slashes_desc}", "subprod_ids" => "{$sub_det}");
                        require_once 'include/Zend/Json.php';
                        $prod_arr = Zend_Json::encode($tmp_arr);
                        $value = '<a href="javascript:window.close();" id=\'popup_product_' . $entity_id . '\' onclick=\'set_return_inventory_po("' . $entity_id . '", "' . decode_html(nl2br($slashes_temp_val)) . '", "' . $unitprice . '", "' . $tax_str . '","' . $row_id . '","' . $slashes_desc . '","' . $sub_det . '"); \'  vt_prod_arr=\'' . $prod_arr . '\' >' . $temp_val . '</a>';
                    } elseif ($popuptype == "inventory_service") {
                        $row_id = $_REQUEST['curr_row'];
                        //To get all the tax types and values and pass it to product details
                        $tax_str = '';
                        $tax_details = getAllTaxes();
                        for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) {
                            $tax_str .= $tax_details[$tax_count]['taxname'] . '=' . $tax_details[$tax_count]['percentage'] . ',';
                        }
                        $tax_str = trim($tax_str, ',');
                        $rate = $user_info['conv_rate'];
                        if (getFieldVisibilityPermission('Services', $current_user->id, 'unit_price') == '0') {
                            $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price');
                            if ($_REQUEST['currencyid'] != null) {
                                $prod_prices = getPricesForProducts($_REQUEST['currencyid'], array($entity_id), $module);
                                $unitprice = $prod_prices[$entity_id];
                            }
                        } else {
                            $unit_price = '';
                        }
                        $slashes_temp_val = popup_from_html($field_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        $description = popup_from_html($adb->query_result($list_result, $list_result_count, 'description'));
                        $slashes_temp_desc = decode_html(htmlspecialchars($description, ENT_QUOTES, $default_charset));
                        $slashes_desc = str_replace(array("\r", "\n"), array('\\r', '\\n'), $slashes_temp_desc);
                        $tmp_arr = array("entityid" => $entity_id, "prodname" => "" . stripslashes(decode_html(nl2br($slashes_temp_val))) . "", "unitprice" => "{$unitprice}", "taxstring" => "{$tax_str}", "rowid" => "{$row_id}", "desc" => "{$slashes_desc}");
                        require_once 'include/Zend/Json.php';
                        $prod_arr = Zend_Json::encode($tmp_arr);
                        $value = '<a href="javascript:window.close();" id=\'popup_product_' . $entity_id . '\' onclick=\'set_return_inventory("' . $entity_id . '", "' . decode_html(nl2br($slashes_temp_val)) . '", "' . $unitprice . '", "' . $tax_str . '","' . $row_id . '","' . $slashes_desc . '");\'  vt_prod_arr=\'' . $prod_arr . '\' >' . $temp_val . '</a>';
                    } elseif ($popuptype == "inventory_pb") {
                        $prod_id = $_REQUEST['productid'];
                        $flname = $_REQUEST['fldname'];
                        $listprice = getListPrice($prod_id, $entity_id);
                        $temp_val = popup_from_html($temp_val);
                        $value = '<a href="javascript:window.close();" onclick=\'set_return_inventory_pb("' . $listprice . '", "' . $flname . '"); \'>' . $temp_val . '</a>';
                    } elseif ($popuptype == "specific_account_address") {
                        require_once 'modules/Accounts/Accounts.php';
                        $acct_focus = new Accounts();
                        $acct_focus->retrieve_entity_info($entity_id, "Accounts");
                        $slashes_temp_val = popup_from_html($temp_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        $xyz = array('bill_street', 'bill_city', 'bill_code', 'bill_pobox', 'bill_country', 'bill_state', 'ship_street', 'ship_city', 'ship_code', 'ship_pobox', 'ship_country', 'ship_state');
                        for ($i = 0; $i < 12; $i++) {
                            if (getFieldVisibilityPermission($module, $current_user->id, $xyz[$i]) == '0') {
                                $acct_focus->column_fields[$xyz[$i]] = $acct_focus->column_fields[$xyz[$i]];
                            } else {
                                $acct_focus->column_fields[$xyz[$i]] = '';
                            }
                        }
                        $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['bill_street']));
                        $ship_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['ship_street']));
                        $value = '<a href="javascript:window.close();" onclick=\'set_return_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $bill_street . '", "' . $ship_street . '", "' . popup_decode_html($acct_focus->column_fields['bill_city']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_city']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_state']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_state']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_code']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_code']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_country']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_country']) . '","' . popup_decode_html($acct_focus->column_fields['bill_pobox']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_pobox']) . '");\'>' . $temp_val . '</a>';
                    } elseif ($popuptype == "specific_contact_account_address") {
                        require_once 'modules/Accounts/Accounts.php';
                        $acct_focus = new Accounts();
                        $acct_focus->retrieve_entity_info($entity_id, "Accounts");
                        $slashes_temp_val = popup_from_html($temp_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['bill_street']));
                        $ship_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['ship_street']));
                        $value = '<a href="javascript:window.close();" onclick=\'set_return_contact_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $bill_street . '", "' . $ship_street . '", "' . popup_decode_html($acct_focus->column_fields['bill_city']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_city']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_state']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_state']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_code']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_code']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_country']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_country']) . '","' . popup_decode_html($acct_focus->column_fields['bill_pobox']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_pobox']) . '");\'>' . $temp_val . '</a>';
                    } elseif ($popuptype == "specific_potential_account_address") {
                        $slashes_temp_val = popup_from_html($temp_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        // For B2C support, Potential was enabled to be linked to Contacts also.
                        // Hence we need case handling for it.
                        $relatedid = $adb->query_result($list_result, $list_result_count, "related_to");
                        $relatedentity = getSalesEntityType($relatedid);
                        if ($relatedentity == 'Accounts') {
                            require_once 'modules/Accounts/Accounts.php';
                            $acct_focus = new Accounts();
                            $acct_focus->retrieve_entity_info($relatedid, "Accounts");
                            $account_name = getAccountName($relatedid);
                            $slashes_account_name = popup_from_html($account_name);
                            $slashes_account_name = htmlspecialchars($slashes_account_name, ENT_QUOTES, $default_charset);
                            $xyz = array('bill_street', 'bill_city', 'bill_code', 'bill_pobox', 'bill_country', 'bill_state', 'ship_street', 'ship_city', 'ship_code', 'ship_pobox', 'ship_country', 'ship_state');
                            for ($i = 0; $i < 12; $i++) {
                                if (getFieldVisibilityPermission('Accounts', $current_user->id, $xyz[$i]) == '0') {
                                    $acct_focus->column_fields[$xyz[$i]] = $acct_focus->column_fields[$xyz[$i]];
                                } else {
                                    $acct_focus->column_fields[$xyz[$i]] = '';
                                }
                            }
                            $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['bill_street']));
                            $ship_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['ship_street']));
                            $value = '<a href="javascript:window.close();" onclick=\'set_return_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $relatedid . '", "' . nl2br(decode_html($slashes_account_name)) . '", "' . $bill_street . '", "' . $ship_street . '", "' . popup_decode_html($acct_focus->column_fields['bill_city']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_city']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_state']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_state']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_code']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_code']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_country']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_country']) . '","' . popup_decode_html($acct_focus->column_fields['bill_pobox']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_pobox']) . '");\'>' . $temp_val . '</a>';
                        } else {
                            if ($relatedentity == 'Contacts') {
                                require_once 'modules/Contacts/Contacts.php';
                                $contact_name = getContactName($relatedid);
                                $slashes_contact_name = popup_from_html($contact_name);
                                $slashes_contact_name = htmlspecialchars($slashes_contact_name, ENT_QUOTES, $default_charset);
                                $value = '<a href="javascript:window.close();" onclick=\'set_return_contact("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $relatedid . '", "' . nl2br(decode_html($slashes_contact_name)) . '");\'>' . $temp_val . '</a>';
                            } else {
                                $value = $temp_val;
                            }
                        }
                    } elseif ($popuptype == "set_return_emails") {
                        if ($module == 'Accounts') {
                            $name = $adb->query_result($list_result, $list_result_count, 'accountname');
                            $accid = $adb->query_result($list_result, $list_result_count, 'accountid');
                            if (CheckFieldPermission('email1', $module) == "true") {
                                $emailaddress = $adb->query_result($list_result, $list_result_count, "email1");
                                $email_check = 1;
                            } else {
                                $email_check = 0;
                            }
                            if ($emailaddress == '') {
                                if (CheckFieldPermission('email2', $module) == 'true') {
                                    $emailaddress2 = $adb->query_result($list_result, $list_result_count, "email2");
                                    $email_check = 2;
                                } else {
                                    if ($email_check == 1) {
                                        $email_check = 4;
                                    } else {
                                        $email_check = 3;
                                    }
                                }
                            }
                            $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)";
                            $queryres = $adb->pquery($querystr, array(getTabid($module)));
                            //Change this index 0 - to get the vtiger_fieldid based on email1 or email2
                            $fieldid = $adb->query_result($queryres, 0, 'fieldid');
                            $slashes_name = popup_from_html($name);
                            $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset);
                            $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"); \'>' . textlength_check($name) . '</a>';
                        } elseif ($module == 'Vendors') {
                            $name = $adb->query_result($list_result, $list_result_count, 'vendorname');
                            $venid = $adb->query_result($list_result, $list_result_count, 'vendorid');
                            if (CheckFieldPermission('email', $module) == "true") {
                                $emailaddress = $adb->query_result($list_result, $list_result_count, "email");
                                $email_check = 1;
                            } else {
                                $email_check = 0;
                            }
                            $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)";
                            $queryres = $adb->pquery($querystr, array(getTabid($module)));
                            //Change this index 0 - to get the vtiger_fieldid based on email1 or email2
                            $fieldid = $adb->query_result($queryres, 0, 'fieldid');
                            $slashes_name = popup_from_html($name);
                            $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset);
                            $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"); \'>' . textlength_check($name) . '</a>';
                        } elseif ($module == 'Contacts' || $module == 'Leads') {
                            $name = getFullNameFromQResult($list_result, $list_result_count, $module);
                            if (CheckFieldPermission('email', $module) == "true") {
                                $emailaddress = $adb->query_result($list_result, $list_result_count, "email");
                                $email_check = 1;
                            } else {
                                $email_check = 0;
                            }
                            if ($emailaddress == '') {
                                if (CheckFieldPermission('yahooid', $module) == 'true') {
                                    $emailaddress2 = $adb->query_result($list_result, $list_result_count, "yahooid");
                                    $email_check = 2;
                                } else {
                                    if ($email_check == 1) {
                                        $email_check = 4;
                                    } else {
                                        $email_check = 3;
                                    }
                                }
                            }
                            $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)";
                            $queryres = $adb->pquery($querystr, array(getTabid($module)));
                            //Change this index 0 - to get the vtiger_fieldid based on email or yahooid
                            $fieldid = $adb->query_result($queryres, 0, 'fieldid');
                            $slashes_name = popup_from_html($name);
                            $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset);
                            $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"); \'>' . $name . '</a>';
                        } else {
                            $firstname = $adb->query_result($list_result, $list_result_count, "first_name");
                            $lastname = $adb->query_result($list_result, $list_result_count, "last_name");
                            $name = $lastname . ' ' . $firstname;
                            $emailaddress = $adb->query_result($list_result, $list_result_count, "email1");
                            $slashes_name = popup_from_html($name);
                            $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset);
                            $email_check = 1;
                            $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',-1,"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"); \'>' . textlength_check($name) . '</a>';
                        }
                    } elseif ($popuptype == "specific_vendor_address") {
                        require_once 'modules/Vendors/Vendors.php';
                        $acct_focus = new Vendors();
                        $acct_focus->retrieve_entity_info($entity_id, "Vendors");
                        $slashes_temp_val = popup_from_html($temp_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        $xyz = array('street', 'city', 'postalcode', 'pobox', 'country', 'state');
                        for ($i = 0; $i < 6; $i++) {
                            if (getFieldVisibilityPermission($module, $current_user->id, $xyz[$i]) == '0') {
                                $acct_focus->column_fields[$xyz[$i]] = $acct_focus->column_fields[$xyz[$i]];
                            } else {
                                $acct_focus->column_fields[$xyz[$i]] = '';
                            }
                        }
                        $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['street']));
                        $value = '<a href="javascript:window.close();" onclick=\'set_return_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $bill_street . '", "' . popup_decode_html($acct_focus->column_fields['city']) . '", "' . popup_decode_html($acct_focus->column_fields['state']) . '", "' . popup_decode_html($acct_focus->column_fields['postalcode']) . '", "' . popup_decode_html($acct_focus->column_fields['country']) . '","' . popup_decode_html($acct_focus->column_fields['pobox']) . '");\'>' . $temp_val . '</a>';
                    } elseif ($popuptype == "specific_campaign") {
                        $slashes_temp_val = popup_from_html($temp_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        $value = '<a href="javascript:window.close();" onclick=\'set_return_specific_campaign("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>';
                    } else {
                        if ($colname == "lastname") {
                            $temp_val = getFullNameFromQResult($list_result, $list_result_count, $module);
                        }
                        $slashes_temp_val = popup_from_html($temp_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        $log->debug("Exiting getValue method ...");
                        if ($_REQUEST['maintab'] == 'Calendar') {
                            $value = '<a href="javascript:window.close();" onclick=\'set_return_todo("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>';
                        } else {
                            $value = '<a href="javascript:window.close();" onclick=\'set_return("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>';
                        }
                    }
                } else {
                    if ($module == "Leads" && $colname == "lastname" || $module == "Contacts" && $colname == "lastname") {
                        $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>';
                    } elseif ($module == "Calendar") {
                        $actvity_type = $adb->query_result($list_result, $list_result_count, 'activitytype');
                        $actvity_type = $actvity_type != '' ? $actvity_type : $adb->query_result($list_result, $list_result_count, 'type');
                        if ($actvity_type == "Task") {
                            $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&activity_mode=Task&parenttab=' . $tabname . '">' . $temp_val . '</a>';
                        } else {
                            $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&activity_mode=Events&parenttab=' . $tabname . '">' . $temp_val . '</a>';
                        }
                    } elseif ($module == "Vendors") {
                        $value = '<a href="index.php?action=DetailView&module=Vendors&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>';
                    } elseif ($module == "PriceBooks") {
                        $value = '<a href="index.php?action=DetailView&module=PriceBooks&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>';
                    } elseif ($module == "SalesOrder") {
                        $value = '<a href="index.php?action=DetailView&module=SalesOrder&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>';
                    } elseif ($module == 'Emails') {
                        $value = $temp_val;
                    } else {
                        $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>';
                    }
                }
            } elseif ($fieldname == 'expectedroi' || $fieldname == 'actualroi' || $fieldname == 'actualcost' || $fieldname == 'budgetcost' || $fieldname == 'expectedrevenue') {
                $rate = $user_info['conv_rate'];
                $value = convertFromDollar($temp_val, $rate);
            } elseif (($module == 'Invoice' || $module == 'Quotes' || $module == 'PurchaseOrder' || $module == 'SalesOrder') && ($fieldname == 'hdnGrandTotal' || $fieldname == 'hdnSubTotal' || $fieldname == 'txtAdjustment' || $fieldname == 'hdnDiscountAmount' || $fieldname == 'hdnS_H_Amount')) {
                $currency_info = getInventoryCurrencyInfo($module, $entity_id);
                $currency_id = $currency_info['currency_id'];
                $currency_symbol = $currency_info['currency_symbol'];
                $value = $currency_symbol . $temp_val;
            } else {
                $value = $temp_val;
            }
        }
    }
    // Mike Crowe Mod --------------------------------------------------------Make right justified and vtiger_currency value
    if (in_array($uitype, array(71, 72, 7, 9, 90))) {
        $value = '<span align="right">' . $value . '</div>';
    }
    $log->debug("Exiting getValue method ...");
    return $value;
}
Exemplo n.º 11
0
 $fresult = $adb->pquery($myquery, array($temp));
 if ($pmodule == 'Contacts') {
     require_once 'modules/Contacts/Contacts.php';
     $myfocus = new Contacts();
     $myfocus->retrieve_entity_info($mycrmid, "Contacts");
 } elseif ($pmodule == 'Accounts') {
     require_once 'modules/Accounts/Accounts.php';
     $myfocus = new Accounts();
     $myfocus->retrieve_entity_info($mycrmid, "Accounts");
 } elseif ($pmodule == 'Leads') {
     require_once 'modules/Leads/Leads.php';
     $myfocus = new Leads();
     $myfocus->retrieve_entity_info($mycrmid, "Leads");
 } elseif ($pmodule == 'Vendors') {
     require_once 'modules/Vendors/Vendors.php';
     $myfocus = new Vendors();
     $myfocus->retrieve_entity_info($mycrmid, "Vendors");
 } else {
     // vtlib customization: Enabling mail send from other modules
     $myfocus = CRMEntity::getInstance($pmodule);
     $myfocus->retrieve_entity_info($mycrmid, $pmodule);
     // END
 }
 $fldname = $adb->query_result($fresult, 0, "columnname");
 $emailadd = br2nl($myfocus->column_fields[$fldname]);
 //This is to convert the html encoded string to original html entities so that in mail description contents will be displayed correctly
 //$focus->column_fields['description'] = from_html($focus->column_fields['description']);
 if ($emailadd != '') {
     $description = getMergedDescription($_REQUEST['description'], $mycrmid, $pmodule);
     //Email Open Tracking
     global $site_URL, $application_unique_key;
 public function submissionAction()
 {
     $vid = $this->_getParam('vid');
     $v = new Vendors($vid);
     if (!empty($_POST)) {
         $comment = $this->_getParam('comments');
         $v->application_notes = $comment;
         $v->save();
         if ($_FILES['submission']['tmp_name'] != "") {
             $tempFile = $_FILES['submission']['tmp_name'];
             $filename = $_FILES['submission']['name'];
             $cr_submission = $this->upload($tempFile, $filename);
             $vc = new VendorsCredentials();
             $vc->vendor_id = $v->id;
             $vc->cred_id = Constants::CR_ESSAY_SUBMISSION;
             $vc->filename = $cr_submission;
             $vc->save();
         }
         // Set message
         $msg = "Once an administrator has approved your application we will provide you with the next step.";
         $params = array('msg' => $msg);
         $this->_forward('thankyou', 'signup', 'vendor', $params);
     }
     $this->view->vendor = $v;
 }
Exemplo n.º 13
0
    public static function createNewFromSessionData($current_upload_file,$client){

        if (file_exists($current_upload_file['filepath'])) {
            // create document

            $document = new Documents();
            $document->Document_Type = $current_upload_file['doctype'];
            $document->User_ID = Yii::app()->user->userID;
            $document->Client_ID = Yii::app()->user->clientID;
            $document->Project_ID = Yii::app()->user->projectID;
            $document->Created = date("Y-m-d H:i:s");
            $document->save();
            $new_doc_id=$document->Document_ID;

            Audits::LogAction($document->Document_ID ,Audits::ACTION_UPLOAD);

            // insert image
            $image = new Images();
            $imageData = addslashes(fread(fopen($current_upload_file['filepath'],"rb"),filesize($current_upload_file['filepath'])));
            //$imageData = FileModification::ImageToPdfByFilePath($current_upload_file['filepath']);
            $image->Document_ID = $document->Document_ID;
            $image->Img = $imageData;
            $image->File_Name = $current_upload_file['name'];
            $image->Mime_Type = $current_upload_file['mimetype'];
            $image->File_Hash = sha1_file($current_upload_file['filepath']);
            $image->File_Size = intval(filesize($current_upload_file['filepath']));
            $image->Pages_Count = FileModification::calculatePagesByPath($current_upload_file['filepath']);

            $image->save();

            $infile = @file_get_contents($current_upload_file['filepath'], FILE_BINARY);
            if (($current_upload_file['mimetype'] == 'application/pdf' && $image->findPdfText($infile) == '')
                || $current_upload_file['mimetype'] != 'application/pdf') {
                Documents::crateDocumentThumbnail($current_upload_file['filepath'], 'thumbs', $current_upload_file['mimetype'], $document->Document_ID, 80);
            }

            // delete file from temporary catalog
            unlink($current_upload_file['filepath']);
        }

        $fedId = trim($current_upload_file['fed_id']);
        $newCompanyName = trim($current_upload_file['company_name']);

        // get company info
        $company = Companies::model()->with('client')->findByAttributes(array(
            'Company_Fed_ID' => $fedId,
        ));

        // create w9
        $W9 = new W9();
        $W9->Document_ID = $document->Document_ID;
        $W9->W9_Owner_ID = Yii::app()->user->clientID;
        $W9->Creator_ID = Yii::app()->user->userID;
        $W9->Business_Name = trim($current_upload_file['bus_name']);
        $W9->Tax_Class =  trim($current_upload_file['tax_name']);

        // get user info
        $user = Users::model()->with('person')->findByPk(Yii::app()->user->userID);

        if ($company) {
            // if company exisits
            $client = $company->client;

            //fill created company with dataentry values from session
            Companies::fillWithSessionDataEntry($company,$current_upload_file);

            $existingW9 = W9::model()->findByAttributes(array(
                'Client_ID' => $client->Client_ID,
                'W9_Owner_ID' => Yii::app()->user->clientID,
            ));

            if ($existingW9) {
                $W9->Revision_ID = -1;
            } else {
                $W9->Revision_ID = 0;
            }

            $vendor = Vendors::model()->findByAttributes(array(
                'Client_Client_ID' => Yii::app()->user->clientID,
                'Vendor_Client_ID' => $client->Client_ID,
            ));

            if (isset($vendor->Active_Relationship) && $vendor->Active_Relationship == Vendors::NOT_ACTIVE_RELATIONSHIP) {
                $vendor->Active_Relationship = Vendors::ACTIVE_RELATIONSHIP;
                $vendor->save();
            } else if (!$vendor && Yii::app()->user->clientID != 0 && Yii::app()->user->clientID != $client->Client_ID) {
                $vendor = new Vendors();
                $vendor->Vendor_ID_Shortcut = '';
                $vendor->Vendor_Client_ID = $client->Client_ID;
                $vendor->Client_Client_ID = Yii::app()->user->clientID;
                $vendor->Vendor_Name_Checkprint = '';
                $vendor->Vendor_1099 = '';
                $vendor->Vendor_Default_GL = '';
                $vendor->Vendor_Default_GL_Note = '';
                $vendor->Vendor_Note_General = '';
                $vendor->save();
            }
        } else {
            //if company does not exists, create new company

            $company_model = Companies::model()->findByPk($client->Company_ID);
            //fill created company with dataentry values from session
            Companies::fillWithSessionDataEntry($company_model,$current_upload_file);

            if (Yii::app()->user->clientID != 0) {
                $vendor = new Vendors();
                $vendor->Vendor_ID_Shortcut = '';
                $vendor->Vendor_Client_ID = $company_model->Company_ID;
                $vendor->Client_Client_ID = Yii::app()->user->clientID;
                $vendor->Vendor_Name_Checkprint = '';
                $vendor->Vendor_1099 = '';
                $vendor->Vendor_Default_GL = '';
                $vendor->Vendor_Default_GL_Note = '';
                $vendor->Vendor_Note_General = '';
                $vendor->save();
            }

            $W9->Revision_ID = 0;
        }

        // save w9
        $W9->Client_ID = $client->Client_ID;
        $W9->save();

        return $W9;

    }
Exemplo n.º 14
0
	/**
	 * Lists all models.
	 */
	public function actionIndex()
	{
        if (isset($_POST['oper']) && $_POST['oper'] == 'edit') {
            $companyId = intval($_POST["id"]);
            $company = Companies::model()->with('client', 'adreses')->findByPk($companyId);
            if ($company) {
                if ($company->client) {
                    $client = $company->client;
                    $client->Client_Number = $_POST["Client_Number"];
                    $client->Client_Logo_Name = $_POST["Client_Logo_Name"];
                    $client->Client_Approval_Amount_1 = $_POST["Client_Approval_Amount_1"] ? $_POST["Client_Approval_Amount_1"] : null;
                    $client->Client_Approval_Amount_2 = $_POST["Client_Approval_Amount_2"] ? $_POST["Client_Approval_Amount_2"] : null;
                    if ($client->validate()) {
                        $client->save();
                        echo "client\n";
                    }
                }

                if ($company->adreses) {
                    $addresses = $company->adreses;
                    if (isset($addresses[0])) {
                        $address = $addresses[0];
                        $address->Address1 =  $_POST["Address1"];
                        $address->Address2 =  $_POST["Address2"];
                        $address->City =  $_POST["City"];
                        $address->State =  $_POST["State"];
                        $address->ZIP =  $_POST["ZIP"];
                        $address->Country =  $_POST["Country"];
                        $address->Phone =  $_POST["Phone"];
                        $address->Fax =  $_POST["Fax"];

                        if ($address->validate()) {
                            $address->save();
                            echo "address\n";
                        }
                    }
                }

                $company->Company_Name = $_POST["Company_Name"];
                $company->Company_Fed_ID = $_POST["Company_Fed_ID"];
                $company->Email = $_POST["Email"];
                $company->SSN = $_POST["SSN"];
                $company->Business_NameW9 = $_POST["Business_NameW9"];

                if ($company->validate()) {
                    $company->save();
                    echo "company\n";
                }
            }
            die;
        }

        if (isset($_POST['oper']) && $_POST['oper'] == 'add') {
            die;
        }

        if (isset($_POST['oper']) && $_POST['oper'] == 'del') {
            $companyId = intval($_POST["id"]);
            $company = Companies::model()->with('client', 'adreses')->findByPk($companyId);
            $documents = Documents::model()->findByAttributes(array(
                'Client_ID' => $company->client->Client_ID,
            ));

            if ($company && !$documents) {
                if ($company->client) {
                    $client = $company->client;

                    UsersToApprove::model()->deleteAllByAttributes(array(
                        'Client_ID' => $client->Client_ID,
                    ));

                    UsersClientList::model()->deleteAllByAttributes(array(
                        'Client_ID' => $client->Client_ID,
                    ));

                    UsersProjectList::model()->deleteAllByAttributes(array(
                        'Client_ID' => $client->Client_ID,
                    ));

                    BankAcctNums::model()->deleteAllByAttributes(array(
                        'Client_ID' => $client->Client_ID,
                    ));

                    Coa::model()->deleteAllByAttributes(array(
                        'Client_ID' => $client->Client_ID,
                    ));

                    Vendors::model()->deleteAllByAttributes(array(
                        'Client_Client_ID' => $client->Client_ID,
                    ));

                    Vendors::model()->deleteAllByAttributes(array(
                        'Vendor_Client_ID' => $client->Client_ID,
                    ));

                    $w9s = W9::model()->findAllByAttributes(array(
                        'Client_ID' => $client->Client_ID,
                    ));

                    if ($w9s) {
                        foreach ($w9s as $w9) {
                            W9::deleteW9($w9->W9_ID);
                        }
                    }

                    $projects = Projects::model()->findAllByAttributes(array(
                        'Client_ID' => $client->Client_ID,
                    ));

                    if ($projects) {
                        foreach ($projects as $project) {
                            PoFormatting::model()->deleteAllByAttributes(array(
                                'Project_ID' => $project->Project_ID,
                            ));
                            $project->delete();
                        }
                    }

                    $client->delete();
                }

                if ($company->adreses) {
                    $addresses = $company->adreses;
                    foreach ($addresses as $address) {
                        $address->delete();
                    }
                }

                CompanyAddresses::model()->deleteAllByAttributes(array(
                    'Company_ID' => $companyId,
                ));

                $company->delete();
            }
            die;
        }

        $conn = mysql_connect(Yii::app()->params->dbhost, Yii::app()->params->dbuser, Yii::app()->params->dbpassword);
        mysql_select_db(Yii::app()->params->dbname);
        mysql_query("SET NAMES 'utf8'");

        Yii::import('ext.phpgrid.inc.jqgrid');

        // set columns
        $col = array();
        $col["title"] = "Company ID"; // caption of column
        $col["name"] = "Company_ID";
        $col["dbname"] = "companies.Company_ID"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = false; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = false;
        $col["sortable"] = false;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Company Name"; // caption of column
        $col["name"] = "Company_Name";
        $col["dbname"] = "companies.Company_Name"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Fed ID"; // caption of column
        $col["name"] = "Company_Fed_ID";
        $col["dbname"] = "companies.Company_Fed_ID"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "SSN"; // caption of column
        $col["name"] = "SSN";
        $col["dbname"] = "companies.SSN"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $col["sortable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Email"; // caption of column
        $col["name"] = "Email";
        $col["dbname"] = "companies.Email"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Business_NameW9"; // caption of column
        $col["name"] = "Business_NameW9";
        $col["dbname"] = "companies.Business_NameW9"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Client ID"; // caption of column
        $col["name"] = "Client_ID";
        $col["dbname"] = "clients.Client_ID"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = false; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = false;
        $col["sortable"] = false;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Client Number"; // caption of column
        $col["name"] = "Client_Number";
        $col["dbname"] = "clients.Client_Number"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Client Logo Name"; // caption of column
        $col["name"] = "Client_Logo_Name";
        $col["dbname"] = "clients.Client_Logo_Name"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Client Approval Amount 1"; // caption of column
        $col["name"] = "Client_Approval_Amount_1";
        $col["dbname"] = "clients.Client_Approval_Amount_1"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Client Approval Amount 2"; // caption of column
        $col["name"] = "Client_Approval_Amount_2";
        $col["dbname"] = "clients.Client_Approval_Amount_2"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Address ID"; // caption of column
        $col["name"] = "Address_ID";
        $col["dbname"] = "addresses.Address_ID"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = false; // this column is editable
        $col["hidden"] = true;
        $col["viewable"] = true;
        $col["search"] = false;
        $col["sortable"] = false;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Address1"; // caption of column
        $col["name"] = "Address1";
        $col["dbname"] = "addresses.Address1"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Address2"; // caption of column
        $col["name"] = "Address2";
        $col["dbname"] = "addresses.Address2"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "City"; // caption of column
        $col["name"] = "City";
        $col["dbname"] = "addresses.City"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "State"; // caption of column
        $col["name"] = "State";
        $col["dbname"] = "addresses.State"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "ZIP"; // caption of column
        $col["name"] = "ZIP";
        $col["dbname"] = "addresses.ZIP"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Country"; // caption of column
        $col["name"] = "Country";
        $col["dbname"] = "addresses.Country"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Phone"; // caption of column
        $col["name"] = "Phone";
        $col["dbname"] = "addresses.Phone"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Fax"; // caption of column
        $col["name"] = "Fax";
        $col["dbname"] = "addresses.Fax"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $cols[] = $col;

        $g = new jqgrid();

        $grid["caption"] = "Clients";
       // $grid["multiselect"] = true;
        $grid["autowidth"] = true;
        $grid["resizable"] = true;
        //$grid["toppager"] = true;
        $grid["sortname"] = 'companies.Company_Name';
        $grid["sortorder"] = "ASC";
        $grid["add_options"] = array(
            'width'=>'420',
            "closeAfterEdit"=>true, // close dialog after add/edit
            "top"=>"200", // absolute top position of dialog
            "left"=>"200" // absolute left position of dialog
        );

        $g->set_options($grid);

        $g->set_actions(array(
                "add"=>false, // allow/disallow add
                "edit"=>true, // allow/disallow edit
                "delete"=>true, // allow/disallow delete
                "rowactions"=>true, // show/hide row wise edit/del/save option
                "export"=>true, // show/hide export to excel option
                "autofilter" => true, // show/hide autofilter for search
                "search" => "advance" // show single/multi field search condition (e.g. simple or advance)
            )
        );

        $g->select_command = "SELECT  clients.Client_ID, clients.Client_Number, clients.Client_Logo_Name,
                                      companies.*, addresses.*, clients.Client_Approval_Amount_1,
                                      clients.Client_Approval_Amount_2
                              FROM clients
                              LEFT JOIN companies ON clients.Company_ID = companies.Company_ID
                              LEFT JOIN company_addresses ON company_addresses.Company_ID = companies.Company_ID
                              LEFT JOIN addresses ON addresses.Address_ID = company_addresses.Address_ID";

        // set database table for CRUD operations
        $g->table = "clients";

        $g->set_columns($cols);

        // group columns header
        $g->set_group_header( array(
                "useColSpanStyle"=>true,
                "groupHeaders"=>array(
                    array(
                        "startColumnName"=>'Company_ID', // group starts from this column
                        "numberOfColumns"=>6, // group span to next 2 columns
                        "titleText"=>'Company Information' // caption of group header
                    ),
                    array(
                        "startColumnName"=>'Client_ID', // group starts from this column
                        "numberOfColumns"=>5, // group span to next 2 columns
                        "titleText"=>'Client Information' // caption of group header
                    ),
                    array(
                        "startColumnName"=>'Address1', // group starts from this column
                        "numberOfColumns"=>8, // group span to next 2 columns
                        "titleText"=>"Company's Address" // caption of group header
                    )
                )
            )
        );

        // render grid and get html/js output
        $out = $g->render("Clients");

        $this->render('index',array(
            'out'=>$out,
        ));
	}
Exemplo n.º 15
0
require_once 'include/ListView/ListView.php';
require_once 'include/utils/utils.php';
require_once 'modules/CustomView/CustomView.php';
global $app_strings, $mod_strings, $list_max_entries_per_page, $currentModule, $theme, $adb;
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
$smarty = new vtigerCRM_Smarty();
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
$smarty->assign("MODULE", $currentModule);
$smarty->assign("SINGLE_MOD", 'Vendor');
$category = getParentTab();
$smarty->assign("CATEGORY", $category);
$focus = new Vendors();
// Initialize sort by fields
$focus->initSortbyField('Vendors');
// END
$other_text = array();
if (!$_SESSION['lvs'][$currentModule]) {
    unset($_SESSION['lvs']);
    $modObj = new ListViewSession();
    $modObj->sorder = $sorder;
    $modObj->sortby = $order_by;
    $_SESSION['lvs'][$currentModule] = get_object_vars($modObj);
}
if ($_REQUEST['errormsg'] != '') {
    $errormsg = vtlib_purify($_REQUEST['errormsg']);
    $smarty->assign("ERROR", "The User does not have permission to delete " . $errormsg . " " . $currentModule);
} else {
Exemplo n.º 16
0
function create_vendor_from_webform($username, $sessionid, $vendorname, $email, $phone, $website)
{
    global $log;
    global $adb;
    global $current_user;
    if (!validateSession($username, $sessionid)) {
        return null;
    }
    require_once "modules/Users/Users.php";
    $seed_user = new Users();
    $user_id = $seed_user->retrieve_user_id($username);
    $current_user = $seed_user;
    $current_user->retrieve_entity_info($user_id, 'Users');
    $adb->println("Create New Vendor from Web Form - Starts");
    require_once "modules/Vendors/Vendors.php";
    if (isPermitted("Vendors", "EditView") == "yes") {
        $focus = new Vendors();
        $focus->column_fields['vendorname'] = $vendorname;
        $focus->column_fields['email'] = $email;
        $focus->column_fields['phone'] = $phone;
        $focus->column_fields['website'] = $website;
        $focus->save("Vendors");
        $focus->retrieve_entity_info($focus->id, "Vendors");
        $adb->println("Create New Vendor from Web Form - Ends");
        if ($focus->id != '') {
            return 'Vendor added successfully';
        } else {
            return "Vendor creation failed. Try again";
        }
    } else {
        return $accessDenied;
    }
}
Exemplo n.º 17
0
    /**
     * Get companies list to share w9
     * @return array
     */
    public static function getCompaniesToShareW9()
    {
        $companiesToShareW9 = array();

        $vendors = Vendors::getCompanyVendors('');
        foreach ($vendors as $vendor) {
            $companiesToShareW9[$vendor->client->Client_ID] = $vendor->client->company->Company_Name;
        }

        $user = Users::model()->with('clients.company')->findByPk(Yii::app()->user->userID);
        $clients = $user->clients;
        foreach ($clients as $clients) {
            $companiesToShareW9[$clients->Client_ID] = $clients->company->Company_Name;
        }

        asort($companiesToShareW9);

        return $companiesToShareW9;
    }
Exemplo n.º 18
0
    /**
     * Import Vendors
     * @param $clientID
     * @param $importedVendors
     */
    public static function importVendors($clientID, $importedVendors)
    {

        $all_amount=count($importedVendors);

        $i=0;
        $pb= ProgressBar::init();

        foreach($importedVendors as $importedVendor) {
            $company = Companies::model()->with('client')->findByAttributes(array(
                'Company_Fed_ID' => $importedVendor['fedId'],
            ));

            if ($company) {
                $client = $company->client;
            } else {
                //if company does not exists, create new company
                $client = Companies::createEmptyCompany($importedVendor['fedId'],  $importedVendor['companyName'], $importedVendor);
            }

            $vendorClientId = $client->Client_ID;

            $vendor = Vendors::model()->findByAttributes(array(
                'Client_Client_ID' => $clientID,
                'Vendor_Client_ID' => $vendorClientId,
            ));
            $newVendor = false;

            if (!$vendor) {
                $vendor = new Vendors();
                $newVendor = true;
            } else {
                $vendor->Active_Relationship = self::ACTIVE_RELATIONSHIP;
                $vendor->save();
            }

            $vendor->Vendor_ID_Shortcut = $importedVendor['shortcut'];
            $vendor->Vendor_Client_ID = $vendorClientId;
            $vendor->Client_Client_ID = $clientID;
            $vendor->Vendor_Name_Checkprint = $importedVendor['checkprint'];
            $vendor->Vendor_1099 = $importedVendor['v1099'];
            $vendor->Vendor_Default_GL = $importedVendor['defG'];
            $vendor->Vendor_Default_GL_Note = $importedVendor['defGLNote'];
            $vendor->Vendor_Note_General = $importedVendor['noteGeneral'];

            if ($vendor->validate()) {
                $vendor->save();
            } else if ($newVendor) {
                $vendor = new Vendors();
                $vendor->Vendor_ID_Shortcut = '';
                $vendor->Vendor_Client_ID = $vendorClientId;
                $vendor->Client_Client_ID = $clientID;
                $vendor->Vendor_Name_Checkprint = '';
                $vendor->Vendor_1099 = '';
                $vendor->Vendor_Default_GL = '';
                $vendor->Vendor_Default_GL_Note = '';
                $vendor->Vendor_Note_General = '';
                $vendor->Active_Relationship = self::ACTIVE_RELATIONSHIP;
                $vendor->save();
            }

            $i++;
            $percent=intval($i/$all_amount*100);
            session_start();
            $_SESSION['progress']=$percent;
            session_write_close();
        }
    }
Exemplo n.º 19
0
	/**
	 * Lists all models.
	 */
	public function actionIndex()
	{
        if (isset($_POST['oper']) && $_POST['oper'] == 'edit') {
            $vendorId = intval($_POST["id"]);
            $vendor = Vendors::model()->with('client')->findByPk($vendorId);
            if ($vendor) {
                $client = $vendor->client;
                $company = $client->company;

                $vendor->Vendor_ID_Shortcut = $_POST["Vendor_ID_Shortcut"];
                $vendor->Vendor_Name_Checkprint = $_POST["Vendor_Name_Checkprint"];
                $vendor->Vendor_1099 = $_POST["Vendor_1099"];
                $vendor->Vendor_Default_GL = $_POST["Vendor_Default_GL"];
                $vendor->Vendor_Default_GL_Note = $_POST["Vendor_Default_GL_Note"];
                $vendor->Vendor_Note_General = $_POST["Vendor_Note_General"];
                $vendor->Active_Relationship = $_POST["Active_Relationship"];
                if ($vendor->validate()) {
                    $vendor->save();
                    echo "vendor\n";
                }

                if ($company->adreses) {
                    $addresses = $company->adreses;
                    if (isset($addresses[0])) {
                        $address = $addresses[0];
                        $address->Address1 =  $_POST["Address1"];
                        $address->Address2 =  $_POST["Address2"];
                        $address->City =  $_POST["City"];
                        $address->State =  $_POST["State"];
                        $address->ZIP =  $_POST["ZIP"];
                        $address->Country =  $_POST["Country"];
                        $address->Phone =  $_POST["Phone"];
                        $address->Fax =  $_POST["Fax"];

                        if ($address->validate()) {
                            $address->save();
                            echo "address\n";
                        }
                    }
                }

                $company->Company_Name = $_POST["Company_Name"];
                $company->Company_Fed_ID = $_POST["Company_Fed_ID"];
                $company->Email = $_POST["Email"];
                $company->SSN = $_POST["SSN"];
                $company->Business_NameW9 = $_POST["Business_NameW9"];
                if ($company->validate()) {
                    $company->save();
                    echo "company\n";
                }
            }
            die;
        }

        if (isset($_POST['oper']) && $_POST['oper'] == 'add') {
            die;
        }

        if (isset($_POST['oper']) && $_POST['oper'] == 'del') {
            $vendorId = intval($_POST["id"]);
            $vendor = Vendors::model()->findByPk($vendorId);
            if ($vendor) {
                $vendor->delete();
            }
            die;
        }

        $conn = mysql_connect(Yii::app()->params->dbhost, Yii::app()->params->dbuser, Yii::app()->params->dbpassword);
        mysql_select_db(Yii::app()->params->dbname);
        mysql_query("SET NAMES 'utf8'");

        Yii::import('ext.phpgrid.inc.jqgrid');

        // set columns
        $col = array();
        $col["title"] = "Vendor ID"; // caption of column
        $col["name"] = "Vendor_ID";
        $col["dbname"] = "vendors.Vendor_ID"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = false; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = false;
        $col["sortable"] = false;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Vendor Shortcut"; // caption of column
        $col["name"] = "Vendor_ID_Shortcut";
        $col["dbname"] = "vendors.Vendor_ID_Shortcut"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $col["sortable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Vendor Checkprint"; // caption of column
        $col["name"] = "Vendor_Name_Checkprint";
        $col["dbname"] = "vendors.Vendor_Name_Checkprint"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $col["sortable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Vendor 1099"; // caption of column
        $col["name"] = "Vendor_1099";
        $col["dbname"] = "vendors.Vendor_1099"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $col["sortable"] = true;
        $col["edittype"] = "select";
        $col["editoptions"] = array("value"=>'0:0;1:1');
        $cols[] = $col;

        $col = array();
        $col["title"] = "Client_Client_ID"; // caption of column
        $col["name"] = "Client_Client_ID";
        $col["dbname"] = "vendors.Client_Client_ID"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = false; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Vendor Default GL"; // caption of column
        $col["name"] = "Vendor_Default_GL";
        $col["dbname"] = "vendors.Vendor_Default_GL"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $col["sortable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Vendor GL Note"; // caption of column
        $col["name"] = "Vendor_Default_GL_Note";
        $col["dbname"] = "vendors.Vendor_Default_GL_Note"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $col["sortable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Vendor Note General"; // caption of column
        $col["name"] = "Vendor_Note_General";
        $col["dbname"] = "vendors.Vendor_Note_General"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $col["sortable"] = true;
        $col["edittype"] = "textarea";
        $col["editoptions"] = array("cols"=>'20', 'rows' => '3');
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Active Relationship"; // caption of column
        $col["name"] = "Active_Relationship";
        $col["dbname"] = "vendors.Active_Relationship"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $col["sortable"] = true;
        $col["edittype"] = "select";
        $col["editoptions"] = array("value"=>'0:0;1:1');
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Company ID"; // caption of column
        $col["name"] = "Company_ID";
        $col["dbname"] = "companies.Company_ID"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = false; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = false;
        $col["sortable"] = false;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Company Name"; // caption of column
        $col["name"] = "Company_Name";
        $col["dbname"] = "companies.Company_Name"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Fed ID"; // caption of column
        $col["name"] = "Company_Fed_ID";
        $col["dbname"] = "companies.Company_Fed_ID"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "SSN"; // caption of column
        $col["name"] = "SSN";
        $col["dbname"] = "companies.SSN"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Email"; // caption of column
        $col["name"] = "Email";
        $col["dbname"] = "companies.Email"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Business_NameW9"; // caption of column
        $col["name"] = "Business_NameW9";
        $col["dbname"] = "companies.Business_NameW9"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Address1"; // caption of column
        $col["name"] = "Address1";
        $col["dbname"] = "addresses.Address1"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Address2"; // caption of column
        $col["name"] = "Address2";
        $col["dbname"] = "addresses.Address2"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "City"; // caption of column
        $col["name"] = "City";
        $col["dbname"] = "addresses.City"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "State"; // caption of column
        $col["name"] = "State";
        $col["dbname"] = "addresses.State"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "ZIP"; // caption of column
        $col["name"] = "ZIP";
        $col["dbname"] = "addresses.ZIP"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Country"; // caption of column
        $col["name"] = "Country";
        $col["dbname"] = "addresses.Country"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Phone"; // caption of column
        $col["name"] = "Phone";
        $col["dbname"] = "addresses.Phone"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Fax"; // caption of column
        $col["name"] = "Fax";
        $col["dbname"] = "addresses.Fax"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $cols[] = $col;

        $g = new jqgrid();

        $grid["caption"] = "Vendor List";
       // $grid["multiselect"] = true;
        $grid["autowidth"] = true;
        $grid["resizable"] = true;
        //$grid["toppager"] = true;
        $grid["sortname"] = 'companies.Company_Name';
        $grid["sortorder"] = "ASC";

        $grid["add_options"] = array(
            'width'=>'420',
            "closeAfterEdit"=>true, // close dialog after add/edit
            "top"=>"200", // absolute top position of dialog
            "left"=>"200" // absolute left position of dialog
        );

        $g->set_options($grid);

        $g->set_actions(array(
                "add"=>false, // allow/disallow add
                "edit"=>true, // allow/disallow edit
                "delete"=>true, // allow/disallow delete
                "rowactions"=>true, // show/hide row wise edit/del/save option
                "export"=>true, // show/hide export to excel option
                "autofilter" => true, // show/hide autofilter for search
                "search" => "advance" // show single/multi field search condition (e.g. simple or advance)
            )
        );

        $g->select_command = "SELECT vendors.*, companies.*, addresses.*
                              FROM vendors
                              LEFT JOIN clients ON clients.Client_ID = vendors.Vendor_Client_ID
                              LEFT JOIN companies ON clients.Company_ID = companies.Company_ID
                              LEFT JOIN company_addresses ON company_addresses.Company_ID = companies.Company_ID
                              LEFT JOIN addresses ON addresses.Address_ID = company_addresses.Address_ID";

        // set database table for CRUD operations
        $g->table = "vendors";

        $g->set_columns($cols);

        // group columns header
        $g->set_group_header( array(
                "useColSpanStyle"=>true,
                "groupHeaders"=>array(
                    array(
                        "startColumnName"=>'Vendor_ID', // group starts from this column
                        "numberOfColumns"=>9, // group span to next 2 columns
                        "titleText"=>'Vendor Information' // caption of group header
                    ),
                    array(
                        "startColumnName"=>'Company_ID', // group starts from this column
                        "numberOfColumns"=>6, // group span to next 2 columns
                        "titleText"=>'Vendor Company' // caption of group header
                    ),
                    array(
                        "startColumnName"=>'Address1', // group starts from this column
                        "numberOfColumns"=>8, // group span to next 2 columns
                        "titleText"=>"Vendor's Address" // caption of group header
                    )
                )
            )
        );

        // render grid and get html/js output
        $out = $g->render("Vendors");

        $this->render('index',array(
            'out'=>$out,
        ));
	}
Exemplo n.º 20
0
    /**
     * Prepare documents of subsection to view
     * @param $documents
     * @param $vendorId
     * @param $sectionFolderCategory
     * @param $year
     * @return array
     */
    public static function prepareDocumentsOfSubsectionToView($documents, $vendorId, $sectionFolderCategory, $year)
    {
        $result = array();

        // if section is W9 Book, add all available for company W9s (they are not in LibraryDocs)
        if ($sectionFolderCategory == Sections::W9_BOOK) {
            $w9Docs = W9::getAvailableW9sOfYear($year);
            foreach ($w9Docs as $w9Doc) {
                $result[] = $w9Doc;
            }
        }

        foreach($documents as $document) {
            $result[] = $document->document;
        }

        // if section is Vendor Documents, add last available for company W9s of this vendor (it is not in LibraryDocs)
        if ($vendorId != 0 && $sectionFolderCategory == Sections::VENDOR_DOCUMENTS) {
            $vendor = Vendors::model()->with('client')->findByPk($vendorId);
            if ($vendor) {
                $document = W9::getCompanyW9Doc($vendor->client->Client_ID);
                if ($document) {
                    $result[] = $document;
                }
            }
        }

        return $result;
    }
Exemplo n.º 21
0
require_once 'include/ListView/ListView.php';
require_once 'include/utils/utils.php';
require_once 'modules/CustomView/CustomView.php';
global $app_strings, $mod_strings, $list_max_entries_per_page, $currentModule, $theme, $adb;
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
$smarty = new vtigerCRM_Smarty();
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
$smarty->assign("MODULE", $currentModule);
$smarty->assign("SINGLE_MOD", 'Vendor');
$category = getParentTab();
$smarty->assign("CATEGORY", $category);
$focus = new Vendors();
// Initialize sort by fields
$focus->initSortbyField('Vendors');
// END
$other_text = array();
if (!$_SESSION['lvs'][$currentModule]) {
    unset($_SESSION['lvs']);
    $modObj = new ListViewSession();
    $modObj->sorder = $sorder;
    $modObj->sortby = $order_by;
    $_SESSION['lvs'][$currentModule] = get_object_vars($modObj);
}
if ($_REQUEST['errormsg'] != '') {
    $errormsg = vtlib_purify($_REQUEST['errormsg']);
    $smarty->assign("ERROR", "The User does not have permission to delete " . $errormsg . " " . $currentModule);
} else {
Exemplo n.º 22
0
    if ($_REQUEST['return_module'] == 'Services') {
        $focus->column_fields['product_id'] = vtlib_purify($_REQUEST['parent_id']);
        $log->debug("Service Id from the request is " . vtlib_purify($_REQUEST['parent_id']));
        $associated_prod = getAssociatedProducts("Services", $focus, $focus->column_fields['product_id']);
        for ($i = 1; $i <= count($associated_prod); $i++) {
            $associated_prod_id = $associated_prod[$i]['hdnProductId' . $i];
            $associated_prod_prices = getPricesForProducts($currencyid, array($associated_prod_id), 'Services');
            $associated_prod[$i]['listPrice' . $i] = $associated_prod_prices[$associated_prod_id];
        }
        $smarty->assign("ASSOCIATEDPRODUCTS", $associated_prod);
        $smarty->assign("AVAILABLE_PRODUCTS", 'true');
    }
}
if (isset($_REQUEST['vendor_id']) && $_REQUEST['vendor_id'] != '' && $_REQUEST['record'] == '') {
    require_once 'modules/Vendors/Vendors.php';
    $vend_focus = new Vendors();
    $vend_focus->retrieve_entity_info($_REQUEST['vendor_id'], "Vendors");
    $focus->column_fields['bill_city'] = $vend_focus->column_fields['city'];
    $focus->column_fields['ship_city'] = $vend_focus->column_fields['city'];
    $focus->column_fields['bill_street'] = $vend_focus->column_fields['street'];
    $focus->column_fields['ship_street'] = $vend_focus->column_fields['street'];
    $focus->column_fields['bill_state'] = $vend_focus->column_fields['state'];
    $focus->column_fields['ship_state'] = $vend_focus->column_fields['state'];
    $focus->column_fields['bill_code'] = $vend_focus->column_fields['postalcode'];
    $focus->column_fields['ship_code'] = $vend_focus->column_fields['postalcode'];
    $focus->column_fields['bill_country'] = $vend_focus->column_fields['country'];
    $focus->column_fields['ship_country'] = $vend_focus->column_fields['country'];
    $focus->column_fields['bill_pobox'] = $vend_focus->column_fields['pobox'];
    $focus->column_fields['ship_pobox'] = $vend_focus->column_fields['pobox'];
}
$disp_view = getView($focus->mode);
Exemplo n.º 23
0
    /**
     * Create Vendor's folder for project
     * @param $projectId
     * @param $vendorId
     * @param $year
     * @return int
     */
    public static function createVendorFolder($projectId, $vendorId, $year)
    {
        // get cabinet
        $cabinet = self::getCabinetForFolderCreate($projectId, $year);

        // get vendor info
        $vendor = Vendors::model()->with('client.company')->findByPk($vendorId);

        $folder = Sections::model()->findByAttributes(array(
            'Section_Type' => Storages::CABINET,
            'Created_By' => '0',
            'Storage_ID' => $cabinet->Storage_ID,
            'Vendor_ID' => $vendorId,
            'Folder_Cat_ID' => self::VENDOR_DOCUMENTS,
        ));

        if (!$folder) {
            $folder = new Sections();
            $folder->Storage_ID = $cabinet->Storage_ID;
            $folder->Section_Name = substr($vendor->client->company->Company_Name,0,50);
            $folder->Vendor_ID = $vendorId;
            $folder->Created_By = 0;
            $folder->Section_Type = Storages::CABINET;
            $folder->Folder_Cat_ID = self::VENDOR_DOCUMENTS;
            $folder->Access_Type = Storages::HAS_ACCESS;
            if ($folder->validate()) {
                $folder->save();

                $panel = new Subsections();
                $panel->Section_ID = $folder->Section_ID;
                $panel->Subsection_Name = 'Panel 1';
                $panel->Subsection_Type = Storages::CABINET;
                $panel->Created_By = 0;
                $panel->Access_Type = Storages::HAS_ACCESS;
                $panel->save();
            }
        } else {
            $panel = Subsections::model()->findByAttributes(array(
                'Subsection_Type' => Storages::CABINET,
                'Created_By' => '0',
                'Section_ID' => $folder->Section_ID,
            ));
        }

        return $panel->Subsection_ID;
    }