コード例 #1
0
 /**
  * Prints out a representation of the line item tree
  * @param EE_Line_Item $line_item
  * @param int $indentation
  * @return void
  */
 public static function visualize(EE_Line_Item $line_item, $indentation = 0)
 {
     echo "\n<br />";
     for ($i = 0; $i < $indentation; $i++) {
         echo " - ";
     }
     if ($line_item->is_percent()) {
         $breakdown = $line_item->percent() . '%';
     } else {
         $breakdown = '$' . $line_item->unit_price() . "x" . $line_item->quantity();
     }
     echo $line_item->name() . "( " . $line_item->ID() . " ) : " . $line_item->type() . " \$" . $line_item->total() . "(" . $breakdown . ")";
     if ($line_item->is_taxable()) {
         echo "  * taxable";
     }
     if ($line_item->children()) {
         foreach ($line_item->children() as $child) {
             self::visualize($child, $indentation + 1);
         }
     }
 }
 /**
  *    _process_billable_total
  *
  * @param EE_Line_Item $line_item
  * @return mixed
  */
 private function _is_billable(EE_Line_Item $line_item)
 {
     $billable = 0;
     // is this a ticket ?
     if ($line_item->OBJ_type() == 'Ticket') {
         //echo '<br/><h5 style="color:#2EA2CC;">$line_item->name() : <span style="color:#E76700">' . $line_item->name() . '</span><br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span>    <b style="font-size:10px;color:#333">  ' . __LINE__ . ' </b></h5>';
         //echo '<h5 style="color:#2EA2CC;">$line_item->OBJ_ID() : <span style="color:#E76700">' . $line_item->OBJ_ID() . '</span><br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span>    <b style="font-size:10px;color:#333">  ' . __LINE__ . ' </b></h5>';
         // is it in the "do not bill" list?
         foreach ($this->_billable as $REG_ID => $TKT_ID) {
             if ($line_item->OBJ_ID() === $TKT_ID) {
                 //echo '<h5 style="color:#2EA2CC;">billable : <span style="color:#E76700">' . $line_item->unit_price() . '</span><br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span>    <b style="font-size:10px;color:#333">  ' . __LINE__ . ' </b></h5>';
                 $this->_billable_total += $line_item->unit_price();
                 //$this->_total_items += $line_item->quantity();
                 if ($line_item->is_taxable()) {
                     $this->_billable_tax_total += $line_item->unit_price();
                 }
                 $this->_total_items++;
                 $billable++;
                 unset($this->_do_not_bill[$REG_ID]);
             }
         }
         foreach ($this->_do_not_bill as $REG_ID => $TKT_ID) {
             if ($line_item->OBJ_ID() === $TKT_ID) {
                 //echo '<h5 style="color:#2EA2CC;">non_billable : <span style="color:#E76700">' . $line_item->unit_price() . '</span><br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span>    <b style="font-size:10px;color:#333">  ' . __LINE__ . ' </b></h5>';
                 $this->_non_billable_total += $line_item->unit_price();
                 if ($line_item->is_taxable()) {
                     $this->_non_billable_tax_total += $line_item->unit_price();
                 }
                 unset($this->_do_not_bill[$REG_ID]);
             }
         }
     }
     return $billable;
 }