PageRenderTime 36ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/billing_tz/gui_billing_tz_quotation_create (another copy).php

https://bitbucket.org/vincentbii/amurt
PHP | 239 lines | 218 code | 16 blank | 5 comment | 15 complexity | c809071dad6f027302b2c688fedfdfd3 MD5 | raw file
Possible License(s): GPL-2.0, Apache-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, MIT, BSD-3-Clause, LGPL-2.0, GPL-3.0
  1. <?php $billing_tz->Display_Header($LDNewQuotation,$enc_obj->ShowPID($batch_nr),''); ?>
  2. <BODY bgcolor="#ffffff" link="#000066" alink="#cc0000" vlink="#000066" onload="setBallon('BallonTip','','')" >
  3. <script language="javascript">
  4. function toggle_tr(myelem,show,id) {
  5. if(show){
  6. document.getElementById(myelem).style.display = '';
  7. if(show)
  8. calc_article(id,show);
  9. }else{
  10. document.getElementById(myelem).style.display = 'none';
  11. }
  12. }
  13. </script>
  14. <script language="javascript">
  15. function calc_article(id,show)
  16. {
  17. if(document.forms[0].elements['modepres_' + id])
  18. {
  19. if(isNaN(document.forms[0].elements['showprice_' + id].value) || isNaN(document.forms[0].elements['dosage_' + id].value) || isNaN(document.forms[0].elements['insurance_' + id].value))
  20. {
  21. document.getElementById('div_' + id).innerHTML='n/a';
  22. }
  23. else
  24. {
  25. <?php
  26. $result = $bill_obj->GetNewQuotation_Prescriptions($_REQUEST['encounter_nr'],'');
  27. echo 'for(var i=0;i<=3;i++){ ';
  28. while($row=$result->FetchRow())
  29. {
  30. echo "if(id==".$row['nr'].") { ";
  31. // echo " if (show) {";
  32. echo "if(document.forms[0].elements['insurance_' + id]) {";
  33. echo "sum = document.forms[0].elements['showprice_' + id].value * document.forms[0].elements['dosage_' + id].value * document.forms[0].elements['times_per_day_' + id].value * document.forms[0].elements['days_' + id].value; \n";
  34. echo "sum_total = sum - document.forms[0].elements['insurance_' + id].value; \n";
  35. echo "document.getElementById('div_' + id).innerHTML='<table width=\"100%\" border=\"0\"><tr><td>' + document.forms[0].elements['unit_price_' + id].value + ' x ' + document.forms[0].elements['dosage_' + id].value + ' x ' + document.forms[0].elements['times_per_day_' + id].value + ' x ' + document.forms[0].elements['days_' + id].value + ' = </td><td align=\"right\">' + sum + ' TSH</td></tr><tr><td>Insurance:</td><td align=\"right\">- ' + document.forms[0].elements['insurance_' + id].value + ' TSH</td></tr><tr><td><b>Sum:</b></td><td align=\"right\"><b>' + sum_total + ' TSH</b></td></tr></table><input type=\"hidden\" name=\"pressum_' + id + '\" value=\"'+ sum_total + '\">'; \n";
  36. echo ' } else {';
  37. echo "sum = document.forms[0].unit_price_".$row['nr'].".value * document.forms[0].elements['dosage_' + id].value * document.forms[0].elements['times_per_day_' + id].value * document.forms[0].elements['days_' + id].value; \n";
  38. echo "sum_total = sum; \n";
  39. echo "document.getElementById('div_' + id).innerHTML='<table width=\"100%\" border=\"0\"><tr><td>' + document.forms[0].elements['unit_price_' + id].value + ' x ' + document.forms[0].elements['dosage_' + id].value + ' x ' + document.forms[0].elements['times_per_day_' + id].value + ' x ' + document.forms[0].elements['days_' + id].value + ' = </td><td align=\"right\">' + sum + ' TSH</td></tr><tr><td><b>Sum:</b></td><td align=\"right\"><b>' + sum_total + ' TSH</b></td></tr></table><input type=\"hidden\" name=\"pressum_' + id + '\" value=\"'+ sum_total + '\">'; \n";
  40. // echo "}";
  41. echo "}";
  42. echo "}";
  43. }
  44. echo "} ";
  45. ?>
  46. }
  47. }
  48. else
  49. {
  50. if(isNaN(document.forms[0].elements['showprice_' + id].value) || isNaN(document.forms[0].elements['dosage_' + id].value) || isNaN(document.forms[0].elements['insurance_' + id].value))
  51. {
  52. document.getElementById('div_' + id).innerHTML='n/a';
  53. }
  54. else
  55. {
  56. <?php
  57. $result = $bill_obj->GetNewQuotation_Laboratory($_REQUEST['encounter_nr'],'');
  58. echo 'for(var i=0;i<=3;i++){ ';
  59. while($row=$result->FetchRow())
  60. {
  61. echo "if(id==".$row['sub_id'].") { ";
  62. // echo " if (show){ ";
  63. echo "if(document.forms[0].elements['insurance_' + id]) {";
  64. echo "sum = document.forms[0].elements['showprice_' + id].value * document.forms[0].elements['dosage_' + id].value; \n";
  65. echo "sum_total = sum - document.forms[0].elements['insurance_' + id].value; \n";
  66. echo "document.getElementById('div_' + id).innerHTML='<table width=\"100%\" border=\"0\"><tr><td>' + document.forms[0].elements['unit_price_' + id].value + ' x ' + document.forms[0].elements['dosage_' + id].value + ' = </td><td align=\"right\">' + sum + ' TSH</td></tr><tr><td>Insurance:</td><td align=\"right\">- ' + document.forms[0].elements['insurance_' + id].value + ' TSH</td></tr><tr><td><b>Sum:</b></td><td align=\"right\"><b>' + sum_total + ' TSH</b></td></tr></table><input type=\"hidden\" name=\"pressum_' + id + '\" value=\"'+ sum_total + '\">'; \n";
  67. echo ' } else {';
  68. echo "sum=document.forms[0].elements['unit_price_' + id].value * document.forms[0].elements['dosage_' + id].value; \n";
  69. echo "sum_total = sum; \n";
  70. echo "document.getElementById('div_' + id).innerHTML='<table width=\"100%\" border=\"0\"><tr><td>' + document.forms[0].elements['unit_price_' +id].value + ' TSH </td><td align=\"right\"></td><input type=\"hidden\" name=\"pressum_' + id + '\" value=\"'+ sum_total + '\">'; \n";
  71. // echo "}";
  72. echo "}";
  73. echo "}";
  74. }
  75. echo "} ";
  76. ?>
  77. }
  78. }
  79. }
  80. </script>
  81. <?php $encoded_batch_number=$enc_obj->ShowPID($pid); ?>
  82. <?php $billing_tz->Display_Headline($LDCreateQuotationfor, '', '('.$encoded_batch_number.')','billing_create2.php','Billing :: Create Quotation'); ?>
  83. <table width="100%" border="0" cellspacing="0" height="100%">
  84. <tr valign=top>
  85. <td colspan="2">
  86. <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="5" >
  87. <tr>
  88. <td><form method="POST" action="">
  89. <input type="hidden" value="<?php echo $_REQUEST['patient']; ?>" name="patient">
  90. <table width="700" border="0" align="center" bgcolor="#FFFF88" class="table_content">
  91. <tr>
  92. <td><font class="submenu_item"><?php echo $LDCurrentQuotation; ?></font></td>
  93. <td align="right"><?php echo $namelast.', '.$namefirst.' (PID: '.$encoded_batch_number.')'; ?></td>
  94. </tr>
  95. </table><br><br>
  96. <?php if($countlab>0)
  97. {
  98. ?>
  99. <input type="hidden" value="insert" name="task">
  100. <input type="hidden" value="<?php echo $encounter_nr; ?>" name="encounter_nr">
  101. <input type="hidden" value="<?php echo $createmode; ?>" name="createmode">
  102. <input type="hidden" value="<?php echo $pid; ?>" name="pid">
  103. <?php
  104. }
  105. if($countpres>0)
  106. {
  107. ?><br>
  108. <table width="600" border="0" align="center" class="table_content">
  109. <?php
  110. $bill_obj->ShowNewQuotationEncounter_Prescriptions($encounter_nr,$id_array, $IS_PATIENT_INSURED);
  111. //additional: show Laboratory-Items
  112. $bill_obj->ShowNewQuotationEncounter_Laboratory($encounter_nr, &$id_array, $IS_PATIENT_INSURED);
  113. ?>
  114. <tr>
  115. <td bgcolor="#ffffdd" width="80" colspan="4">
  116. <input type="hidden" value="<?php echo $_REQUEST['patient']; ?>" name="patient">
  117. <input type="hidden" value="insert" name="task">
  118. <input type="hidden" value="<?php echo $encounter_nr; ?>" name="encounter_nr">
  119. <input type="hidden" value="<?php echo $pid; ?>" name="pid">
  120. </td>
  121. <td bgcolor="#ffffdd" colspan="4" align="right"></td>
  122. </tr>
  123. </table>
  124. <?php
  125. }
  126. ?>
  127. <script language="javascript">
  128. var objectarray = new Array();
  129. function sum_all()
  130. {
  131. var totalsum=0;
  132. var insurancebalance=0;
  133. <?php
  134. $arraycount=0;
  135. while(list($x,$v) = each($id_array))
  136. {
  137. $objectarray[$arraycount++] = substr(strstr($x,'_'),1);
  138. echo 'if(document.forms[0].elements[\''.$x.'\']) if(!isNaN(document.forms[0].elements[\''.$x.'\'].value)) { if(document.forms[0].elements[\'modepres_'.substr(strstr($x,'_'),1).'\']) { if(document.forms[0].elements[\'modepres_'.substr(strstr($x,'_'),1).'\'][0].checked) { totalsum = totalsum + parseInt(document.forms[0].elements[\''.$x.'\'].value); if(document.forms[0].elements[\'insurance_'.substr(strstr($x,'_'),1).'\']) { if(parseInt(document.forms[0].elements[\'insurance_'.substr(strstr($x,'_'),1).'\'].value) <= (parseInt(document.forms[0].elements[\'showprice_'.substr(strstr($x,'_'),1).'\'].value) * parseInt(document.forms[0].elements[\'dosage_'.substr(strstr($x,'_'),1).'\'].value))) { insurancebalance=insurancebalance + parseInt(document.forms[0].elements[\'insurance_'.substr(strstr($x,'_'),1).'\'].value); }else {
  139. insurancebalance=insurancebalance + (parseInt(document.forms[0].elements[\'showprice_'.substr(strstr($x,'_'),1).'\'].value) * parseInt(document.forms[0].elements[\'dosage_'.substr(strstr($x,'_'),1).'\'].value)); } } } } else { if(document.forms[0].elements[\'modelab_'.substr(strstr($x,'_'),1).'\']) { if(document.forms[0].elements[\'modelab_'.substr(strstr($x,'_'),1).'\'][0].checked) { totalsum = totalsum + parseInt(document.forms[0].elements[\''.$x.'\'].value); if(document.forms[0].elements[\'insurance_'.substr(strstr($x,'_'),1).'\']) { if(parseInt(document.forms[0].elements[\'insurance_'.substr(strstr($x,'_'),1).'\'].value) <=parseInt(document.forms[0].elements[\'showprice_'.substr(strstr($x,'_'),1).'\'].value)) insurancebalance=insurancebalance + parseInt(document.forms[0].elements[\'insurance_'.substr(strstr($x,'_'),1).'\'].value); else insurancebalance=insurancebalance + (parseInt(document.forms[0].elements[\'showprice_'.substr(strstr($x,'_'),1).'\'].value) * parseInt(document.forms[0].elements[\'dosage_'.substr(strstr($x,'_'),1).'\'].value)); } } } } } ';
  140. $y = $x;
  141. }
  142. $x = $y;
  143. echo 'if(document.getElementById(\'modepres_'.substr(strstr($x,'_'),1).'\')) alert(document.getElementById(\'modepres_'.substr(strstr($x,'_'),1).'\').value); if(document.getElementById(\'modelab_'.substr(strstr($x,'_'),1).'\')) alert(document.getElementById(\'modelab_'.substr(strstr($x,'_'),1).'\').value);';
  144. echo 'balance='.$insurancebudget.'-insurancebalance;';
  145. echo 'if(balance<0) balance = \'<font color="#FF0000">\' + balance + \'</font>\';';
  146. echo 'document.getElementById(\'totalsum\').innerHTML=\' '.$LDTotalSum.' <b>\' + totalsum + \' TSH</b>';
  147. echo '<br>Your insurance balance is: <b>'.$insurancebudget.' - \' + insurancebalance + \' = \' + balance + \' TSH</b>\';';
  148. ?>
  149. }
  150. function TriggerAllItems(trigger)
  151. {
  152. var showtr;
  153. if(trigger==0) {
  154. showtr = true;
  155. } else {
  156. showtr = false;
  157. } // end of if(trigger==0)
  158. <?php
  159. $this_arraycount=0;
  160. while(list($x,$v) = each($objectarray))
  161. {
  162. $objectarray[$this_arraycount++] = $v;
  163. echo 'if(document.forms[0].elements[\'modepres_'.$v.'\']) { document.forms[0].elements[\'modepres_'.$v.'\'][trigger].checked = true; toggle_tr(\'tr_'.$v.'\',showtr,\''.$v.'\'); } if(document.forms[0].elements[\'modelab_'.$v.'\']){ document.forms[0].elements[\'modelab_'.$v.'\'][trigger].checked = true; toggle_tr(\'tr_'.$v.'\',showtr,\''.$v.'\'); }';
  164. $y = $v;
  165. } // end of while(list($x,$v) = each($objectarray))
  166. $v = $y;
  167. ?>
  168. } // end of function TriggerAllItems(trigger)
  169. </script>
  170. <table width="600" border="0" align="center">
  171. <tr>
  172. <td>
  173. <?php echo $LDMarkallitems; ?>
  174. </td>
  175. <td align="right">
  176. <input type="button" value="<?php echo $LDSelect; ?>" onClick="javascript:TriggerAllItems(0);">
  177. <input type="button" value="<?php echo $LDTodo; ?>" onClick="javascript:TriggerAllItems(1);">
  178. <input type="button" value="<?php echo $LDDelete; ?>" onClick="javascript:TriggerAllItems(2);">
  179. </td>
  180. </tr>
  181. <tr>
  182. <td>
  183. <input type="button" value="<?php echo $LDCalculateTotalSum; ?>" onClick="javascript:sum_all();">
  184. </td>
  185. <td>
  186. <div id="totalsum" width="400">
  187. <?php echo $LDTotalSumnotcalculated; ?>
  188. <?php
  189. if($insurance_obj->is_patient_insured($pid)) {
  190. echo '<br>'. $namelast.', '.$namefirst.' is insured by: '.$insurance_obj->GetName_insurance_from_pid($pid);
  191. echo '<br>'.$LDRemainingInsurancebudget .'<b>'.$insurancebudget.' TSH</b>';
  192. } else
  193. echo '<br>'.$LDThereisnovalidinsurance;
  194. ?></div>
  195. </td>
  196. </tr>
  197. <tr>
  198. <td>&nbsp;
  199. </td>
  200. <td>
  201. <?php if(!$insurancebudget) echo 'Assign here to a insurance:'?>
  202. <?php echo $insurance_obj->ShowAllInsurancesForQuotatuion(); ?>
  203. </td>
  204. </tr>
  205. <tr>
  206. <td>
  207. <input type="reset" value="<?php echo $LDResetFields; ?>">
  208. </td>
  209. <td align="right">
  210. <input type="submit" value="<?php echo $LDFinished; ?>">
  211. </td>
  212. </tr>
  213. </table>
  214. </td>
  215. </form>
  216. </tr>
  217. </table>
  218. </td>
  219. </tr>
  220. </table>
  221. <?php $encoded_batch_number=$enc_obj->ShowPID($pid); ?>
  222. <?php $billing_tz->Display_Footer($LDCreateQuotationfor, '', '('.$encoded_batch_number.')','billing_create2.php','Billing :: Create Quotation'); ?>
  223. <?php $billing_tz->Display_Credits(); ?>