X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=sales%2Fincludes%2Fdb%2Fbranches_db.inc;h=e51de6f149234bd8004084fa8545d0f0919025ae;hb=6351305b2b0e5782804ab4d9e3db5f84b671d6f2;hp=48cd417de703c7b24330c604020ca15fb49c885f;hpb=f44132511cc91b83f20f91af0625d4b112b4c26e;p=fa-stable.git diff --git a/sales/includes/db/branches_db.inc b/sales/includes/db/branches_db.inc index 48cd417d..e51de6f1 100644 --- a/sales/includes/db/branches_db.inc +++ b/sales/includes/db/branches_db.inc @@ -267,3 +267,29 @@ function get_default_branch($customer_id, $ar_account=null) return db_fetch($result); } +function get_branches_search($customer, $branch) +{ + global $SysPrefs; + + if (isset($SysPrefs->max_rows_in_search)) + $limit = $SysPrefs->max_rows_in_search; + else + $limit = 10; + + $sql = "SELECT + b.branch_code, + b.branch_ref, + b.br_name, + p.name as contact_name, + p.phone + FROM ".TB_PREF."cust_branch b + LEFT JOIN ".TB_PREF."crm_contacts c + ON c.entity_id=b.branch_code AND c.type='cust_branch' AND c.action='general' + LEFT JOIN ".TB_PREF."crm_persons p ON c.person_id=p.id + WHERE b.debtor_no = ".db_escape($customer)." + AND b.br_name LIKE " . db_escape("%" . $branch. "%") . " + ORDER BY b.br_name LIMIT 0,".(int)($limit); + + return db_query($sql, "Failed in retreiving branches list."); +} +