public function __construct()
 {
     // Use a plural name for the database
     $this->_table = get_class($this);
     $inflect = new Inflect();
     $this->_table = strtolower($inflect->pluralize($this->_table));
     $this->loadTableColumns();
 }
Exemplo n.º 2
0
 public function __construct($model = '', $fields = '', $zip = null, $version = '0.6', $norm = true)
 {
     if (empty($model)) {
         trigger_error('Please provide a model');
         exit;
     }
     if (empty($fields)) {
         trigger_error('Please provide fields');
         exit;
     }
     $this->model->lowercase = strtolower($this->computerize(Inflect::singularize($model)));
     $this->model->capital = ucwords($this->computerize(Inflect::singularize($model)));
     $this->models->lowercase = strtolower($this->computerize(Inflect::pluralize($model)));
     $this->models->capital = ucwords($this->computerize(Inflect::pluralize($model)));
     $this->models->table = $this->computerize($this->models->lowercase);
     $this->models->human = $this->humanize($this->models->lowercase);
     $this->models->human_capital = $this->humanize($this->models->capital);
     $this->models->class = ucwords($this->computerize(Inflect::singularize($model), 'camelcase'));
     $this->models->migration = ucwords($this->computerize(Inflect::pluralize($model), 'camelcase'));
     $this->fields = $this->field_cleaner($fields);
     $this->zip = $zip;
     $this->version = $version;
     if ($this->version < '0.6') {
         $this->norm = false;
     } else {
         $this->norm = $norm;
     }
     $this->include_path = $_SERVER['DOCUMENT_ROOT'] . '/tools/_shared/admin_templates/' . $this->version . ($this->norm ? '_norm' : '') . '/';
     if (!file_exists($this->include_path)) {
         trigger_error('AI files for ' . $this->version . ($this->norm ? '_norm' : '') . ' doesn\'t exist.');
         exit;
     }
 }
Exemplo n.º 3
0
 public static function gateway($gateway = null, $options = array())
 {
     $gateway = "Merchant_Billing_" . Inflect::camelize($gateway);
     if (class_exists($gateway)) {
         return new $gateway($options);
     }
     throw new Exception("Unable to load class: {$gateway}.");
 }
Exemplo n.º 4
0
 public static function pluralize_if($count, $string)
 {
     if ($count == 1) {
         return "1 {$string}";
     } else {
         return $count . " " . Inflect::pluralize($string);
     }
 }
Exemplo n.º 5
0
 function __construct($route = null)
 {
     parent::__construct($route);
     $controllerClass = $this->getControllerClassName();
     // Create model instance for each registered model in the controller
     if (isset($this->uses)) {
         foreach ($this->uses as $use) {
             $this->{$use} = new $use();
         }
     } else {
         // Default model based on Controller name
         $sing = Inflect::singularize($controllerClass);
         $this->{$sing} = new $sing();
         $this->model = $this->{$sing};
     }
 }
Exemplo n.º 6
0
 /**
  * Create a model class name from a plural table name.
  *
  * <code>
  * TipyInflector::classify('blog_posts') // => BlogPost
  * </code>
  * @param string $str
  * @return string
  */
 public static function classify($str)
 {
     $str = self::camelCase($str);
     $str = Inflect::singularize($str);
     return ucfirst($str);
 }
Exemplo n.º 7
0
 function p($num, $label)
 {
     return Inflect::pluralizeIf($num, $label);
 }
Exemplo n.º 8
0
 protected function get_index_url()
 {
     if (null !== $this->_index_url) {
         return $this->_index_url;
     }
     $module = $this->getRequest()->getModuleName();
     $this->_index_url = "/" . ('index' == strtolower($module) ? null : $module . "/") . Inflect::underscore($this->getRequest()->getControllerName()) . "/index";
     $this->getView()->assign('index_url', $this->_index_url);
     return $this->_index_url;
 }
