~eventum-developers/eventum/trunk

« back to all changes in this revision

Viewing changes to lib/eventum/class.search.php

  • Committer: Bryan Alsdorf
  • Date: 2013-08-23 03:50:34 UTC
  • mto: (4033.1.168 eventum-skysql)
  • mto: This revision was merged to the branch mainline in revision 4660.
  • Revision ID: bryan@montyprogram.com-20130823035034-7f5r3pt1xg0xnnhk
Initial commit of CRM migration

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
            'hide_closed'    => $hide_closed,
91
91
            "sort_by"        => Misc::stripHTML($sort_by ? $sort_by : "pri_rank"),
92
92
            "sort_order"     => Misc::stripHTML($sort_order ? $sort_order : "ASC"),
93
 
            "customer_id"    => Misc::escapeInteger(self::getParam('customer_id')),
 
93
            "customer_id"    => Misc::escapeString(self::getParam('customer_id')),
94
94
            // quick filter form
95
95
            'keywords'       => self::getParam('keywords', $request_only),
96
96
            'match_mode'     => self::getParam('match_mode', $request_only),
410
410
            Issue::getAssignedUsersByIssues($res);
411
411
            Time_Tracking::getTimeSpentByIssues($res);
412
412
            // need to get the customer titles for all of these issues...
413
 
            if (Customer::hasCustomerIntegration($prj_id)) {
414
 
                Customer::getCustomerTitlesByIssues($prj_id, $res);
415
 
                Customer::getSupportLevelsByIssues($prj_id, $res);
 
413
            if (CRM::hasCustomerIntegration($prj_id)) {
 
414
                $crm = CRM::getInstance($prj_id);
 
415
                $crm->processListIssuesResult($res);
416
416
            }
417
417
            Issue::formatLastActionDates($res);
418
418
            Issue::getLastStatusChangeDates($prj_id, $res);
456
456
            if (count($categories) > 0) {
457
457
                $fields[] = $res[$i]['prc_title'];
458
458
            }
459
 
            if (Customer::hasCustomerIntegration($prj_id)) {
 
459
            if (CRM::hasCustomerIntegration($prj_id)) {
460
460
                $fields[] = @$res[$i]['customer_title'];
461
 
                // check if current user is acustomer and has a per incident contract.
 
461
                // check if current user is a customer and has a per incident contract.
462
462
                // if so, check if issue is redeemed.
463
463
                if (User::getRoleByUser($usr_id, $prj_id) == User::getRoleID('Customer')) {
464
 
                    if ((Customer::hasPerIncidentContract($prj_id, Issue::getCustomerID($res[$i]['iss_id'])) &&
465
 
                            (Customer::isRedeemedIncident($prj_id, $res[$i]['iss_id'])))) {
466
 
                        $res[$i]['redeemed'] = true;
467
 
                    }
 
464
                    // TODOCRM: Fix per incident usage
 
465
//                    if ((Customer::hasPerIncidentContract($prj_id, Issue::getCustomerID($res[$i]['iss_id'])) &&
 
466
//                            (Customer::isRedeemedIncident($prj_id, $res[$i]['iss_id'])))) {
 
467
//                        $res[$i]['redeemed'] = true;
 
468
//                    }
468
469
                }
469
470
            }
470
471
            $fields[] = $res[$i]['sta_title'];
522
523
 
523
524
        $stmt = ' AND iss_usr_id = usr_id';
524
525
        if ($role_id == User::getRoleID('Customer')) {
525
 
            $stmt .= " AND iss_customer_id='" . User::getCustomerID($usr_id) . "'";
 
526
            $crm = CRM::getInstance($prj_id);
 
527
            $contact = $crm->getContact($usr_details['usr_customer_contact_id']);
 
528
            $stmt .= " AND iss_customer_contract_id IN('" . join("','", $contact->getContractIDS()) . "')";
 
529
            $stmt .= " AND iss_customer_id ='" . Auth::getCurrentCustomerID() . "'";
526
530
        } elseif (($role_id == User::getRoleID("Reporter")) && (Project::getSegregateReporters($prj_id))) {
527
531
            $stmt .= " AND (
528
532
                        iss_usr_id = $usr_id OR
568
572
            $stmt .= " AND (\n";
569
573
            if (($options['search_type'] == 'all_text') && (APP_ENABLE_FULLTEXT)) {
570
574
                $stmt .= "iss_id IN(" . join(', ', self::getFullTextIssues($options)) . ")";
571
 
            } elseif (($options['search_type'] == 'customer') && (Customer::hasCustomerIntegration($prj_id))) {
572
 
                // check if the user is trying to search by customer email
573
 
                $customer_ids = Customer::getCustomerIDsLikeEmail($prj_id, $options['keywords']);
 
575
            } elseif (($options['search_type'] == 'customer') && (CRM::hasCustomerIntegration($prj_id))) {
 
576
                // check if the user is trying to search by customer name / email
 
577
                $crm = CRM::getInstance($prj_id);
 
578
                $customer_ids = $crm->getCustomerIDsByString($options['keywords'], true);
574
579
                if (count($customer_ids) > 0) {
575
580
                    $stmt .= " iss_customer_id IN (" . implode(', ', $customer_ids) . ")";
576
581
                } else {