PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/class/eBPLS.SignTemp.class.php

http://ebpls.googlecode.com/
PHP | 288 lines | 133 code | 110 blank | 45 comment | 31 complexity | bac5b67ceb704de91943c4d04f0e5390 MD5 | raw file
  1. <?
  2. /************************************************************************************
  3. Module : eBPLS.SignTemp.class.php
  4. Dependencies :
  5. eBPLS.dbfuncs.php
  6. eBPLS.dataencapsulator.class.php
  7. Description :
  8. - encapsulates Province
  9. Created By : Robert M. Verzosa
  10. Email : rmv71279@yahoo.com, verzosar@dap.edu.ph
  11. Date Created : 12/12/2005
  12. ************************************************************************************/
  13. require_once("class/eBPLS.dataencapsulator.class.php");
  14. require_once("lib/eBPLS.dbfuncs.php");
  15. // keys for getData method
  16. define(EBPLS_REPORT_SIGN_TABLE,"report_signatories");
  17. // Industry Sector Data Elements Constants
  18. define(RS_ID,"rs_id");
  19. define(REPORT_FILE,"report_file");
  20. define(SIGN_ID,"sign_id");
  21. define(DATE_UPDATED,"date_updated");
  22. define(UPDATED_BY,"updated_by");
  23. define(SIGN_TYPE,"sign_type");
  24. class EBPLSSignTemp extends DataEncapsulator {
  25. var $m_dbLink,
  26. $rcount,
  27. $out;
  28. function EBPLSSignTemp( $dbLink, $bDebug = false ) {
  29. $this->m_dbLink = $dbLink;
  30. $this->setDebugMode( $bDebug );
  31. // add data elements of class with their respective validation functions an params, used default value for 4th parameter
  32. // for error message pair in case validation failed
  33. $this->addDataElement( RS_ID, "is_not_empty", "[VALUES]");
  34. $this->addDataElement( REPORT_FILE, "is_not_empty", "[VALUES]");
  35. $this->addDataElement( SIGN_ID, "is_not_empty", "[VALUES]");
  36. $this->addDataElement( DATE_UPDATED, "is_not_empty", "[VALUES]");
  37. $this->addDataElement( UPDATED_BY, "is_not_empty", "[VALUES]");
  38. $this->addDataElement( SIGN_TYPE, "is_not_empty", "[VALUES]");
  39. }
  40. /**
  41. * Adds new Industry Sector to ebls_INDUSTRY_SECTOR table
  42. *
  43. */
  44. function add(){
  45. if ( $this->m_dbLink ) {
  46. if ( ( $error_num = $this->validateData() ) > 0 ) {
  47. $strValues = $this->data_elems;
  48. $ret = ebpls_insert_data( $this->m_dbLink, EBPLS_REPORT_SIGN_TABLE, $strValues );
  49. if ( $ret < 0 ) {
  50. //$this->debug( "CREATE OCCUPNACY TYPE FAILED" );
  51. //$this->setError( $ret, get_db_error() );
  52. return $ret;
  53. } else {
  54. //$this->debug( "CREATE OCCUPNACY TYPE SUCCESSFULL" );
  55. $this->data_elems[ RS_ID ] = $ret;
  56. return $ret;
  57. }
  58. } else {
  59. //$this->debug( "CREATE INDUSTRY FAILED" );
  60. return $error_num;
  61. }
  62. } else {
  63. //$this->debug( "CREATE OWNER FAILED INVALID DB LINK $this->m_dbLink" );
  64. $this->setError( $ret, "Invalid Db link $this->m_dbLink" );
  65. return -1;
  66. }
  67. }
  68. /**
  69. * View owner data, loads data using owner id as param
  70. *
  71. */
  72. function view( $rs_id ) {
  73. $strValues[$key] = "*";
  74. $strWhere[RS_ID] = $rs_id;
  75. $result = ebpls_select_data( $this->m_dbLink, EBPLS_REPORT_SIGN_TABLE, $strValues, $strWhere, NULL, $strOrderBy, "DESC", NULL );
  76. if ( is_array($result) ) {
  77. $this->data_elems = $result[0];
  78. return $result[0][RS_ID];
  79. } else {
  80. $this->setError( $result, get_db_error() );
  81. return -1;
  82. }
  83. }
  84. /**
  85. * Update owner data
  86. *
  87. *
  88. **/
  89. function update( $rs_id ) {
  90. $arrData = $this->getData();
  91. foreach( $arrData as $key=>$value){
  92. if ( $arrData[$key] != NULL ) {
  93. $strValues[$key] = $value;
  94. }
  95. }
  96. if ( ( $error_num = $this->validateData(true) ) > 0 ) {
  97. $strWhere[RS_ID] = $rs_id;
  98. $ret = ebpls_update_data( $this->m_dbLink, EBPLS_REPORT_SIGN_TABLE, $strValues, $strWhere );
  99. if ( $ret < 0 ) {
  100. return $ret;
  101. } else {
  102. return $ret;
  103. }
  104. } else {
  105. return -1;
  106. }
  107. }
  108. function delete( $rs_id ) {
  109. $strWhere[RS_ID] = $rs_id;
  110. $strValues[] = "count(*) as cnt";
  111. // check if owner have existing transactions
  112. $result = ebpls_delete_data ( $this->m_dbLink, EBPLS_REPORT_SIGN_TABLE, $strWhere );
  113. if ( $result < 0 ) {
  114. $this->setError( $result, get_db_error() );
  115. }
  116. return $result;
  117. }
  118. function search( $rs_id = NULL, $report_file = NULL ) {
  119. if ( $rs_id != NULL and $report_file == NULL ) {
  120. $strWhere[RS_ID] = $rs_id;
  121. }
  122. if ( $rs_id == NULL and $report_file != NULL ) {
  123. $strWhere[REPORT_FILE] = $report_file;
  124. }
  125. if ( $rs_id != NULL and $report_file != NULL ) {
  126. $strWhere[REPORT_FILE] = $report_file;
  127. $strWhere[SIGN_ID] = $rs_id;
  128. }
  129. // select all columns
  130. $strValues[] = "*";
  131. if ( $orderkey != NULL ) {
  132. $strOrder[$orderkey] = $orderkey;
  133. } else {
  134. $strOrder = $orderkey;
  135. }
  136. if ( count($strWhere) <= 0 ) {
  137. $this->setError ( -1, "No search parameters." );
  138. return -1;
  139. }
  140. $result = ebpls_select_data( $this->m_dbLink, EBPLS_REPORT_SIGN_TABLE, $strValues, $strWhere, NULL, NULL, NULL, NULL);
  141. $fetchrecord = ebpls_fetch_data( $this->m_dbLink, $result) ;
  142. $this->out = $fetchrecord;
  143. }
  144. function searchcomp($report_file = NULL, $sign_id = NULL, $type = NULL) {
  145. $ifexist = @mysql_query("select * from report_signatories where report_file = '$report_file' and sign_id = '$sign_id' and sign_type = '$type'");
  146. $fetchrecord = @mysql_num_rows($ifexist) ;
  147. $this->rcount = $fetchrecord;
  148. }
  149. function searchcomp1($bbo, $report_file = NULL, $sign_id = NULL, $type = NULL) {
  150. $ifexist = @mysql_query("select * from report_signatories where report_file = '$report_file' and sign_id = '$sign_id' and sign_type = '$type' and rs_id <> '$bbo'");
  151. $fetchrecord = @mysql_num_rows($ifexist) ;
  152. $this->rcount = $fetchrecord;
  153. }
  154. function pagesearch($page = 1, $maxrec = 1000000000, $orderkey = RS_ID, $is_desc = true ) {
  155. // select all columns
  156. $strValues1[] = "*";
  157. $strValues2[] = "count(*)";
  158. if ( $orderkey != NULL ) {
  159. $strOrder[$orderkey] = $orderkey;
  160. } else {
  161. $strOrder = $orderkey;
  162. }
  163. //echo $is_desc."Robert";
  164. $result = ebpls_select_data( $this->m_dbLink, EBPLS_REPORT_SIGN_TABLE, $strValues1, $strWhere, NULL, $strOrder, $is_desc, $maxrec, $page );
  165. $rowcount = ebpls_select_data( $this->m_dbLink, EBPLS_REPORT_SIGN_TABLE, $strValues2, $strWhere, NULL, $strOrder, $is_desc, NULL, NULL );
  166. //$sqlCount = $rowcount["count_sql"];
  167. $this->out = $result;
  168. $this->rcount = $rowcount;
  169. //echo $rowcount."VooDoo";
  170. }
  171. }
  172. ?>