Exemplo n.º 9
0
    }
    if (CurrentMember::auth_type('site_admin')) {
        $panel_admin_menu = '
        <div class="tab_frame">
          <a href="' . PATH . 'panel_admin.php" class="' . ($page_tab == 'admin_panel' ? ' current_tab' : '') . '">Site Admin</a>
        </div>';
    }
    $logout_menu = '
        <div class="tab_frame right">
          <a href="' . PATH . 'index.php?action=logout" class="' . ($page_tab == 'login' ? ' current_tab' : '') . '">Logout</a>
        </div>';
    if (isset($basket_id) && $basket_id != 0) {
        if (CurrentMember::auth_type('orderex') || ActiveCycle::ordering_window() == 'open') {
            $basket_menu = '
        <div class="tab_frame right">
          <a href="' . PATH . 'product_list.php?type=basket" class="">View Basket [' . $basket_quantity . ' ' . Inflect::pluralize_if($basket_quantity, 'item') . ']</a>
        </div>';
        }
    }
} else {
    $login_menu = '
        <div class="tab_frame right">
          <a href="' . PATH . 'index.php?action=login" class="' . ($page_tab == 'login' ? ' current_tab' : '') . '">Login</a>
        </div>';
}
// Put it all together now
////////////////////////////////////////////////////////////////////////////////
//////////////                                              ////////////////////
//////////////     ASSEMBLE FINAL OUTPUT FOR POPUP PAGES    ////////////////////
//////////////                                              ////////////////////
////////////////////////////////////////////////////////////////////////////////
Exemplo n.º 10
0
function get_baskets_list()
{
    global $connection;
    // Get a list of the order cycles since the member joined
    $delivery_id_array = array();
    $delivery_attrib = array();
    $query = '
      SELECT 
        delivery_id,
        date_open,
        date_closed,
        order_fill_deadline,
        delivery_date
      FROM
        ' . TABLE_ORDER_CYCLES . '
      WHERE
        delivery_date > "' . mysql_real_escape_string($_SESSION['renewal_info']['membership_date']) . '"
        AND date_open < NOW()
      ORDER BY
        delivery_date DESC';
    $result = @mysql_query($query, $connection) or die(debug_print("ERROR: 898034 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
    while ($row = mysql_fetch_array($result)) {
        array_push($delivery_id_array, $row['delivery_id']);
        $delivery_attrib[$row['delivery_id']]['date_open'] = $row['date_open'];
        $delivery_attrib[$row['delivery_id']]['time_open'] = strtotime($row['date_open']);
        $delivery_attrib[$row['delivery_id']]['date_closed'] = $row['date_closed'];
        $delivery_attrib[$row['delivery_id']]['time_closed'] = strtotime($row['date_closed']);
        $delivery_attrib[$row['delivery_id']]['order_fill_deadline'] = $row['order_fill_deadline'];
        $delivery_attrib[$row['delivery_id']]['delivery_date'] = $row['delivery_date'];
    }
    // Now get this customer's baskets
    $query = '
      SELECT 
        *
      FROM
        ' . NEW_TABLE_BASKETS . '
      WHERE
        member_id = "' . mysql_real_escape_string($_SESSION['member_id']) . '"
      ORDER BY
        delivery_id DESC';
    $result = @mysql_query($query, $connection) or die(debug_print("ERROR: 898034 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
    while ($row = mysql_fetch_array($result)) {
        $delivery_attrib[$row['delivery_id']]['basket_id'] = $row['basket_id'];
        $delivery_attrib[$row['delivery_id']]['site_id'] = $row['site_id'];
        $delivery_attrib[$row['delivery_id']]['delivery_type'] = $row['delivery_type'];
        $delivery_attrib[$row['delivery_id']]['checked_out'] = $row['checked_out'];
    }
    // Display the order cycles and baskets...
    $display .= '
        <div id="basket_dropdown" class="dropdown">
          <a href="' . $_SERVER['SCRIPT_NAME'] . '?action=basket_list_only"><h1 class="basket_history">
            Ordering History
          </h1></a>
          <div id="basket_history">
            <ul class="basket_history">';
    foreach ($delivery_id_array as $delivery_id) {
        $full_empty = '';
        $open_closed = '';
        $future_past = '';
        // Check if basket for the delivery had any items...
        if ($delivery_attrib[$delivery_id]['checked_out'] != 0) {
            $fe = 'f';
            // full
            $full_empty = 'full';
        } else {
            $fe = 'e';
            // empty
            $full_empty = 'empty';
        }
        // Check if this basket is currently open...
        if ($delivery_attrib[$delivery_id]['time_open'] < time() && $delivery_attrib[$delivery_id]['time_closed'] > time()) {
            $cg = 'c';
            // colored
            $current = true;
            // Start the after_current counter
            $open_closed = 'open';
            $after_current_count = 1;
        } else {
            $cg = 'g';
            // grey
            $open_closed = 'closed';
        }
        // Check if this is a future delivery...
        if ($delivery_attrib[$delivery_id]['time_open'] > time()) {
            $is = 'i';
            // insubstantial
            $cg = 'c';
            // colored
            $current = false;
            $after_current_count++;
            $future_past = 'future';
        } else {
            $is = 's';
            // substantial
            $future_past = 'past';
        }
        $day_open = date('j', $delivery_attrib[$delivery_id]['time_open']);
        $month_open = date('M', $delivery_attrib[$delivery_id]['time_open']);
        $year_open = date('Y', $delivery_attrib[$delivery_id]['time_open']);
        $day_closed = date('j', $delivery_attrib[$delivery_id]['time_closed']);
        $month_closed = date('M', $delivery_attrib[$delivery_id]['time_closed']);
        $year_closed = date('Y', $delivery_attrib[$delivery_id]['time_closed']);
        if ($day_open == $day_closed) {
            $day_open = '';
        }
        if ($month_open == $month_closed) {
            $month_closed = '';
        }
        if ($year_open == $year_closed) {
            $year_open = '';
        }
        $items_in_basket = abs($delivery_attrib[$delivery_id]['checked_out']);
        $current_link = '';
        // Process basket quantity display
        if ($future_past != 'future') {
            if ($items_in_basket) {
                $basket_quantity_text = '[' . $items_in_basket . ' ' . Inflect::pluralize_if($items_in_basket, 'item') . ']';
                $current_link = 'View
                  <a href="product_list.php?type=basket&delivery_id=' . $delivery_id . '">Basket</a> /
                  <a href="show_report.php?type=customer_invoice&delivery_id=' . $delivery_id . '">Invoice</a>';
            } else {
                $basket_quantity_text = '[Empty]';
            }
        }
        // Current order... set link for opening or checking basket
        if ($open_closed == 'open') {
            // Basket does not exist?
            if (!$delivery_attrib[$delivery_id]['basket_id']) {
                $current_link = '
                  <!-- <a href="">Start an Order</a> -->';
            } else {
                $current_link = 'View...
                  <a href="product_list.php?type=basket&delivery_id=' . $delivery_id . '">Basket</a>';
            }
            $basket_quantity_text = '';
        }
        if ($after_current_count <= 2) {
            // Need some onclick code for class=view (full baskets)
            $display .= '
              <li class="' . $fe . $cg . $is . ($full_empty == 'full' || $current == 'true' ? ' view' : '') . '"' . ($open_closed == 'open' ? ' id="current"' : '') . '>
                <span class="delivery_date">Delivery: ' . date('M j, Y', strtotime($delivery_attrib[$delivery_id]['delivery_date'])) . '</span>' . (CurrentBasket::basket_id() && $current == 'true' ? '
                  <span class="basket_link"><a href="product_list.php?type=basket&delivery_id=' . $delivery_id . '">Basket</a></span>
                   &bull; <!--
                   <span class="accounting_link"><a href="member_view_balance.php?account_type=member&delivery_id=' . $delivery_id . '">Account</a></span>
                   &bull; -->
                   <span class="accounting_link"><a href="show_report.php?type=customer_invoice&delivery_id=' . $delivery_id . '&member_id=' . $_SESSION['member_id'] . '">Invoice</a></span>' : '') . '
                <span class="order_dates">' . $month_open . ' ' . $day_open . ' ' . $year_open . ' &ndash; ' . $month_closed . ' ' . $day_closed . ' ' . $year_closed . '</span>
                <span class="basket_qty">' . $basket_quantity_text . '</span>
                <span class="basket_action">' . $current_link . '</span>
              </li>';
        }
    }
    $display .= '
            </ul>
          </div>
        </div>';
    return $display;
}
    public static function Main()
    {
        global $FIELD_TYPES, $mf_domain;
        $customGroupID = $_REQUEST['custom-group-id'];
        if (isset($customGroupID)) {
            $group = RCCWP_CustomGroup::Get($customGroupID);
            ?>

      <script type="text/javascript">

      var mf_create_field = true;

      var mf_group_info = {
        'name' : '<?php 
            echo stripslashes($group->name);
            ?>
',
        'safe_name' : '<?php 
            echo sanitize_title_with_dashes($group->name);
            ?>
',
        'singular_safe_name' : '<?php 
            echo sanitize_title_with_dashes(Inflect::singularize($group->name));
            ?>
'
      };

      </script>

      <?php 
        }
        ?>


  		<div class="wrap">

  		<h2><?php 
        _e("Create Custom Field", $mf_domain);
        ?>
 <?php 
        if ($group && $group->name != "__default") {
            _e("In Group", $mf_domain);
            echo " <em>" . $group->name . "</em>";
        }
        ?>
</h2>
  		<br class="clear" />
  		<?php 
        if (isset($_GET['err_msg'])) {
            switch ($_GET['err_msg']) {
                case -1:
                    ?>
				<div class="error"><p> <?php 
                    _e('A field with the same name already exists in this write panel. Please choose a different name.', $mf_domain);
                    ?>
</p></div>
				<?php 
            }
        }
        ?>

  	<form action="<?php 
        echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('continue-create-custom-field');
        ?>
" method="post" name="create_custom_field_form" id="create-custom-field-form" onsubmit="return checkEmpty();" autocomplete="off">

  		<?php 
        wp_nonce_field('continue-create-custom-field');
        ?>

		<?php 
        if (isset($_GET['custom-group-id']) && !empty($_GET['custom-group-id'])) {
            ?>
  			<input type="hidden" name="custom-group-id" value="<?php 
            echo $_GET['custom-group-id'];
            ?>
">
		<?php 
        }
        ?>
		<?php 
        if (isset($_POST['custom-group-id']) && !empty($_POST['custom-group-id'])) {
            ?>
  			<input type="hidden" name="custom-group-id" value="<?php 
            echo $_POST['custom-group-id'];
            ?>
">
		<?php 
        }
        ?>


		<table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6">
		<tbody>

		<tr valign="top">
			<th scope="row"><?php 
        _e("Label", $mf_domain);
        ?>
:</th>
			<td>
				<input name="custom-field-description" id="custom-field-description" size="40" type="text" />
				<p>
					<?php 
        _e('Type a label for the field. The label of the field is displayed
					beside the field in Write Panel page.', $mf_domain);
        ?>
				</p>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row"><?php 
        _e("Name", $mf_domain);
        ?>
:</th>
			<td>
				<input name="custom-field-name" id="custom-field-name" size="40" type="text" />
				<input type="hidden" id="custom-field-name_hidden" name="custom-field-name_hidden" onchange="copyField();" />

				<p>
					<?php 
        _e('Type a unique name for the field, the name must be unique among all fields
					in this panel. The name of the field is the key by which you can retrieve
					the field value later.', $mf_domain);
        ?>

				</p>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row"><?php 
        _e('Help text', $mf_domain);
        ?>
:</th>
			<td>
				<input name="custom-field-helptext" id="custom-field-helptext" size="40" type="text" /><br/><small><?php 
        _e('If set, this will be displayed in a tooltip next to the field label', $mf_domain);
        ?>
</small></td>
		</tr>

		<tr valign="top">
			<th scope="row"><?php 
        _e("Can be duplicated", $mf_domain);
        ?>
:</th>
			<td><input name="custom-field-duplicate" id="custom-field-duplicate" type="checkbox" value="1" /></td>
		</tr>

		<tr valign="top">
			<th scope="row"><?php 
        _e("Order", $mf_domain);
        ?>
:</th>
			<td><input type="text" name="custom-field-order" id="custom-field-order" size="2" value="0" /></td>
		</tr>


		<tr valign="top">
			<th scope="row"><?php 
        _e("Required", $mf_domain);
        ?>
:</th>
			<td>
				<select name="custom-field-required" id="custom-field-required">
					<option value="0" selected="selected"><?php 
        _e('Not Required - can be empty', $mf_domain);
        ?>
</option>
					<option value="1"><?php 
        _e('Required - can not be empty', $mf_domain);
        ?>
</option>
				</select>
			</td>
		</tr>

		<tr valign="top">
			<th scope="row"><?php 
        _e("Type", $mf_domain);
        ?>
:</th>
			<td>

				<!-- START :: Javascript for Image/Photo' Css Class and for check -->
				<script type="text/javascript" language="javascript">
					submitForm = false;
					function fun(name)
					{
						if(name == "Image" || name == 'Image (Upload Media)')
						{
							document.getElementById('divLbl').style.display = 'inline';
							document.getElementById('divCSS').style.display = 'inline';
						}
						else
						{
							document.getElementById('divLbl').style.display = 'none';
							document.getElementById('divCSS').style.display = 'none';
						}
					}

					function checkEmpty()
					{
						if (submitForm && (document.getElementById('custom-field-name').value == "" || document.getElementById('custom-field-description').value == "")){
							alert("<?php 
        _e('Please fill in the name and the label of the field', $mf_domain);
        ?>
");
							return false;
						}
						return true;

					}
				</script>
				<!-- END :: Javascript for Image/Photo' Css Class -->

				<?php 
        $field_types = RCCWP_CustomField::GetCustomFieldTypes();
        foreach ($field_types as $field) {
            $checked = $field->name == "Textbox" ? 'checked="checked"' : '';
            ?>
					<label><input name="custom-field-type" value="<?php 
            echo $field->id;
            ?>
" type="radio" <?php 
            echo $checked;
            ?>
 onclick='fun("<?php 
            echo $field->name;
            ?>
");' /> <!-- Calling Javascript Function -->
					<?php 
            echo $field->name;
            ?>
</label><br />
				<?php 
        }
        ?>
			</td>
		</tr>
		<!-- START :: For Image/Photo' Css -->
		<tr valign="top">
			<th scope="row"><div id="divLbl" style="display:none"><?php 
        _e('Css Class', $mf_domain);
        ?>
:</div></th>
			<td>
				<div id="divCSS" style="display:none">
				<input name="custom-field-css" id="custom-field-css" size="40" type="text" value="magicfields" />
				</div>
			</td>
		</tr>
		<!-- END :: For Image/Photo' Css -->
		</tbody>
		</table>


	  	<p class="submit" >
  			<a style="color:black" href="<?php 
        echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('cancel-create-custom-field') . "&custom-group-id={$customGroupID}";
        ?>
" class="button"><?php 
        _e('Cancel', $mf_domain);
        ?>
</a>
  			<input type="submit" id="continue-create-custom-field" value='<?php 
        _e("Continue", $mf_domain);
        ?>
'  onclick="submitForm=true;"/>
  		</p>

  		</form>

  		</div>

  		<?php 
    }
Exemplo n.º 12
0
   <tr>
     <td rowspan="5" width="50%" valign="top"><strong>' . $row->product_name . '</strong><br>' . $row->detailed_notes . '</td>
     <td class="prod_desc">Product ID: </td>
     <td class="prod_data"><input type="text" name="product_id" size="3" value="' . $row->product_id . '"><br>
   </tr>
   <tr>
     <td class="prod_desc">Repeat after first order: </td>
     <td class="prod_data"><input type="text" name="repeat_cycles" size="3" value="' . $row->repeat_cycles . '"> ' . Inflect::pluralize_if($row->repeat_cycles, 'time') . '<br>
   </tr>
   <tr>
     <td class="prod_desc">Warn on remaining: </td>
     <td class="prod_data"><input type="text" name="warn_cycles" size="3" value="' . $row->warn_cycles . '"> ' . Inflect::pluralize_if($row->warn_cycles, 'cycle') . '<br>
   </tr>
   <tr>
     <td class="prod_desc">Orders to process: </td>
     <td class="prod_data">' . $row->quantity . ' ' . Inflect::pluralize_if($row->quantity, 'member') . '<br>
   </tr>
   <tr>
     <td class="prod_desc">Last added for: </td>
     <td class="prod_data">' . ($row->delivery_date ? date("M d, Y", strtotime($row->delivery_date)) : '[NEVER]') . '</td>
   </tr>';
 if ($repeat_id == $row->repeat_id && count($completion_array) > 0) {
     sort($completion_array, SORT_NUMERIC);
     $display .= '
   <tr>
     <td colspan="3">
       <div class="completion_list">
       ' . implode('<br>', $completion_array) . '
       </div>
     </td>
   </tr>';
Exemplo n.º 13
0
      <div class="route_row">
        <div class="route_name">' . $route_name . '</div>
      </div>';
    }
    if ($site_inactive == '1') {
        $site_class = 'suspended';
    } elseif ($site_inactive == '2') {
        $site_class = 'standby';
    } else {
        $site_class = 'active';
    }
    $display .= '
      <div class="site_row ' . $site_class . '">
        <div class="hub">Hub: ' . $hub_short . '</div>
        <div class="site_short">' . $site_short . '</span></div>
        <div class="site_orders"><span class="site_long">' . $site_long . '</span><span class="num_orders">' . $num_orders . ' ' . Inflect::pluralize_if($num_orders, 'order') . '</span></div>
        <div class="link"><a href="delivery_list.php?route_id=' . $route_id . '&site_id=' . $site_id . '&delivery_id=' . $delivery_id . '">View by member</a></div>
      </div>';
    $total_orders = $total_orders + $num_orders;
    $route_id_prior = $route_id;
}
$content_delivery = '
    <div id="delivery_id_nav">
      <a class="prior" href="' . $_SERVER['SCRIPT_NAME'] . '?delivery_id=' . ($delivery_id - 1) . '">&larr; PRIOR CYCLE </a>
      <a class="next" href="' . $_SERVER['SCRIPT_NAME'] . '?delivery_id=' . ($delivery_id + 1) . '"> NEXT CYCLE &rarr;</a>
    </div>
    <h5>' . $total_orders . ' Total Orders for this Cycle</h5>
    <div id="site_list">
      ' . $display . '
    </div>';
$page_specific_css = '
Exemplo n.º 14
0
 /**
  * Make a tree like relations to model
  *
  * @param string $parent_field The name of field that make relation possible
  * @return void
  */
 protected function act_as_tree($parent_field = 'parent_id')
 {
     $this->has_many(strtolower(Inflect::pluralize(get_class($this))) . ' as childs', array('foreign_field' => $parent_field));
     $this->belongs_to(strtolower(get_class($this)) . ' as parent', array('foreign_field' => $parent_field));
 }
Exemplo n.º 15
0
            }
            if ($a['count'] < $b['count']) {
                return 1;
            }
            return strcasecmp($a['title'], $b['title']);
        });
        foreach ($domains as $domain) {
            ?>
				<li<?php 
            echo isset($domainMap[$domain['title']]) ? ' class="current subsel"' : '';
            ?>
><button type="submit" name="domain" value="<?php 
            echo isset($domainMap[$domain['title']]) ? '' : a($domain['title']);
            ?>
"><?php 
            echo h(p($domain['count'], Inflect::singularize($domain['title'])));
            ?>
</button></li>
			<?php 
        }
        ?>
		</ol>
		</div>
		<table class="facets">
			<tbody>
			<?php 
        $timeframe = array();
        if (isset($_GET['timeframe']) && is_array($_GET['timeframe'])) {
            foreach ($_GET['timeframe'] as $tf) {
                $timeframe[] = array('id' => $tf, 'title' => $tf);
            }
function show_product_row(&$product, &$unique)
{
    $this_row = $product['this_row'];
    $display_line = '';
    // Check if this is an adjusted quantity
    if ($product[$this_row]['adjustment_group_memo'] != "") {
        $adjustment_class = ' adjusted';
        // Use an associative key...[$product[$this_row]['adjustment_group_memo']]...to prevent repeating memos
        $unique['adjustment_markup'][$product[$this_row]['adjustment_group_memo']] = '
          <tr align="center" class="' . $adjustment_class . '">
            <td colspan="2"></td>
            <td colspan="5" align="left" class="adjustment">Adjustment: ' . $product[$this_row]['adjustment_group_memo'] . '</td>
          </tr>';
    }
    // Aggregate the total order cost over the whole order
    $unique['total_order_amount'] += $product[$this_row]['amount'];
    if ($unique['invoice_price'] == 1) {
        $product['total_product_amount'] += $product[$this_row]['amount'];
    } elseif ($product[$this_row]['text_key'] != 'customer fee') {
        $product['total_product_amount'] += $product[$this_row]['amount'];
    }
    // Aggregate customer fee over whole order
    if ($product[$this_row]['text_key'] == 'customer fee') {
        $unique['total_order_customer_fee'] += $product[$this_row]['amount'];
    }
    // Aggregate tax over whole order
    if (!strpos($product[$this_row]['text_key'], 'tax') === false) {
        $unique['total_order_tax'] += $product[$this_row]['amount'];
        $product['total_product_tax'] += $product[$this_row]['amount'];
    }
    // If the product will be different on the next go-around
    // or if this is the last row, then show product details
    if ($product[$this_row + 1]['product_id'] != $product[$this_row]['product_id'] || $product['this_row'] == $product['number_of_rows']) {
        $tax_display = $product[$this_row]['taxable'] == 1 ? '* ' : '';
        $display_line = '
          <tr align="center" class="' . $adjustment_class . '">
            <td width="40" align="right" valign="top">' . ($unique['view'] == 'editable' ? '<img src="' . DIR_GRAPHICS . 'edit_icon.png" onclick="popup_src(\'adjust_ledger.php?type=product&amp;target=' . $product[$this_row]['bpid'] . '\', \'edit_transaction\', \'\');">' : '') . '</td>
            <td width="50" align="right" valign="top">' . $product[$this_row]['product_id'] . '&nbsp;&nbsp;</td>

            <td align="left" valign="top">' . $product[$this_row]['product_name'] . ($product[$this_row]['customer_message'] != '' ? '<br />
                <font color="#6666aa" face="arial" size="-1"><b>Customer Note: </b>' . $product[$this_row]['customer_message'] . '</font>' : '') . '</td>

            <td align="center" valign="top">' . $product[$this_row]['pricing_display'] . '</td>

            <td align="center" valign="top">' . ($product[$this_row]['out_of_stock'] != 0 ? $product[$this_row]['basket_quantity'] - $product[$this_row]['out_of_stock'] . ' of ' : '') . $product[$this_row]['basket_quantity'] . ' ' . Inflect::pluralize_if($product[$this_row]['basket_quantity'], $product[$this_row]['ordering_unit']) . '</td>

            <td align="center" valign="top">' . ($product[$this_row]['random_weight'] ? $product[$this_row]['total_weight'] ? $product[$this_row]['total_weight'] . ' ' . Inflect::pluralize_if($product[$this_row]['total_weight'], $product[$this_row]['pricing_unit']) : '(wt.&nbsp;pending)' : '') . '</td>

            <td width="13" align="right" valign="top" style="text-align:right;"><b>' . $tax_display . '$' . number_format($product['total_product_amount'] - $product['total_product_tax'], 2) . '</b></td>
          </tr>' . (count($unique['adjustment_markup']) > 0 ? implode('', $unique['adjustment_markup']) : '');
        // Set product aggregations to zero
        unset($unique['adjustment_markup']);
        $product['total_product_amount'] = 0;
        $product['total_product_tax'] = 0;
    }
    return $display_line;
}
Exemplo n.º 17
0
 public static function gateway($gateway = null, $options = array())
 {
     $gateway = 'Merchant_Billing_' . Inflect::camelize($gateway);
     return new $gateway($options);
 }
Exemplo n.º 18
0
 /**
  * Transforma uma palavra para singular
  *
  * @param string $name
  * @return string
  */
 public function singular($name)
 {
     return Inflect::singularize($name);
 }
Exemplo n.º 19
0
 /**
  * @return mixed
  */
 public function toPlural()
 {
     return Inflect::pluralize($this->name);
 }
Exemplo n.º 20
0
    public function __construct($rid, $existing, $opts = array())
    {
        $opts = array_merge(array('min_len' => 4, 'count' => 20), $opts);
        require_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'helpers' . DS . 'Inflect.php';
        $dbh = App::get('db');
        $dbh->setQuery('SELECT t.raw_tag, fa.*
			FROM #__focus_areas fa
			INNER JOIN #__tags t ON t.id = fa.tag_id');
        $this->fa_properties = $dbh->loadAssocList('raw_tag');
        $dbh->setQuery('SELECT raw_tag, (label IS NOT NULL AND label != "") AS is_focus_area
			FROM #__tags_object to1
			INNER JOIN #__tags t ON t.id = to1.tagid
			WHERE to1.tbl = \'resources\' AND to1.objectid = ' . $rid);
        if (!$existing) {
            foreach ($dbh->loadAssocList() as $tag) {
                if ($tag['is_focus_area']) {
                    $this->focus_areas[] = $tag['raw_tag'];
                    $this->existing_fa_map[strtolower($tag['raw_tag'])] = true;
                } else {
                    $this->existing_tags[] = $tag['raw_tag'];
                    $this->existing_map[strtolower($tag['raw_tag'])] = true;
                }
            }
        } else {
            foreach ($existing as $tag) {
                if (!is_null($tag[2])) {
                    $this->existing_fa_map[strtolower($tag[0])] = true;
                } else {
                    $this->existing_tags[] = $tag[0];
                    $this->existing_map[strtolower($tag[0])] = true;
                }
            }
        }
        $dbh->setQuery('SELECT lower(raw_tag) AS raw_tag, CASE WHEN to1.id IS NULL THEN 0 ELSE 1 END AS is_endorsed
			FROM #__tags t
			LEFT JOIN #__tags_object to1 ON to1.tbl = \'tags\' AND to1.objectid = t.id AND to1.label = \'label\' AND to1.tagid = (SELECT id FROM #__tags WHERE tag = \'endorsed\')');
        $tags = array();
        foreach ($dbh->loadAssocList() as $row) {
            $tags[Inflect::singularize($row['raw_tag'])] = $row['is_endorsed'] ? self::ENDORSED_TAG : self::REGULAR_TAG;
            $tags[Inflect::pluralize($row['raw_tag'])] = $row['is_endorsed'] ? self::ENDORSED_TAG : self::REGULAR_TAG;
        }
        $dbh->setQuery('SELECT body FROM #__resource_assoc ra
			LEFT JOIN #__document_resource_rel drr ON drr.resource_id = ra.child_id
			INNER JOIN #__document_text_data dtd ON dtd.id = drr.document_id
			WHERE ra.parent_id = ' . $rid);
        $words = preg_split('/\\W+/', join(' ', $dbh->loadColumn()));
        $word_count = count($words);
        if (!$words[$word_count - 1]) {
            array_pop($words);
            --$word_count;
        }
        $freq = array();
        $last = array();
        foreach ($words as $idx => $word) {
            if (self::is_stop_word($word, $opts['min_len'])) {
                continue;
            }
            $stems = array(array(stem($word), strtolower($word)));
            if (isset($words[$idx + 1]) && !self::is_stop_word($words[$idx + 1], $opts['min_len'])) {
                $stems[] = array($stems[0][0] . ' ' . stem($words[$idx + 1]), strtolower($word) . ' ' . strtolower($words[$idx + 1]));
            }
            if (isset($words[$idx + 2]) && !self::is_stop_word($words[$idx + 2], $opts['min_len'])) {
                $stems[] = array($stems[0][0] . ' ' . stem($words[$idx + 1]) . ' ' . stem($words[$idx + 2]), Inflect::singularize(strtolower($word)) . ' ' . strtolower($words[$idx + 1]) . ' ' . strtolower($words[$idx + 2]));
            }
            foreach ($stems as $set_idx => $set) {
                list($stem, $word) = $set;
                if (isset($this->existing_map[strtolower($word)]) || isset($this->focus_area_map[strtolower($word)])) {
                    continue;
                }
                if (!isset($freq[$stem])) {
                    $freq[$stem] = array('text' => $word, 'count' => 0);
                } else {
                    $freq[$stem]['count'] += ($idx - $last[$stem]) / $word_count * ($set_idx + 1);
                }
                $last[$stem] = $idx;
            }
        }
        foreach ($freq as $stem => $def) {
            foreach (array($stem, $def['text']) as $text) {
                if (isset($tags[$text])) {
                    $freq[$stem]['count'] += $tags[$text] === self::ENDORSED_TAG ? 3 : 1.5;
                    break;
                }
            }
        }
        usort($freq, create_function('$a, $b', 'return $a[\'count\'] === $b[\'count\'] ? 0 : ($a[\'count\'] > $b[\'count\'] ? -1 : 1);'));
        $this->tags = array_slice($freq, 0, $opts['count']);
    }
Exemplo n.º 21
0
<?php

require '../../inc/admin/config.php';
$session->auth_or_redirect('admin', '/login.php');
@session_start();
$x = 0;
if ($session->auth('admin')) {
    $timestamp = time();
    $errors = array();
    $tools = array('admin_creator', 'form_builder', 'project_starter');
    foreach ($tools as $tool) {
        $dir = ROOT . '/tools/_shared/tmp/';
        $files = scandir($dir);
        list($prefix) = explode('_', $tool);
        foreach ($files as $file) {
            $filename = split('-', basename($file, '.zip'));
            if ($filename[0] == $prefix && $filename[1] < $timestamp) {
                if (unlink($dir . $file)) {
                    ++$x;
                } else {
                    $errors[] = 'Could not delete: ' . $dir . $file;
                }
            }
        }
    }
}
Flash::add('success', 'Cleared ' . Inflect::pluralize_if($x, 'file'));
if (!empty($errors)) {
    Flash::add('error', implode('<br />', $errors));
}
header("Location: ../");
Exemplo n.º 22
0
 /** Custom SQL Query **/
 function custom($query)
 {
     $this->_result = mysql_query($query, $this->_dbHandle);
     $result = array();
     $table = array();
     $field = array();
     $tempResults = array();
     if (substr_count(strtoupper($query), "SELECT") > 0) {
         if (mysql_num_rows($this->_result) > 0) {
             $numOfFields = mysql_num_fields($this->_result);
             for ($i = 0; $i < $numOfFields; ++$i) {
                 array_push($table, mysql_field_table($this->_result, $i));
                 array_push($field, mysql_field_name($this->_result, $i));
             }
             while ($row = mysql_fetch_row($this->_result)) {
                 for ($i = 0; $i < $numOfFields; ++$i) {
                     $table[$i] = ucfirst(Inflect::singularize($table[$i]));
                     $tempResults[$table[$i]][$field[$i]] = $row[$i];
                 }
                 array_push($result, $tempResults);
             }
         }
         mysql_free_result($this->_result);
     }
     $this->clear();
     return $result;
 }
Exemplo n.º 23
0
    ' . TABLE_PRODUCER . '.producer_id
  ORDER BY
    ' . TABLE_PRODUCER . '.business_name';
$result = @mysql_query($query, $connection) or die(debug_print("ERROR: 897650 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
while ($row = mysql_fetch_array($result)) {
    $producer_id = $row['producer_id'];
    $business_name = $row['business_name'];
    $producttypes = $row['producttypes'];
    $product_count = $row['product_count'];
    if ($product_count > 0 || $show_all) {
        $show_name = "";
        $row_color = $row_count % 2 ? $color1 : $color2;
        $display_top .= '
          <tr bgcolor="' . $row_color . '">
            <td width="25%"><font face="arial" size="3"><b><a href="product_list.php?type=producer_id&producer_id=' . $producer_id . '">' . $business_name . '</a></b></td>
            <td width="75%">' . strip_tags($producttypes) . ' (' . ($product_count > 0 ? number_format($product_count, 0) . ' ' . Inflect::pluralize_if($product_count, 'product') : 'no products currently listed') . ')</font></td>
          </tr>';
        $row_count++;
    }
}
if ($show_all) {
    $content_list .= '
  <font face="arial">
    All producers listed below have been approved for selling by ' . SITE_NAME . ', although some
    may not currently have products for sale.  Also available is a list of only those
    <a href="' . $_SERVER['SCRIPT_NAME'] . '">producers with products for sale</a>.<br><br>
    Not from this region? Don&rsquo;t despair. Many of these producers are ready and able
    to ship their products to you, including frozen meats! Please contact the producers
    directly about the shipping policies. <br><br>';
} else {
    $content_list .= '
Exemplo n.º 24
0
        // the current number of views to send back, so do the next query first...
    }
    $query = '
      SELECT
        COUNT(status_key) AS total_views,
        MIN(timestamp) AS oldest_view
      FROM ' . NEW_TABLE_STATUS . '
      WHERE
        status_scope = "motd_viewed"
        AND status_value = "popup"';
    $result = @mysql_query($query, $connection) or die(debug_print("ERROR: 578230 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
    if ($row = mysql_fetch_object($result)) {
        $total_views = $row->total_views;
        $oldest_view = $row->oldest_view;
    }
    $views_text = 'Viewed by ' . $total_views . ' ' . Inflect::pluralize_if($total_views, 'member') . (isset($oldest_view) ? ' since<br />' . $oldest_view : '') . '.';
    if ($_GET['action'] == 'reset_motd') {
        echo $views_text;
        exit(0);
    }
    $motd_reset = '
      <fieldset id="motd_admin">
        <legend>Admin Function</legend>
        <div class="instructions">
          Administrators may edit the MOTD message (in HTML) under Site Admin / Edit Site Configuration. By default, members will be forced to view the MOTD every ' . MOTD_REPEAT_TIME . ' days.
          Pressing the reset button below (twice to confirm) will force all members to view the MOTD the next time they access this site.
        </div>
        <span id="total_views" class="total_views">' . $views_text . '</span>
        <input id="reset_motd" class="reset_motd" type="button" onblur="reset_motd(this,\'clear\')" onclick="reset_motd(this,\'set\')" value="RESET ALL MOTD VIEWS" title="Reset all MOTD views">
      </div>';
}
Exemplo n.º 25
0
 /**
  * run_association()
  * 
  * Runs association when requested
  * 
  * @param string $class Class of the association to run
  *
  * @return Association model(s)
  **/
 private function run_association($class)
 {
     $type = key($this->config->associations[$class]);
     $options = $this->config->associations[$class][$type];
     $class_name = $this->classify(Inflect::singularize($options['model']));
     $c = new $class_name();
     // Set the field for lookup
     if (isset($options['field'])) {
         $id_field = $options['field'];
     } else {
         $id_field = $type == 'belongs_to' ? $options['model'] . '_id' : strtolower(get_class($this)) . '_id';
     }
     // Perform search
     list($find, $param) = $type == 'belongs_to' ? array('find_by_id', $this->{$id_field}) : array('find_by_' . $id_field, $this->id);
     $members = $c->order_by(@$options['order_by'])->{$find}($param);
     array_push($this->config->ignore, $class);
     if (empty($members)) {
         return array();
     } else {
         return $type == 'has_many' ? $members : $members[0];
     }
 }
Exemplo n.º 26
0
function inventory_display_calc($data)
{
    return $data['inventory_id'] ? '<span id="available' . $data['product_id'] . '">' . ($data['inventory_quantity'] == 0 ? '[OUT OF STOCK] No' : $data['inventory_quantity']) . '</span> more ' . Inflect::pluralize_if($data['inventory_quantity'], $data['ordering_unit']) . ' available. ' : '';
}
function show_product_row(&$product, &$unique)
{
    $this_row = $product['this_row'];
    $display_line = '';
    // Capture producer product costs
    if ($product[$this_row]['text_key'] == 'quantity cost' || $product[$this_row]['text_key'] == 'weight cost' || $product[$this_row]['text_key'] == 'extra charge') {
        $unique['total_bpid_amount'] += $product[$this_row]['amount'];
        $unique['total_product_amount'] += $product[$this_row]['amount'];
        $unique['total_order_amount'] += $product[$this_row]['amount'];
    } else {
        $unique['total_bpid_fee'] += $product[$this_row]['amount'];
        $unique['total_product_fee'] += $product[$this_row]['amount'];
        $unique['total_order_fee'] += $product[$this_row]['amount'];
    }
    // Aggregate customer fee over whole order
    if ($product[$this_row]['text_key'] == 'customer fee') {
        $unique['total_order_customer_fee'] += $product[$this_row]['amount'];
    }
    // Aggregate tax over whole order
    if (!strpos($product[$this_row]['text_key'], 'tax') === false) {
        $unique['total_order_tax'] += $product[$this_row]['amount'];
        $product['total_product_tax'] += $product[$this_row]['amount'];
    }
    // If the product will be different on the next go-around
    // or if this is the last row, then show product details
    if ($product[$this_row + 1]['bpid'] != $product[$this_row]['bpid'] || $product['this_row'] == $product['number_of_rows']) {
        $display_line = '
          <tr align="center">
            <td width="40" align="right" valign="top" style="text-align:right;">' . ($unique['view'] == 'editable' ? '<img src="' . DIR_GRAPHICS . 'edit_icon.png" onclick="popup_src(\'adjust_ledger.php?type=product&amp;target=' . $product[$this_row]['bpid'] . '\', \'adjust_ledger\', \'\');">' : '') . '</td>
            <td width="50" align="right" valign="top" style="text-align:right;">' . $product[$this_row]['member_id'] . '&nbsp;&nbsp;</td>
            <td align="left" valign="top">' . $product[$this_row]['preferred_name'] . '</td>

            <td align="center" valign="top">' . ($product[$this_row]['out_of_stock'] != 0 ? $product[$this_row]['basket_quantity'] - $product[$this_row]['out_of_stock'] . ' of ' : '') . $product[$this_row]['basket_quantity'] . ' ' . Inflect::pluralize_if($product[$this_row]['basket_quantity'], $product[$this_row]['ordering_unit']) . '</td>

            <td align="center" valign="top">' . ($product[$this_row]['random_weight'] ? $product[$this_row]['total_weight'] ? $product[$this_row]['total_weight'] . ' ' . Inflect::pluralize_if($product[$this_row]['total_weight'], $product[$this_row]['pricing_unit']) : '(wt.&nbsp;pending)' : '') . '</td>

            <td width="13" align="right" valign="top" style="text-align:right;">' . number_format($unique['total_bpid_amount'], 2) . '</td>
            <td align="center" valign="top"></td>
          </tr>';
        // Reset totals for this row (bpid)
        $unique['total_bpid_amount'] = 0;
        $unique['total_bpid_fee'] = 0;
        $unique['product_count']++;
    }
    return $display_line;
}
Exemplo n.º 28
0
function singularize($str)
{
    require_once 'pluralize.inc';
    $infl = new Inflect();
    return $infl->singuarize($str);
}
Exemplo n.º 29
0
    $result = @mysql_query($query, $connection) or die(debug_print("ERROR: 730302 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
    while ($row = mysql_fetch_object($result)) {
        if ($row->site_id != $site_id_prior) {
            $output .= '
              </pre>' . ($_GET['paginate'] == 'true' ? '<!-- NEW SHEET -->' : '') . '
<h3>' . $row->site_long . ' [' . $row->site_short . ']</h3>
              <pre>
(MEMBR)  ROUTE CODE                - NAME
  PROD_ID   CHK    STOR  DESCRIPTION                                  QUANTITY
___________________________________________________________________________________________________';
        }
        $route_code = convert_route_code((array) $row);
        if ($row->member_id != $member_id_prior || $row->site_id != $site_id_prior) {
            $output .= "\n\n " . str_pad('(' . $row->member_id . ')', 6, ' ', STR_PAD_LEFT) . '  ' . $route_code . ' - ' . $row->first_name . ' ' . $row->last_name . "\n  " . str_pad($row->product_id, 7, ' ', STR_PAD_LEFT) . '   ' . $checkbox . '  ' . str_pad($row->storage_code, 6) . str_pad(substr($row->product_name, 0, 40), 40) . '     ' . '(' . $row->quantity . ') - ' . Inflect::pluralize_if($row->quantity, $row->ordering_unit);
        } else {
            $output .= "\n  " . str_pad($row->product_id, 7, ' ', STR_PAD_LEFT) . '   ' . $checkbox . '  ' . str_pad($row->storage_code, 6) . str_pad(substr($row->product_name, 0, 40), 40) . '     ' . '(' . $row->quantity . ') - ' . Inflect::pluralize_if($row->quantity, $row->ordering_unit);
        }
        //         $output .= '
        //
        //                 <tr>
        //                   <td width="7%">'.$row->storage_code.'</td>
        //                   <td width="75%">('.$row->member_id.') ['.$row->product_id.'] '.$row->product_name.'</td>
        //                   <td width="18%">('.$row->quantity.') - '.Inflect::pluralize_if ($row->product_quantity, $row->ordering_unit).'</td>
        //                 </tr>';
        $site_id_prior = $row->site_id;
        $storage_code_prior = $row->storage_code;
        $member_id_prior = $row->member_id;
    }
    $output .= '
              </pre>';
}
 foreach (array('product_id', 'item_price', 'quantity', 'random_weight', 'total_weight', 'taxable', 'extra_charge', 'out_of_stock') as $field_name) {
     if (${$field_name} != $old_invoice[$product_id][$field_name]) {
         $error[$field_name] = $error_flag;
         $invoice[$field_name] = '<span id="invoice_' . $field_name . '" class="invoice_source">' . htmlspecialchars($old_invoice[$product_id][$field_name], ENT_QUOTES) . '</span>';
         $move_link[$field_name] = '<span id="transfer_' . $field_name . '" class="transfer" onClick="transfer_to_field(\'invoice_' . $field_name . '\',\'update_' . $field_name . '\');update_db(\'' . $field_name . '\');document.getElementById(\'skip\').innerHTML=\' &nbsp; &nbsp; <br>Continue<br> &nbsp; &nbsp; \'">' . $transfer_this . '</span>';
         $update[$field_name] = '<input size="5" id="update_' . $field_name . '" class="update_destination" value="' . htmlentities(${$field_name}) . '" onChange="update_db(\'' . $field_name . '\')">';
         $errors++;
     } else {
         $invoice[$field_name] = htmlspecialchars($old_invoice[$product_id][$field_name], ENT_QUOTES);
         $move_link[$field_name] = '';
         $update[$field_name] = htmlspecialchars(${$field_name}, ENT_QUOTES);
     }
 }
 // These fields must match with consideration for pluralization
 foreach (array('pricing_unit', 'ordering_unit') as $field_name) {
     if (${$field_name} != trim($old_invoice[$product_id][$field_name]) && Inflect::singularize(${$field_name}) != trim($old_invoice[$product_id][$field_name]) && Inflect::pluralize(${$field_name}) != trim($old_invoice[$product_id][$field_name]) && ${$field_name} . 's' != trim($old_invoice[$product_id][$field_name])) {
         $error[$field_name] = $error_flag;
         $invoice[$field_name] = '<span id="invoice_' . $field_name . '" class="invoice_source">' . htmlspecialchars($old_invoice[$product_id][$field_name], ENT_QUOTES) . '</span>';
         $move_link[$field_name] = '<span id="transfer_' . $field_name . '" class="transfer" onClick="transfer_to_field(\'invoice_' . $field_name . '\',\'update_' . $field_name . '\');update_db(\'' . $field_name . '\');document.getElementById(\'skip\').innerHTML=\' &nbsp; &nbsp; <br>Continue<br> &nbsp; &nbsp; \'">' . $transfer_this . '</span>';
         $update[$field_name] = '<input size="15" id="update_' . $field_name . '" class="update_destination" value="' . htmlentities(${$field_name}) . '" onChange="update_db(\'' . $field_name . '\')">';
         $errors++;
     } else {
         $invoice[$field_name] = htmlspecialchars($old_invoice[$product_id][$field_name], ENT_QUOTES);
         $move_link[$field_name] = '';
         $update[$field_name] = htmlspecialchars(${$field_name}, ENT_QUOTES);
     }
 }
 if ($errors > 0) {
     // Only display this stuff if there were errors
     // How many products in this basket? This is used to create a basket-progress bar.
     $query_progress = '