function stripDebug($xml, &$stripped = '') { $tags = array('strong', 'pre'); $tags_elems = array(); foreach ($tags as $tag) { $tags_elems[$tag] = array('start' => '<(?<' . $tag . '_start>' . $tag . ')[^>]*?>', 'end' => '<\\/(?<' . $tag . '_end>' . $tag . ')>'); } $reg = '/' . implode('|', set::flatten($tags_elems)) . '/sim'; $stack = 0; $offset = 0; $start = 0; while (preg_match($reg, $xml, $matches, PREG_OFFSET_CAPTURE, $offset)) { $matche = $this->qualifyMatch($matches); if ($matche['elem'] == 'start') { if ($stack == 0) { $start = $matche['pos']; } $stack++; } else { $stack--; if ($stack == 0) { $end = $matche['pos'] + strlen($matche['string']); $stripped .= substr($xml, $start, $end - $start); $xml = substr($xml, 0, $start) . substr($xml, $end); $offset -= $end - $start; continue; } } $offset = $matche['pos'] + strlen($matche['string']); } return $xml; }
/** * Conveniently creates new set instance prefilled with provided argument(s). * * If a single array is given, then its elements are used to prefill the set. * Otherwise all arguments become elements of new set. * * @return set created set */ function _A() { $arguments = func_get_args(); if (count($arguments) == 1 && is_array($arguments[0])) { return set::wrap($arguments[0]); } return set::wrap($arguments); }
/** * Simple function to return the $config array * @param array $config if set, merge with existing array * @return array $config */ public function config($config = array()) { $db =& ConnectionManager::getDataSource($this->useDbConfig); if (!empty($config) && is_array($config)) { $db->config = set::merge($db->config, $config); } return $db->config; }
public function _extractItem($items) { $temp = array(); foreach ($items as $index => $item) { $temp[$index]['title'] = set::classicExtract($item, "Item.name"); $temp[$index]['url']['controller'] = set::classicExtract($item, "Item.controller"); $temp[$index]['url']['action'] = set::classicExtract($item, "Item.action"); if (set::classicExtract($item, "children")) { $temp[$index]['children'] = $this->_extractItem(set::classicExtract($item, "children")); } } return $temp; }
function setup(&$Model, $settings = array()) { if (empty($settings['fieldsOpt'])) { $settings['fieldsOpt'] = array(); } if (!empty($settings['fields'])) { $settings['fieldsOpt'] = set::merge($settings['fieldsOpt'], array_filter(Set::normalize($settings['fields']))); $settings['fields'] = array_keys(Set::normalize($settings['fields'])); } if (empty($this->settings[$Model->alias])) { $this->settings[$Model->alias] = $this->defSettings; } $this->settings[$Model->alias] = set::merge($this->settings[$Model->alias], $settings); }
public function getList($pref = NULL) { // パラメータ範囲チェックと補正(デフォルト:東京) if (!($pref >= 1 && $pref <= 47)) { $pref = 13; } $prefLines = $this->find('all', array('conditions' => array('Station.pref_cd' => $pref), 'fields' => array('DISTINCT Station.line_cd', 'Station.line_name'))); $combineLines = set::combine($prefLines, '{n}.Station.line_cd', '{n}.Station'); $lineStations = $this->find('all', array('conditions' => array('Station.pref_cd' => $pref), 'fields' => array('Station.line_cd', 'Station.id', 'Station.station_name', 'Station.pref_cd'))); foreach ($lineStations as $tmpVal) { $combineLines[$tmpVal['Station']['line_cd']]['id'][] = $tmpVal['Station']['id']; $combineLines[$tmpVal['Station']['line_cd']]['station_name'][] = $tmpVal['Station']['station_name']; } //debug($combineLines); return $combineLines; }
function _subProductsFields($types, $prefix = 'ShopSubproduct.') { App::import('Lib', 'Shop.SetMulti'); $config = ShopConfig::load(); $typeFields = array(); if (!empty($types)) { foreach ($types as $key => $type) { $fields = set::normalize(array('id', 'code', 'label_fre', 'label_eng', 'operator', 'price')); if (isset($type['price']) && $type['price'] === false) { unset($fields['price']); unset($fields['operator']); } if (array_key_exists('price', $fields) && !empty($config['currencies'])) { //$fields['price']['label'] = __('Default Price',true); unset($fields['price']); foreach ($config['currencies'] as $currency) { $fOpt = array('label' => str_replace('%currency%', $currency, __('Price %currency%', true)), 'type' => 'text'); $fields['currency_prices.' . $currency] = $fOpt; } } if (array_key_exists('operator', $fields)) { if (count($type['operators']) == 1) { $fields = SetMulti::insertBeforeKey($fields, 'operator', array('operator_display' => array('type' => 'definition', 'value' => $type['operators'][0], 'label' => __('Operator', true)))); $fields['operator']['type'] = 'hidden'; $fields['operator']['value'] = $type['operators'][0]; } else { $fields['operator']['options'] = $type['operators']; } if (isset($type['adminFields'])) { $fields = set::merge($fields, $type['adminFields']); } } $typeField = array('type' => 'multiple', 'fields' => $fields, 'div' => array('class' => 'type')); if (!empty($type['children'])) { $typeField['subline'] = $this->_subProductsFields($type['children'], 'children.'); } $typeFields[$prefix . $key] = $typeField; } } return $typeFields; }
/** * Reduces an array to a the JS nomenclature for an object, useful for passing into JS configurations */ static function arrayFlatten($arrayNested) { $returnArray = array(); foreach ($arrayNested as $key => $val) { if (is_array($val)) { $returnArray = set::merge($returnArray, $val); } else { $returnArray[$key] = $val; } } return $returnArray; }
<td> <input type="text" name="client" id="clientNo" autocomplete="off"> <div class="autocompleteCname" id="dropDown"></div> </td> </tr><tr> <td> </td> <td>Customer no. <input type="text" name="cusNum" id="cusNum" style="background: none; border: none; width: 13em;" readonly="readonly"> </td> </tr><tr> <td valign="top" align="right"> Job number : </td> <td> <input type="text" name="jobNum" id="jobNum" autocomplete="off"> <div class="autocompleteCname" id="jobNumList"></div> </td> </tr><tr> <td valign="top" align="right"> Payment Date : </td> <td> <span id="colDate">' . set::mm_dd_yyyy($dNam = "day", $dIds = "day", $defDay = "", $dayAttr = "", $yNam = "year", $yIds = "year", $defYear = "", $yerAttr = "", $mNam = "month", $mIds = "month", $defMonth = "Month", $monAttr = "") . '</span> </td> </tr><tr> <td valign="top" align="right"> Payment Time : </td> <td> <span id="colDate"> <input type="text" name="colTime" id="colTime" value="' . date("h:i:s A", time()) . '"> </span> </td> </tr><tr> <td valign="top" align="right"> Sales Rep : </td> <td> <input type="text" name="salesRep" id="salesRep"> </td> </tr><tr> <td valign="top" align="right"> Payment Amount : </td> <td> <input type="text" name="payment" id="payment" autocomplete="off"> </td> </tr><tr> <td colspan="5"> <div style="height: 5.2em; width: 100%; background: none;"> <table style="font-size: 13pt; width: 98%;" border="0"> <tr> <td align="right"> Job order Amount Paid : </td>
function index($mode = Null) { // layout指定 $this->layout = 'connectlistsIndex'; // $userInfo取得 $this->_user(); // paginateの準備 $this->paginate = array( 'limit' => 10, 'order' => array('Connectlist.modified' => 'DESC') ); // switch ($mode) { case BOOKMARK: $indexMode = ($this->userInfo['class'] == STUDENT ? BOOKMARK : ALL); break; case ARCHIVE: $indexMode = ARCHIVE; break; case CONNECTLIST: $indexMode = ($this->userInfo['class'] == STUDENT ? CONNECTLIST : ALL); break; default: $indexMode = ALL; break; } // 受け渡し用変数宣言 $listList = Array(); if ($this->userInfo['class'] == STUDENT) { // 生徒の場合 switch ($indexMode) { case CONNECTLIST: $listData = $this->paginate($this->Connectlist, array( 'Connectlist.student_id' => $this->userInfo['id'], 'Connectlist.bookmark' => 0, 'NOT Connectlist.archive & 2' )); break; case BOOKMARK: $listData = $this->paginate($this->Connectlist, array( 'Connectlist.student_id' => $this->userInfo['id'], 'Connectlist.bookmark' => STUDENT, )); break; case ARCHIVE: $listData = $this->paginate($this->Connectlist, array( 'Connectlist.student_id' => $this->userInfo['id'], 'Connectlist.archive & 2' )); break; default: $listData = $this->paginate($this->Connectlist, array( 'Connectlist.student_id' => $this->userInfo['id'], 'NOT Connectlist.archive & 2' )); break; } // classifiedId / userId のリストを取得 $classifiedIds = set::combine($listData, '{n}.Connectlist.teacher_cid'); $classifiedIds = array_keys($classifiedIds); $userIds = set::combine($listData, '{n}.Connectlist.teacher_id'); $userIds = array_keys($userIds); } else if ($this->userInfo['class'] == TEACHER) { // 先生の場合 CONNECTLIST ARCHIVEのみ if ($indexMode != ARCHIVE) { $listData = $this->paginate($this->Connectlist, array( 'Connectlist.teacher_id' => $this->userInfo['id'], 'Connectlist.bookmark' => 0, 'NOT Connectlist.archive & 1' )); } else { $listData = $this->paginate($this->Connectlist, array( 'Connectlist.teacher_id' => $this->userInfo['id'], 'Connectlist.archive & 1' )); } // classifiedId / userId のリストを取得 $classifiedIds = set::combine($listData, '{n}.Connectlist.student_cid'); $classifiedIds = array_keys($classifiedIds); $userIds = set::combine($listData, '{n}.Connectlist.student_id'); $userIds = array_keys($userIds); } // Classifiedクエリ $classifiedData = $this->Classified->find('all', array( 'conditions' => array( 'Classified.id' => $classifiedIds ) )); // Classified.idで組み直し $classifiedList = Array(); foreach ($classifiedData as $tmpKey => $tmpValue) { $classifiedList[$tmpValue['Classified']['id']] = Array( 'Classified' => $tmpValue['Classified'] ); } // Userクエリ $userData = $this->User->find('all', array( 'conditions' => array( 'User.id' => $userIds ) )); // User.idで組み直し $userList = Array(); foreach ($userData as $tmpKey => $tmpValue) { $userList[$tmpValue['User']['id']] = Array( 'User' => $tmpValue['User'] ); } // Connectlistの順序で配列を合成 if ($this->userInfo['class'] == STUDENT) { // 生徒の場合 foreach ($listData as $tmpKey => $tmpValue) { $listList[$tmpKey] = Array( 'Connectlist' => $tmpValue['Connectlist'], 'Classified' => $classifiedList[$tmpValue['Connectlist']['teacher_cid']]['Classified'], 'User' => $userList[$tmpValue['Connectlist']['teacher_id']]['User'] ); } } else if ($this->userInfo['class'] == TEACHER) { // 先生の場合 CONNECTLIST ARCHIVEのみ foreach ($listData as $tmpKey => $tmpValue) { $listList[$tmpKey] = Array( 'Connectlist' => $tmpValue['Connectlist'], 'Classified' => $classifiedList[$tmpValue['Connectlist']['student_cid']]['Classified'], 'User' => $userList[$tmpValue['Connectlist']['student_id']]['User'] ); } } $this->set('listList', $listList); $this->set('indexMode', $indexMode); $this->set('userInfo', $this->userInfo); }
function index() { $this->layout = 'classifiedsIndex'; // デフォルトパラメータ $argsList = Array( 'page' => 1, 'dir' => 0, 'genre' => array(), 'area' => array(), 'wage' => array(), //'opt' => 0, //'parent' => false ); // ソート定義 $dirList = Array( array('Classified.modified' => 'DESC'), // 更新日の新しい順 array('Classified.eval' => 'DESC'), // 評価の高い順 array('Classified.wage' => 'ASC'), // 時間あたり報酬の安い順 array('Classified.wage' => 'DESC'), // 時間あたり報酬の高い順 array('Classified.connected' => 'DESC'), // 面接数の多い順 array('Classified.established' => 'DESC') // 成立数の多い順 ); // passedArgs取り込み // page if (isset($this->passedArgs['page'])) { $argsList['page'] = floor($this->passedArgs['page']); } // dir if (isset($this->passedArgs['dir'])) { $argsList['dir'] = floor($this->passedArgs['dir']); // range check if ($argsList['dir'] < 0 || $argsList['dir'] > 5) { $argsList['dir'] = 0; } } // genre genre指定の場合はcookieを上書き genreがない場合はcookieから読み込み if (isset($this->passedArgs['genre'])) { $argsList['genre'] = explode(':', $this->passedArgs['genre']); // genreの範囲逸脱 if (isset($this->passedArgs['genre'])) { if ($argsList['genre'][0] > 58) { $argsList['genre'][0] = 7; } if ($argsList['genre'][0] >= 13 && $argsList['genre'][0] <= 16) { $argsList['genre'][0] = 7; } if ($argsList['genre'][0] >= 25 && $argsList['genre'][0] <= 28) { $argsList['genre'][0] = 7; } if ($argsList['genre'][0] >= 37 && $argsList['genre'][0] <= 38) { $argsList['genre'][0] = 7; } if ($argsList['genre'][0] >= 47 && $argsList['genre'][0] <= 50) { $argsList['genre'][0] = 7; } } $writeCookie = Array('genre' => $argsList['genre']); $writeCookie = serialize($writeCookie); $this->Cookie->write('Genre', $writeCookie, true, '+2 weeks'); } else { $cookieData = $this->Cookie->read('Genre'); $cookieData = unserialize($cookieData); if (isset($cookieData['genre'])) { $argsList['genre'] = $cookieData['genre']; } else { // ほんとうになんにもgenreを指定していない場合 $argsList['genre'][0] = 7; } } // area area指定の場合はcookieを上書き areaがない場合はcookieから読み込み if (isset($this->passedArgs['area'])) { $argsList['area'] = explode(':', $this->passedArgs['area']); // areaの範囲逸脱 -> 1..856 if (isset($this->passedArgs['area'])) { if ($argsList['area'][0] > 856) { $argsList['area'][0] = 2; } } $writeCookie = Array('area' => $argsList['area']); $writeCookie = serialize($writeCookie); $this->Cookie->write('Area', $writeCookie, true, '+2 weeks'); } else { $cookieData = $this->Cookie->read('Area'); $cookieData = unserialize($cookieData); //debug($cookieData); if (isset($cookieData['area'])) { $argsList['area'] = $cookieData['area']; } else { $argsList['area'] = array( 0 ); // area指定がなくcookieにも記録がない場合 } } // wage if (isset($this->passedArgs['wage'])) { $argsList['wage'] = explode(':', $this->passedArgs['wage']); } // opt if (isset($this->passedArgs['opt'])) { $argsList['opt'] = ceil($this->passedArgs['opt']); } // 親genreのみ指定の場合 /* if ($argsList['genre'][0] <= 6) { $argsList['parent'] = true; switch ($argsList['genre'][0]) { case 1: $argsList['genre'] = explode(':', '7:8:9:10:11:12'); break; case 2: $argsList['genre'] = explode(':', '19:20:21:22:23:24'); break; case 3: $argsList['genre'] = explode(':', '31:32:33:34:35:36'); break; case 4: $argsList['genre'] = explode(':', '41:42:43:44:45:46'); break; case 5: $argsList['genre'] = explode(':', '53:54:55:56:57:58'); // 引数見直し!!! break; default: $argsList['genre'][0] = 7; $argsList['parent'] = false; break; } } */ // GenreとAreaのHABTMテーブルをJOINして、GenreとAreaの条件を指定して検索 // classified_idでDISTINCTして結果出力 if ($argsList['area'][0] == 0) { $idList = $this->ClassifiedsGenre->idlists($argsList['genre']); } else { $idList = $this->AreasClassified->idlists($argsList['area'], $argsList['genre']); } /* if ($argsList['area'][0] == 0) { // area の指定がない場合の検索 $singleTable = $this->ClassifiedsGenre->find('all', array( 'fields' => array( 'DISTINCT ClassifiedsGenre.classified_id' ), 'conditions' => array( 'ClassifiedsGenre.genre_id' => $argsList['genre'] ) )); // classifiedIdの抽出 $idList = Array(); foreach ($singleTable as $tmpData) { $idList[] = $tmpData['ClassifiedsGenre']['classified_id']; } } else { // area がある場合はtable joinして検索 $joinTable = $this->AreasClassified->find('all', array( 'joins' => array( array( 'type' => 'inner', 'table' => 'classifieds_genres', 'alias' => 'ClassifiedsGenre', 'conditions' => array( 'AreasClassified.classified_id = ClassifiedsGenre.classified_id' ) ) ), 'fields' => array( 'DISTINCT AreasClassified.classified_id' ), 'conditions' => array( 'AreasClassified.area_id' => $argsList['area'], 'ClassifiedsGenre.genre_id' => $argsList['genre'] ) )); // 次の検索に渡すためにclassified_idだけのリストにする $idList = Array(); foreach ($joinTable as $tmpData) { $idList[] = $tmpData['AreasClassified']['classified_id']; } }*/ //debug($joinTest); //debug($idList); // HABTMバインドを設定 $this->Classified->bindModel(array('hasAndBelongsToMany' => array('Genre','Area')), false); $this->Classified->bindModel(array('belongsTo' => array('User')), false); /* $results = $this->Classified->find('all', array( 'conditions' => array( //'Classified.option & 2', 'Classified.wage BETWEEN ? AND ?' => array(1000,1100), 'Classified.id' => $idList ) )); */ // paginate検索を実行 // ここでclassified側の検索条件を適用 $this->paginate = array( 'limit' => 10, 'page' => $argsList['page'], 'order' => $dirList[$argsList['dir']] ); // classified検索条件の設定 $classifiedConditions = Array(); if (!empty($argsList['wage'])) { $classifiedConditions['Classified.wage BETWEEN ? AND ?'] = $argsList['wage']; } /* if ($argsList['opt'] != 0) { $classifiedConditions[] = 'Classified.option & ' . $argsList['opt']; } */ $classifiedConditions['Classified.id'] = $idList; $classifiedConditions['Classified.user_class'] = TEACHER; $classifiedConditions['Classified.stat'] = CPUBLIC; //debug($classifiedConditions); //$listClassified = $this->paginate($this->Classified, array( //'Classified.wage BETWEEN ? AND ?' => array(1000,1100), //'Classified.id' => $idList //)); $listClassified = $this->paginate($this->Classified, $classifiedConditions); // connectlist検索用の最終classified_idリストを抽出 $classifiedIds = set::combine($listClassified, '{n}.Classified.id'); $classifiedIds = array_keys($classifiedIds); //debug($classifiedIds); // loginデータがあるとして // $userInfo取得 $this->_user(); //$loginData = Array( //'isLogin' => true, //'id' => '1', //'nickname' => 'sample' //); // connectlistのデータを検索 // idが取得できることが前提 /* if (!empty($this->userInfo['id'])) { $conditions = Array( 'conditions' => array( 'Connectlist.student_id' => $this->userInfo['id'], 'Connectlist.teacher_cid' => $classifiedIds ), 'fields' => array( 'Connectlist.id','Connectlist.teacher_cid','Connectlist.bookmark','Connectlist.stat' ) ); $listResults = $this->Connectlist->find('all', $conditions); // $listResultsをteacher_cidをkeyに組み直し $listConnect = Array(); foreach($listResults as $tmpValue) { $listConnect[$tmpValue['Connectlist']['teacher_cid']] = array( 'id' => $tmpValue['Connectlist']['id'], 'bookmark' => $tmpValue['Connectlist']['bookmark'], 'stat' => $tmpValue['Connectlist']['stat'] ); } } // $listClassifiedにConnectlistからの値を合成 foreach($listClassified as $tmpKey => $tmpValue) { if(isset($listConnect[$tmpValue['Classified']['id']])) { $listClassified[$tmpKey]['Classified']['connect_id'] = $listConnect[$tmpValue['Classified']['id']]['id']; $listClassified[$tmpKey]['Classified']['connect_stat'] = $listConnect[$tmpValue['Classified']['id']]['stat']; $listClassified[$tmpKey]['Classified']['connect_bookmark'] = $listConnect[$tmpValue['Classified']['id']]['bookmark']; } else { $listClassified[$tmpKey]['Classified']['connect_id'] = 0; $listClassified[$tmpKey]['Classified']['connect_stat'] = 0; $listClassified[$tmpKey]['Classified']['connect_bookmark'] =0; } } */ // view用データ作成 $viewData = array(); $viewData['genre'] = $this->Genre->getGenreName($argsList['genre'][0]); if ($argsList['area'][0] != 0) { //$viewData['area'] = $this->Area->find('first', array('conditions' => array('Area.id' => $argsList['area'][0]))); $viewData['area'] = $this->Area->getAreaName($argsList['area'][0]); } //debug($argsList); $this->set('listClassified', $listClassified); $this->set('argsList', $argsList); $this->set('viewData', $viewData); $this->set('areaParentValue', $this->Area->getAreaParentValue()); $this->set('areaValue', $this->Area->getAreaValue()); $this->set('path', $this->Genre->getLinkParam($argsList['genre'][0], $viewData['genre']['parent_genre_id'])); $this->set('userInfo', $this->userInfo); //$voidView = FALSE; //$this->set('voidView', $voidView); }
/** * Compiles current configuration from different sources selected by * current context and overloading/extending each other. * */ protected function import() { /* * prepare coordinates for collecting all interesting sources/files */ // may have separate sources in TXF and application context $patterns = array(TXF_FRAMEWORK_PATH . '/config/%A/%H.xml', TXF_APPLICATION_PATH . '/config/%H.xml'); // may have sources depending on application's name $applications = array('default', TXF_APPLICATION); // may have sources depending on used hostname $hosts = array(); $temp = explode('.', $_SERVER['HTTP_HOST']); while (count($temp)) { $hosts[] = implode('.', $temp); array_shift($temp); } $hosts[] = 'default'; $hosts = array_reverse($hosts); /* * select all files to read configuration from with latter overlaying former */ $files = array(); foreach ($patterns as $pattern) { foreach ($applications as $application) { foreach ($hosts as $host) { $filename = strtr($pattern, array('%A' => $application, '%H' => $host)); if ($files[$filename]) { // always include repeating file in its highest priority unset($files[$filename]); } else { // haven't tested before whether file exists or not // --> check now if (!file_exists($filename)) { continue; } } $files[$filename] = $filename; } } } /* * read selected files each extending/overlaying its predecessors' setup */ $setup = new set(); foreach ($files as $file) { $xml = simplexml_load_file($file); $setup->extendFromXml($xml); } // save read configuration in runtime $this->cached = $setup; }
<option value="cvNum">by cv#</option> <option value="isDate">by Date</option> <option value="byPeriod">by Period from</option> <option value="payee">by Payee</option> <option value="checknum">by Check number</option> <option value="account">by Account</option> <option value="amount">by Amount</option> <option value="dTotal">by Total amount</option> <option value="explanation">by Explanation</option> </select> <input type="text" name="searchQue" id="searchQue" style="font-size: 9pt;" placeholder="Type here"> <span id="byDateP" style="display: none;"> ' . set::mm_dd_yyyy($dNam = "searchQfrday", $dIds = "searchQfrday", $defDay = "", $dayAttr = "", $yNam = "searchQfryear", $yIds = "searchQfryear", $defYear = "", $yerAttr = "", $mNam = "searchQfrmonth", $mIds = "searchQfrmonth", $defMonth = "Month", $monAttr = "") . ' to ' . set::mm_dd_yyyy($dNam = "searchQtoday", $dIds = "searchQtoday", $defDay = "", $dayAttr = "", $yNam = "searchQtoyear", $yIds = "searchQtoyear", $defYear = "", $yerAttr = "", $mNam = "searchQtomonth", $mIds = "searchQtomonth", $defMonth = "Month", $monAttr = "") . ' </span> <span id="byDate" style="display: none;"> ' . set::mm_dd_yyyy($dNam = "day", $dIds = "day", $defDay = "", $dayAttr = "", $yNam = "year", $yIds = "year", $defYear = "", $yerAttr = "", $mNam = "month", $mIds = "month", $defMonth = "Month", $monAttr = "") . ' </span> <input type="submit" name="submit" value="GO!" style="font-size: 9pt;"> </form> <div id="loading"></div> '; ob_end_flush();
public function testPopping() { $set = set::wrap(array(1, true, 2.0, '3.0')); $this->assertEquals(4, $set->count); $this->assertEquals('3.0', $set->pop()); $this->assertEquals(3, $set->count); $this->assertEquals(2.0, $set->pop()); $this->assertEquals(2, $set->count); $this->assertEquals(true, $set->pop()); $this->assertEquals(1, $set->count); $this->assertEquals(1, $set->pop()); $this->assertEquals(0, $set->count); }
<tr> <td align="right"> Client : </td> <td> ' . $pdo_sql->select("clientbase", $select = "clientbase.name", "WHERE client_no='{$client_num}'", "name") . ' (' . $client_num . ') </td> </tr> <tr> <td align="right"> Paid on : </td> <td> ' . set::mm_dd_yyyy($dNam = "day", $dIds = "day", $defDay = $col_day, $dayAttr = "", $yNam = "year", $yIds = "year", $defYear = $col_year, $yerAttr = "", $mNam = "month", $mIds = "month", $defMonth = $col_month, $monAttr = "") . ', <input type="text" name="col_time" id="col_time" value="' . $col_time . '"> </td> </tr> <tr> <td align="right"> Sales rep. : </td> <td> <input type="text" name="salesrep" id="col_salesrep" value="' . $salesrep . '"> </td> </tr> <tr> <td align="right">
<option value="Febuary">Febuary</option> <option value="March">March</option> <option value="April">April</option> <option value="May">May</option> <option value="June">June</option> <option value="July">July</option> <option value="August">August</option> <option value="September">September</option> <option value="October">October</option> <option value="November">November</option> <option value="December">December</option> </select> <input type="text" name="entToday" id="entToday" placeholder="day" style="width: 30px;"> <input type="text" name="entToyear" id="entToyear" placeholder="year" style="width: 30px;"> </span> in branch ' . set::branchLoc($pdo_sql, $default = '<option name="branch" value="">Choose Branch</option>', '') . ' <input type="submit" name="submit" value="GO!"> </div> </form> <div id="loading"></div> '; ob_end_flush();
/** * Opens a new form tag. * * Has variable parameters. May either pass an associative array with the parameters and HTML attributes mixed together * or the paramters may be passed in order, with an additional array parameter containing the HTML attributes. * * @param callable $callback The callback function for handling the form. * @param bool $nocsrf Indicator to use CSRF or not. * @param string $class The HTML class attribute. * @param string $method The HTML method attribute. * @param string $action The HTML action attribute. * @param array $attributes Other HTML attributes for the tag. * * @return string|bool */ public function open($arg) { if (isset($this->openForm)) { log::warning('Unable to open a new form - a form is already open.'); return false; } $args = func_get_args(); if (count($args) == 1 && is_array($arg) && !is_callable(get::form_callback($arg))) { $args = $arg; } if (count($args) > 0) { $n = array('callback' => null, 'nocsrf' => false, 'class' => null, 'method' => null, 'action' => null); $attributes = null; if (is_array(end($args))) { $eargs = array_pop($args); //could be params or only as callback if (is_callable(get::form_callback($eargs))) { $n['callback'] = get::form_callback($eargs); } else { $attributes = $eargs; } } $did = 0; //$dargs = array('callback', 'class', 'method', 'action', 'nocsrf'); while (count($args) > 0) { $a = array_shift($args); if ($did < 2 && (is_string($a) || is_array($a)) && is_callable(get::form_callback($a))) { $n['callback'] = get::form_callback($a); $did++; continue; } if ($did < 2 && is_bool($a)) { $n['nocsrf'] = $a; $did++; continue; } if (is_string($a)) { if ($did < 3) { $n['class'] = $a; $did = 3; continue; } if ($did < 4) { $n['method'] = $a; $did = 4; continue; } if ($did < 5) { $n['action'] = $a; $did = 5; continue; } } } if (is_array($attributes)) { foreach ($attributes as $ak => $av) { $n[$ak] = $av; } } $args = $n; } set::array_default($args, 'method', 'post', array('get', 'post', 'GET', 'POST')); set::array_default($args, 'action', get::url()); set::array_default($args, 'nocsrf', false, array(true, false)); $formid = get::array_default($args, 'id', 'form_' . ++self::$nextFormIndex, array(), true); $callback = get::array_default($args, 'callback'); if (!isset($callback) || !is_callable($callback)) { log::warning('Form callback is missing or invalid. The form callback should be a static member of a class that extends formHandler.'); } $html = ''; $args = array_filter($args, function ($v) { return !is_null($v); }); if (is::existset($args, 'nocsrf') && $args['nocsrf']) { $args['nocsrf'] = 'nocsrf'; if (isset($callback) && is_callable($callback)) { $mnlAction = self::generateAction($callback); $html = sprintf('<form%s><input%s />', get::formattedAttributes($args), get::formattedAttributes(array('type' => 'hidden', 'name' => 'mnl_formaction', 'value' => $mnlAction))); $this->openForm = $callback; } else { $html = sprintf('<form%s>', get::formattedAttributes($args)); $this->openForm = true; } } else { $csrfName = csrfHelper::generateName(); if (!is::existset(munla::$session, 'forms')) { munla::$session['forms'] = array(); } if (!is::existset(munla::$session['forms'], $csrfName)) { munla::$session['forms'][$csrfName] = array(); } munla::$session['forms'][$csrfName][$formid] = array(); $this->openForm =& munla::$session['forms'][$csrfName][$formid]; $this->openForm['formid'] = $formid; $this->openForm['callback'] = $callback; $this->openForm['method'] = $args['method']; $this->openForm['fields'] = array(); $this->openForm['nocsrf'] = $args['nocsrf']; unset($args['nocsrf']); $html = sprintf('<form%s><input%s />', get::formattedAttributes($args), get::formattedAttributes(array('type' => 'hidden', 'name' => 'mnl_formid', 'value' => $csrfName . '-' . $formid))); } formElement::$fieldNameArrays = array(); if (!$this->echoOff) { echo $html; } return $html; }
/** * Creates new set from provided XML document. * * @param string|\SimpleXMLElement $xml xml * @return set set representing data found in XML */ public static function fromXml($xml) { return static::wrap(parent::fromXml($xml)); }
function tableOfContents($zones = null, $options = array()) { $defOpt = array('group' => '<ul>%items%</ul>', 'item' => '<li><a href="%anchor%">%title%</a></li>', 'titleGroup' => '<ul>%groups%</ul>', 'title' => '<li><p>%title%</p>%items%</li>'); $opt = array_merge($defOpt, $options); if (empty($zones)) { $zones = array_keys($this->boxes_by_zone); } if (!is_array($zones)) { $zones = array($zones); } $named = !set::numeric(array_keys($zones)); $out = ''; foreach ($zones as $key => $id) { $links = ''; if (!empty($this->boxes_by_zone[$id])) { foreach ($this->boxes_by_zone[$id] as $box) { if (!empty($box['NewsletterBox']['data']['title'])) { $anchor = '#' . strtolower(Inflector::slug($box['NewsletterBox']['data']['title'])) . '_' . $box['NewsletterBox']['id']; $replace = array('%anchor%' => $anchor, '%title%' => $box['NewsletterBox']['data']['title']); $links .= str_replace(array_keys($replace), array_values($replace), $opt['item']); } } if (!empty($links)) { $links = str_replace('%items%', $links, $opt['group']); } } if (!empty($links) && $named) { $replace = array('%title%' => $key, '%items%' => $links); $out .= str_replace(array_keys($replace), array_values($replace), $opt['title']); } else { $out .= $links; } } if (!empty($out) && $named) { $out = str_replace('%groups%', $out, $opt['titleGroup']); } return $out; }
function alterEmailQuery($opt) { $Model = $this->EmailModel; $modelName = $Model->alias; if (!empty($opt)) { $NewsletterEmail = ClassRegistry::init('Newsletter.NewsletterEmail'); App::import('Lib', 'Newsletter.SetMulti'); $replace = array($NewsletterEmail->alias . '.email' => $this->realField('email'), $NewsletterEmail->alias => $modelName); $opt = SetMulti::replaceTree(array_keys($replace), array_values($replace), $opt); } $conditions = array(); if (!empty($opt['active']) || !isset($opt['active']) && !$this->options['showInnactive']) { if ($opt['mode'] != 'count' && $this->options['checkUnsubscribe']) { $NewsletterEmail = ClassRegistry::init('Newsletter.NewsletterEmail'); $opt['joins'][] = array('alias' => $NewsletterEmail->alias, 'table' => $NewsletterEmail->useTable, 'type' => 'LEFT', 'conditions' => array($this->realField('email') . ' = ' . $NewsletterEmail->alias . '.email')); $conditions[] = array('or' => array($NewsletterEmail->alias . '.active' => 1, $NewsletterEmail->alias . '.id IS NULL')); } if (!empty($this->options['fields']['active']) && $Model->hasField($this->options['fields']['active'])) { $conditions[$this->realField('active')] = 1; } } $conditions['NOT'][$this->realField('email')] = ""; $conditions[] = $this->realField('email') . ' IS NOT NULL'; if (!empty($this->options['conditions'])) { if (!array($this->options['conditions'])) { $this->options['conditions'] = array($this->options['conditions']); } $conditions = set::merge($conditions, $this->options['conditions']); } $opt['conditions'][] = $conditions; if ((empty($opt['mode']) || $opt['mode'] != 'count') && empty($opt['fields'])) { $opt['fields'] = $this->emailFields(); } if (!empty($this->options['findOptions']) && is_array($this->options['findOptions'])) { $opt = set::merge($opt, $this->options['findOptions']); } return $opt; }
function findUniqueIPAddressesWithoutCountry() { $uniqueIPAddresses = $this->find('all', array('fields' => array('DISTINCT Entry.ip_address'), 'conditions' => array('Entry.country' => null))); return set::Extract('*/Entry/ip_address', $uniqueIPAddresses); }
function indistinguishable_state_map($table) { # Assumes that $table is filled according to the table filling # algorithm. $map = array(); $set = new set($this->states); while ($set->count()) { $p = $set->one(); foreach ($set->all() as $q) { if (!$table->differ($p, $q)) { $map[$q] = $p; $set->del($q); } } } return $map; }
function find_first() { $dot = count($this->rhs); $last = $this->first[$dot] = new set(); while ($dot) { $dot--; $symbol_after_the_dot = $this->rhs[$dot]; $first = $symbol_after_the_dot->first->all(); bug_if(empty($first) and !$symbol_after_the_dot->lambda); $set = new set($first); if ($symbol_after_the_dot->lambda) { $set->union($last); if ($this->epsilon == $dot + 1) { $this->epsilon = $dot; } } $last = $this->first[$dot] = $set; } }
function tabledEmailGetFindOptions($tableSendlist, $active = true, $addfindOptions = null) { $tableSendlist = $this->getTableSendlistID($tableSendlist, true); if (!empty($tableSendlist)) { $Model = $tableSendlist['modelClass']; $modelName = $Model->alias; $conditions = array(); if ($active && !is_null($tableSendlist['activeField']) && $Model->hasField($tableSendlist['activeField'])) { $conditions[$modelName . '.' . $tableSendlist['activeField']] = 1; } $conditions['NOT'][$modelName . '.' . $tableSendlist['emailField']] = ""; $conditions[] = $modelName . '.' . $tableSendlist['emailField'] . ' IS NOT NULL'; if (!empty($tableSendlist['conditions'])) { if (!array($tableSendlist['conditions'])) { $tableSendlist['conditions'] = array($tableSendlist['conditions']); } $conditions = set::merge($conditions, $tableSendlist['conditions']); } $findOptions = array('conditions' => $conditions); $findOptions['model'] = $Model; $findOptions['fields'] = $this->tabledEmailGetFindFields($tableSendlist); if (!empty($tableSendlist['findOptions']) && is_array($tableSendlist['findOptions'])) { $findOptions = set::merge($findOptions, $tableSendlist['findOptions']); } if (!empty($addfindOptions)) { $NewsletterEmail = ClassRegistry::init('Newsletter.NewsletterEmail'); App::import('Lib', 'Newsletter.SetMulti'); $replace = array($NewsletterEmail->alias . '.email' => $modelName . '.' . $tableSendlist['emailField'], $NewsletterEmail->alias => $modelName); $addfindOptions = SetMulti::replaceTree(array_keys($replace), array_values($replace), $addfindOptions); $findOptions = set::merge((array) $addfindOptions, $findOptions); } return $findOptions; } return null; }
</div> <form name="" id="disbursement" action="" style="background: none; width: 550px; height: 90%; margin-top: 2em; margin-left: 2em; position: absolute; overflow-x: hidden; overflow-y: scroll;"> <input type="hidden" name="disb_id" value="' . $disbid . '"> <table border="0" style="float: left; text-align: left;"> <tr> <td colspan="5"> <b style="font-size: 20pt;">DISBURSEMENT</b><br/> for the period: ' . $isDate . ' <br>Change to<br/> ' . set::mm_dd_yyyy($dNam = "day", $dIds = "day", $defDay = $isDay, $dayAttr = "", $yNam = "year", $yIds = "year", $defYear = $isYear, $yerAttr = "", $mNam = "month", $mIds = "month", $defMonth = $isMonth, $monAttr = "") . ' </td> </tr> <tr> <td align="right" valign="top">Branch : </td> <td> ' . set::branchLoc($pdo_sql, '<option name="brancnAvailable" value="' . $branch . '">' . $branch . '</option>', '') . ' </td> </tr> <tr> <td align="right" valign="top">cv # : </td> <td> <input type="text" name="cvNum" id="cvNum" value="' . $cvNum . '"> </tr> <tr> <td align="right" valign="top">PAYEE : </td> <td> <input type="text" name="payee" id="payee" value="' . $payee . '"> </tr> <tr> <td align="right" valign="top">CHECK # : </td> <td> <input type="text" name="checknum" id="checknum" value="' . $checknum . '"> </tr> <tr> <td align="left" valign="top">ACCOUNT </td>
/** * Replaces occurrences of substring. * * This method tries to imitate behaviour of str_replace(). Though the * latter is already safe for utf-8, managed strings may use different * encodings as well. * As another convenience option $pattern may contain hash while * $replacement is null so mapping in hash is used * * @param string|array $pattern single (or set of) substring(s) to replace * @param string|array $replacement single (or set of) substring(s) * replacing related substring(s) in $pattern * @return \de\toxa\txf\string string with replacements applied */ public function replace($pattern, $replacement = null) { // using str_replace requires to use all strings encoded in UTF-8 if (is_array($pattern) && (is_array($replacement) || is_null($replacement))) { // normalize either array if (is_null($replacement)) { $usingHash = set::isHash($pattern); $replacement = static::wrapArray($usingHash ? array_values($pattern) : array()); $pattern = static::wrapArray($usingHash ? array_keys($pattern) : $pattern); } else { $replacement = static::wrapArray($replacement); $pattern = static::wrapArray($pattern); } // convert elements in either array to UTF-8 encoding foreach ($pattern as $key => $value) { $pattern[$key] = $value->asUtf8; } foreach ($replacement as $key => $value) { $replacement[$key] = $value->asUtf8; } // ensure both arrays containing same number of elements if (count($replacement) > count($pattern)) { $replacement = array_slice($replacement, 0, count($pattern)); } else { $replacement = array_pad($replacement, count($pattern), ''); } } else { if (static::isString($pattern) && (static::isString($replacement) || is_null($replacement))) { $pattern = static::wrap($pattern)->asUtf8; $replacement = static::wrap($replacement)->asUtf8; } else { throw new \InvalidArgumentException('provide two strings or 2 arrays'); } } // convert subject of replacement to UTF-8 as well $subject = $this->asUtf8; // perform str_replace $result = str_replace($pattern, $replacement, $subject); // finally convert result back from UTF-8 encoding to current one return static::wrap($result, 'utf-8')->convertTo($this->encoding); }
function admin_edit($id = null) { if (!$id && empty($this->data)) { $this->Session->setFlash(sprintf(__('Invalid %s', true), 'shop promotion')); $this->redirect(array('action' => 'index')); } $this->ShopPromotion->recursive = -1; $promotion = $this->ShopPromotion->read(null, $id); $aros = $this->ShopPromotion->productAros(); if (!empty($aros)) { $promotion[$this->ShopPromotion->alias]['aroProduct'] = set::extract('{n}.Aro.id', $aros); } if (!empty($this->data)) { if ($this->ShopPromotion->save($this->data)) { if (!empty($this->data['ShopPromotion']['aroProduct'])) { //debug($this->ShopProduct->Aro->Permission->alias); //// unset old $aros //// foreach ($aros as $aro) { if (!empty($aro[$this->ShopProduct->Aro->alias]['alias'])) { $aro = $aro[$this->ShopProduct->Aro->alias]['alias']; } else { $aro = $aro[$this->ShopProduct->Aro->alias]; } $this->Acl->inherit($aro, $this->ShopPromotion); } //// set new $aros //// $aros = $this->ShopProduct->Aro->find('all', array('conditions' => array('id' => $this->data['ShopPromotion']['aroProduct']))); foreach ($aros as $aro) { if (!empty($aro[$this->ShopProduct->Aro->alias]['alias'])) { $aro = $aro[$this->ShopProduct->Aro->alias]['alias']; } else { $aro = $aro[$this->ShopProduct->Aro->alias]; } $this->Acl->allow($aro, $this->ShopPromotion); } } $this->Session->setFlash(sprintf(__('The %s has been saved', true), 'shop promotion')); $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash(sprintf(__('The %s could not be saved. Please, try again.', true), 'shop promotion')); } } if (empty($this->data)) { $this->data = $promotion; //debug($this->data); } $this->ShopPromotion->ShopCoupon->recursive = -1; $coupons['all'] = $this->ShopPromotion->ShopCoupon->find('count', array('conditions' => array('shop_promotion_id' => $promotion['ShopPromotion']['id']))); $coupons['used'] = $coupons['all'] - $this->ShopPromotion->ShopCoupon->find('count', array('conditions' => array('shop_promotion_id' => $promotion['ShopPromotion']['id'], 'or' => array('ShopCoupon.status not' => 'used', 'ShopCoupon.status' => null)))); $coupons['reserved'] = $coupons['all'] - $this->ShopPromotion->ShopCoupon->find('count', array('conditions' => array('shop_promotion_id' => $promotion['ShopPromotion']['id'], 'or' => array('ShopCoupon.status not' => array('used', 'reserved'), 'ShopCoupon.status' => null)))); $this->set('coupons', $coupons); $products = $this->ShopProduct->generateAroList(); $this->set('products', $products); $this->set($this->_promoMethodList()); $actions = $this->ShopPromotion->ShopAction->find('list', array('conditions' => array('status' => 'checkPromo'))); $this->set('actions', $actions); $this->set('promotion', $promotion); }
<tr> <td align="right" valign="top">PAYEE : </td> <td> <input type="text" name="payee" id="payee"> </td> </tr> <tr> <td align="right" valign="top">CHECK # : </td> <td> <input type="text" name="checknum" id="checknum"> </td> </tr> <tr> <td align="right" valign="top">ACCOUNT </td> <td align="left" valign="top">AMOUNT</td> </tr> <tr id="account_amount" > <td align="right" valign="top"> ' . set::accounTitle($pdo_sql, $default = '<option value="">Account title</option>', $inputName = "account[]", $id = "debitAccount") . ' : </td> <td align="left" valign="top"> <input type="text" name="amount[]" id="amount" value="0.00"> </td> </tr> <tr> <td align="right"> </td> <td align="center"> <span id="add_acc_amo" style="cursor: pointer;"> add </span> </td> </tr> <tr> <td align="right" valign="top">TOTAL : </td> <td align="left" valign="top"><input type="text" name="totalAmount" id="totalAmount"></td> </tr>
<!-- to date --> <td align="right" valign="top"> From : </td> <td align="left" valign="top"> ' . set::mm_dd_yyyy($dNam = "frmserviceDay", $dIds = "serviceDay", $defDay = "", $dayAttr = "", $yNam = "frmserviceYear", $yIds = "serviceYear", $defYear = "", $yerAttr = "", $mNam = "frmserviceMonth", $mIds = "service", $defMonth = "Month", $monAttr = "") . ' </td> <td align="right" valign="top"> Job # : </td> <td align="left" valign="top"> <input type="text" name="jobNumber" id="jobNumber" style="font-size: 9pt;" > </td> </tr> <tr> <td align="right" valign="top"> To : </td> <td align="left" valign="top"> ' . set::mm_dd_yyyy($dNam = "toserviceDay", $dIds = "serviceDay", $defDay = "", $dayAttr = "", $yNam = "toserviceYear", $yIds = "serviceYear", $defYear = "", $yerAttr = "", $mNam = "toserviceMonth", $mIds = "service", $defMonth = "Month", $monAttr = "") . ' </td> <td align="right" valign="top"> Job # series : </td> <td align="left" valign="top"> <input type="text" name="jobNumberFr" id="jobNumberFr" style="font-size: 9pt; width: 5em;" > - <input type="text" name="jobNumberTo" id="jobNumberTo" style="font-size: 9pt; width: 5em;" > </td> </tr> <tr> <td colspan="5"> <input type="submit" name="submit" value="GO!" class="button" style="margin-top: -0.03em; margin-left: 1.6em; position: absolute; z-index: 60;"> </td> </tr> </table>
<?php /* * file: root/05_disbusrement/JavaScripts/modRecord.php * purpose: js for validating data to be edited and for the on the spot data editing possible * last modified: November 17, 2012 * */ //________________________________________________________________________________________________ ob_start(); // include the system configurations here include '../../sysConfig.php'; // include the system interface module here include '../../systemInt.php'; $acc_amo = '<tr id="account_amount"><td align="right" valign="top"> ' . set::accounTitle($pdo_sql, $default = '<option value="">Account title</option>', $inputName = "account[]", $id = "debitAccount") . ' : </td><td align="left" valign="top"><input type="text" name="amount[]" id="amount" value="0.00"></td></tr>'; echo ' var $j = jQuery.noConflict(); $j(document).ready(function(){ $j("#add_acc_amo").live("click",function(){ $j("#account_amount").before(\'' . $acc_amo . '\').removeAttr("id"); $j("#account_amount input#lessName").focus(); }); $j("form#disburtment input, select").live("focusout", function(){ /* reg exp variable for floating point data typed input tags */ var intRegex = /^\\d+(?:\\.\\d{0,5})?$/; var inputVals = $j(this).val(); var inputIDs = $j(this).attr("id");