/**
  *
  * @param Request $request
  * @param Exercise $exercise
  * @return mixed
  */
 public function update(Request $request, Exercise $exercise)
 {
     // Create an array with the new fields merged
     $data = array_compare($exercise->toArray(), $request->only(['name', 'step_number', 'default_quantity', 'description', 'target', 'priority', 'frequency']));
     $exercise->update($data);
     if ($request->has('stretch')) {
         $exercise->stretch = $request->get('stretch');
         $exercise->save();
     }
     if ($request->has('series_id')) {
         $series = Series::findOrFail($request->get('series_id'));
         $exercise->series()->associate($series);
         $exercise->save();
     }
     if ($request->has('program_id')) {
         $program = ExerciseProgram::findOrFail($request->get('program_id'));
         $exercise->program()->associate($program);
         $exercise->save();
     }
     if ($request->has('default_unit_id')) {
         $unit = Unit::where('for', 'exercise')->findOrFail($request->get('default_unit_id'));
         $exercise->defaultUnit()->associate($unit);
         $exercise->save();
     }
     return $this->responseOkWithTransformer($exercise, new ExerciseTransformer());
 }
Пример #2
0
 /**
  *
  * @param Request $request
  * @param Category $category
  * @return Response
  */
 public function update(Request $request, Category $category)
 {
     // Create an array with the new fields merged
     $data = array_compare($category->toArray(), $request->only(['name']));
     $category->update($data);
     return response($category->transform(), Response::HTTP_OK);
 }
 /**
  * UPDATE /api/favouritesTransactions/{favouriteTransactions}
  * @param Request $request
  * @param FavouriteTransaction $favourite
  * @return Response
  */
 public function update(Request $request, FavouriteTransaction $favourite)
 {
     // Create an array with the new fields merged
     $data = array_compare($favourite->toArray(), $request->only(['name', 'type', 'description', 'merchant', 'total']));
     $favourite->update($data);
     if ($request->has('account_id')) {
         $favourite->account()->associate(Account::findOrFail($request->get('account_id')));
         $favourite->fromAccount()->dissociate();
         $favourite->toAccount()->dissociate();
         $favourite->save();
     }
     if ($request->has('from_account_id')) {
         $favourite->fromAccount()->associate(Account::findOrFail($request->get('from_account_id')));
         $favourite->account()->dissociate();
         $favourite->save();
     }
     if ($request->has('to_account_id')) {
         $favourite->toAccount()->associate(Account::findOrFail($request->get('to_account_id')));
         $favourite->account()->dissociate();
         $favourite->save();
     }
     if ($request->has('budget_ids')) {
         $favourite->budgets()->sync($request->get('budget_ids'));
     }
     $favourite = $this->transform($this->createItem($favourite, new FavouriteTransactionTransformer()))['data'];
     return response($favourite, Response::HTTP_OK);
 }
 /**
  *
  * @param Request $request
  * @param Activity $activity
  * @return Response
  */
 public function update(Request $request, Activity $activity)
 {
     // Create an array with the new fields merged
     $data = array_compare($activity->toArray(), $request->only(['name', 'color']));
     $activity->update($data);
     $activity = $this->transform($this->createItem($activity, new ActivityTransformer()))['data'];
     return response($activity, Response::HTTP_OK);
 }
Пример #5
0
 /**
  * UPDATE /api/accounts/{accounts}
  * @param UpdateAccountRequest $request
  * @param Account $account
  * @return Response
  */
 public function update(UpdateAccountRequest $request, Account $account)
 {
     // Create an array with the new fields merged
     $data = array_compare($account->toArray(), $request->only(['name']));
     $account->update($data);
     $account = $this->transform($this->createItem($account, new AccountTransformer()))['data'];
     return response($account, Response::HTTP_OK);
 }
 /**
  * UPDATE /api/weights/{weights}
  * @param Request $request
  * @param Weight $weight
  * @return Response
  */
 public function update(Request $request, Weight $weight)
 {
     // Create an array with the new fields merged
     $data = array_compare($weight->toArray(), $request->only(['weight']));
     $weight->update($data);
     $weight = $this->transform($this->createItem($weight, new WeightTransformer()))['data'];
     return response($weight, Response::HTTP_OK);
 }
 /**
  *
  * @param Request $request
  * @param Series $series
  * @return mixed
  */
 public function update(Request $request, Series $series)
 {
     // Create an array with the new fields merged
     $data = array_compare($series->toArray(), $request->only(['name', 'priority']));
     //        dd($data);
     $series->update($data);
     if ($request->has('workout_ids')) {
         $series->workouts()->sync($request->get('workout_ids'));
         //            $series->save();
     }
     return $this->responseOkWithTransformer($series, new SeriesTransformer());
 }
 /**
  *
  * @param Request $request
  * @param Timer $timer
  * @return Response
  */
 public function update(Request $request, Timer $timer)
 {
     // Create an array with the new fields merged
     $data = array_compare($timer->toArray(), $request->only(['start', 'finish']));
     $timer->update($data);
     if ($request->has('activity_id')) {
         $timer->activity()->associate(Activity::findOrFail($request->get('activity_id')));
         $timer->save();
     }
     //        dd($timer);
     $finishDate = $this->calculateFinishDate($timer);
     $timer = $this->transform($this->createItem($timer, new TimerTransformer(['date' => $finishDate])))['data'];
     return response($timer, Response::HTTP_OK);
 }
Пример #9
0
/**
 * Crawl through each array to find differences.
 * 
 * This includes differences in type (i.e. "2", 2 and 2.0 differ) as well as
 * bits present on one side but not on the other.  To catch differences,
 * including those of type, you need to use var_dump() on the result;
 * print_r() is too limited.
 *
 * This version includes dwraven's replacement of isset() with
 * array_key_exists(), as well as a new improvement to allow the comparison of
 * non-array arguments.
 *
 * @param mixed $array1 Array 1 (or anything to test with !==)
 * @param mixed $array2 Array 2
 *
 * @return array An array with two elements, one containing what's in your 
 *               first array, but not your second, and the second is vice 
 *               versa.
 */
function array_compare($array1, $array2)
{
    $diff = false;
    if (!is_array($array1) || !is_array($array2)) {
        // We need two arrays, so return non-array comparison.
        if ($array1 !== $array2) {
            $diff = array($array1, $array2);
        }
        return $diff;
    }
    // Left-to-right
    foreach ($array1 as $key => $value) {
        if (!array_key_exists($key, $array2)) {
            $diff[0][$key] = $value;
        } elseif (is_array($value)) {
            if (!is_array($array2[$key])) {
                $diff[0][$key] = $value;
                $diff[1][$key] = $array2[$key];
            } else {
                $new = array_compare($value, $array2[$key]);
                if ($new !== false) {
                    if (isset($new[0])) {
                        $diff[0][$key] = $new[0];
                    }
                    if (isset($new[1])) {
                        $diff[1][$key] = $new[1];
                    }
                }
            }
        } elseif ($array2[$key] !== $value) {
            $diff[0][$key] = $value;
            $diff[1][$key] = $array2[$key];
        }
    }
    // Right-to-left
    foreach ($array2 as $key => $value) {
        if (!array_key_exists($key, $array1)) {
            $diff[1][$key] = $value;
        }
        // No direct comparsion because matching keys were compared in the
        // left-to-right loop earlier, recursively.
    }
    return $diff;
}
Пример #10
0
 /**
  * UPDATE /api/foods/{foods}
  * @param Request $request
  * @param Food $food
  * @return Response
  */
 public function update(Request $request, Food $food)
 {
     if ($request->get('updatingCalories')) {
         //We are updating the calories for one of the food's units
         $food->units()->updateExistingPivot($request->get('unit_id'), ['calories' => $request->get('calories')]);
     } else {
         // Create an array with the new fields merged
         $data = array_compare($food->toArray(), $request->only(['name']));
         $food->update($data);
         if ($request->has('default_unit_id')) {
             $food->defaultUnit()->associate(Unit::findOrFail($request->get('default_unit_id')));
             $food->save();
         }
         if ($request->has('unit_ids')) {
             $food->units()->sync($request->get('unit_ids'));
         }
     }
     $food = $this->transform($this->createItem($food, new FoodTransformer()))['data'];
     return response($food, Response::HTTP_OK);
 }
function array_compare(&$ar1, &$ar2)
{
    if (gettype($ar1) != 'array' || gettype($ar2) != 'array') {
        return FALSE;
    }
    # first a shallow diff
    if (count($ar1) != count($ar2)) {
        return FALSE;
    }
    $diff = array_diff($ar1, $ar2);
    if (count($diff) == 0) {
        return TRUE;
    }
    # diff failed, do a full check of the array
    foreach ($ar1 as $k => $v) {
        #print "comparing $v == $ar2[$k]\n";
        if (gettype($v) == "array") {
            if (!array_compare($v, $ar2[$k])) {
                return FALSE;
            }
        } else {
            if (!string_compare($v, $ar2[$k])) {
                return FALSE;
            }
            if ($type == 'float') {
                # we'll only compare to 3 digits of precision
                $ok = number_compare($expect, $result, 3);
            }
            if ($type == 'boolean') {
                $ok = boolean_compare($expect, $result);
            } else {
                $ok = string_compare($expect, $result);
            }
        }
    }
    return TRUE;
}
Пример #12
0
 function removeSimilarGrants($grants)
 {
     // first check for similar grants (same modifiers)
     $grants_check = $grants;
     foreach ($grants as $grant => $grant_ar) {
         // loop $grants for each entry in $grants_check (which is a copy)
         array_shift($grants_check);
         if (is_array($grant_ar)) {
             foreach ($grants_check as $grant_c => $grant_ar_c) {
                 if (is_array($grant_ar_c) && array_compare($grant_ar, $grant_ar_c)) {
                     unset($grants[$grant_c]);
                 }
             }
         }
     }
     reset($grants);
     ksort($grants);
     return $grants;
 }
Пример #13
0
 /**
  * Compares two PHP types for a match.
  *
  * @param mixed $expect
  * @param mixed $test_result
  *
  * @return boolean
  */
 function compareResult(&$expect, &$result, $type = null)
 {
     $expect_type = gettype($expect);
     $result_type = gettype($result);
     if ($expect_type == 'array' && $result_type == 'array') {
         // compare arrays
         return array_compare($expect, $result);
     }
     if ($type == 'float') {
         // We'll only compare to 3 digits of precision.
         return number_compare($expect, $result);
     }
     if ($type == 'boolean') {
         return boolean_compare($expect, $result);
     }
     return string_compare($expect, $result);
 }
Пример #14
0
 /** public function save
  *		Saves all changed data to the database
  *
  * @param void
  * @action saves the game data
  * @return void
  */
 public function save()
 {
     call(__METHOD__);
     // grab the base game data
     $query = "\n\t\t\tSELECT state\n\t\t\t\t, extra_info\n\t\t\t\t, modify_date\n\t\t\tFROM " . self::GAME_TABLE . "\n\t\t\tWHERE game_id = '{$this->id}'\n\t\t\t\tAND state <> 'Waiting'\n\t\t";
     $game = $this->_mysql->fetch_assoc($query);
     call($game);
     $update_modified = false;
     if (!$game) {
         throw new MyException(__METHOD__ . ': Game data not found for game #' . $this->id);
     }
     $this->_log('DATA SAVE: #' . $this->id . ' @ ' . time() . "\n" . ' - ' . $this->modify_date . "\n" . ' - ' . strtotime($game['modify_date']));
     // test the modified date and make sure we still have valid data
     call($this->modify_date);
     call(strtotime($game['modify_date']));
     if ($this->modify_date != strtotime($game['modify_date'])) {
         $this->_log('== FAILED ==');
         throw new MyException(__METHOD__ . ': Trying to save game (#' . $this->id . ') with out of sync data');
     }
     $update_game = false;
     call($game['state']);
     call($this->state);
     if ($game['state'] != $this->state) {
         $update_game['state'] = $this->state;
         if ('Finished' == $this->state) {
             $update_game['winner_id'] = $this->_players[$this->_pharaoh->winner]['player_id'];
         }
         if (in_array($this->state, array('Finished', 'Draw'))) {
             try {
                 $this->_add_stats();
             } catch (MyException $e) {
                 // do nothing, it gets logged
             }
         }
     }
     $diff = array_compare($this->_extra_info, self::$_EXTRA_INFO_DEFAULTS);
     $update_game['extra_info'] = $diff[0];
     ksort($update_game['extra_info']);
     $update_game['extra_info'] = serialize($update_game['extra_info']);
     if ('a:0:{}' == $update_game['extra_info']) {
         $update_game['extra_info'] = null;
     }
     if (0 === strcmp($game['extra_info'], $update_game['extra_info'])) {
         unset($update_game['extra_info']);
     }
     if ($update_game) {
         $update_modified = true;
         $this->_mysql->insert(self::GAME_TABLE, $update_game, " WHERE game_id = '{$this->id}' ");
     }
     // update the board
     $color = $this->_players['player']['color'];
     call($color);
     call('IN-GAME SAVE');
     // grab the current board from the database
     $query = "\n\t\t\tSELECT *\n\t\t\tFROM " . self::GAME_HISTORY_TABLE . "\n\t\t\tWHERE game_id = '{$this->id}'\n\t\t\tORDER BY move_date DESC\n\t\t\tLIMIT 1\n\t\t";
     $move = $this->_mysql->fetch_assoc($query);
     $board = $move['board'];
     call($board);
     $new_board = packFEN($this->_pharaoh->get_board());
     call($new_board);
     list($new_move, $new_hits) = $this->_pharaoh->get_move();
     call($new_move);
     call($new_hits);
     if (is_array($new_hits)) {
         $new_hits = implode(',', $new_hits);
     }
     if ($new_board != $board) {
         call('UPDATED BOARD');
         $update_modified = true;
         $this->_current_move_extra_info['laser_fired'] = (bool) $this->can_fire_laser();
         $this->_current_move_extra_info['laser_hit'] = (bool) $this->_pharaoh->laser_hit;
         $diff = array_compare($this->_current_move_extra_info, self::$_HISTORY_EXTRA_INFO_DEFAULTS);
         $m_extra_info = $diff[0];
         ksort($m_extra_info);
         $m_extra_info = serialize($m_extra_info);
         if ('a:0:{}' == $m_extra_info) {
             $m_extra_info = null;
         }
         $this->_mysql->insert(self::GAME_HISTORY_TABLE, array('board' => $new_board, 'move' => $new_move, 'hits' => $new_hits, 'extra_info' => $m_extra_info, 'game_id' => $this->id));
     }
     // update the game modified date
     if ($update_modified) {
         $this->_mysql->insert(self::GAME_TABLE, array('modify_date' => NULL), " WHERE game_id = '{$this->id}' ");
     }
 }
Пример #15
0
function array_compare($needle, $haystack, $match_all = true)
{
    if (!is_array($needle) || count($haystack) > count($needle)) {
        return false;
    }
    $count = 0;
    $result = false;
    foreach ($needle as $k => $v) {
        if (!isset($haystack[$k])) {
            if ($match_all) {
                return false;
            }
            continue;
        }
        if (is_array($v)) {
            $result = array_compare($v, $haystack[$k], $match_all);
        }
        $result = $haystack[$k] === $v && ($match_all && (!$count || $result) || !$match_all) || !$match_all && $result;
        $count++;
    }
    return $result;
}
 /**
  * UPDATE /api/recipes/{recipes}
  * @param Request $request
  * @param Recipe $recipe
  * @return Response
  */
 public function update(Request $request, Recipe $recipe)
 {
     if ($request->get('removeIngredient')) {
         //This line didn't work so I'm using DB::table instead
         //            $recipe->foods()->detach([$request->get('food_id') => ['unit_id' => $request->get('unit_id')]]);
         DB::table('food_recipe')->where('food_id', $request->get('food_id'))->where('unit_id', $request->get('unit_id'))->delete();
     } else {
         if ($request->get('addIngredient')) {
             $recipe->foods()->attach($request->get('food_id'), ['unit_id' => $request->get('unit_id'), 'quantity' => $request->get('quantity'), 'description' => $request->get('description')]);
         } else {
             // Create an array with the new fields merged
             $data = array_compare($recipe->toArray(), $request->only(['name']));
             $recipe->update($data);
             if ($request->has('tag_ids')) {
                 $ids = $request->get('tag_ids');
                 $pivotData = array_fill(0, count($ids), ['taggable_type' => 'recipe']);
                 $syncData = array_combine($ids, $pivotData);
                 $recipe->tags()->sync($syncData);
             }
             if ($request->has('steps')) {
                 //Remove the existing steps from the recipe
                 $currentSteps = $recipe->steps()->delete();
                 //Attach the updated steps to the recipe
                 $count = 0;
                 foreach ($request->get('steps') as $step) {
                     $count++;
                     $step = new RecipeMethod(['step' => $count, 'text' => $step]);
                     $step->user()->associate(Auth::user());
                     $step->recipe()->associate($recipe);
                     $step->save();
                 }
             }
             if ($request->has('ingredients')) {
                 //Remove the existing ingredients from the recipe
                 $currentFoodIds = $recipe->foods()->lists('id')->all();
                 $recipe->foods()->detach($currentFoodIds);
                 //Attach the updated ingredients to the recipe
                 foreach ($request->get('ingredients') as $ingredient) {
                     $recipe->foods()->attach([$ingredient['food_id'] => ['unit_id' => $ingredient['unit_id']]]);
                 }
             }
         }
     }
     $recipe = $this->transform($this->createItem($recipe, new RecipeWithIngredientsTransformer()))['data'];
     return response($recipe, Response::HTTP_OK);
 }
Пример #17
0
 function test_stripslashes_deep()
 {
     // prepare some arrays
     $a1 = array("apostrophe's", "apostrophe''s", "\"quotes\"", "\"\"quotes\"\"");
     $a2 = array("apostrophe\\'s", "apostrophe\\'\\'s", "\\\"quotes\\\"", "\\\"\\\"quotes\\\"\\\"");
     $a3 = array(array("apostrophe's"), array(array("apostrophe''s")), array("\"quotes\""), array("\"\"quotes\"\""));
     $a4 = array(array("apostrophe\\'s"), array(array("apostrophe\\'\\'s")), array("\\\"quotes\\\""), array("\\\"\\\"quotes\\\"\\\""));
     // test a single string
     $this->assertTrue("apostrophe's" == stripslashes_deep("apostrophe\\'s"));
     // test arrays
     $this->assertTrue(array_compare($a1, stripslashes_deep($a2)));
     $this->assertTrue(array_compare($a3, stripslashes_deep($a4)));
 }
Пример #18
0
 public function eq($o)
 {
     $o = new Item($o);
     if ($o->product_slug > $this->product_slug) {
         return -1;
     } else {
         if ($this->product_slug > $o->product_slug) {
             return 1;
         }
     }
     return array_compare($this->options, $o->options);
 }
Пример #19
0
 /** protected function _save
  *		Saves all changed data to the database
  *
  * @param void
  * @action saves the game data
  * @return void
  */
 protected function _save()
 {
     call(__METHOD__);
     // make sure we don't have a MySQL error here, it may be causing the issues
     $run_once = false;
     do {
         if ($run_once) {
             // pause for 3 seconds, then try again
             sleep(3);
         }
         // update the game data
         $query = "\n\t\t\t\tSELECT extra_info\n\t\t\t\t\t, state\n\t\t\t\t\t, modify_date\n\t\t\t\tFROM " . self::GAME_TABLE . "\n\t\t\t\tWHERE game_id = '{$this->id}'\n\t\t\t";
         $game = $this->_mysql->fetch_assoc($query);
         call($game);
         // make sure we don't have a MySQL error here, it may be causing the issues
         $error = $this->_mysql->error;
         $errno = preg_replace('/(\\d+)/', '$1', $error);
         $run_once = true;
     } while (2006 == $errno || 2013 == $errno);
     $update_modified = false;
     if (!$game) {
         throw new MyException(__METHOD__ . ': Game data not found for game #' . $this->id);
     }
     $this->_log('DATA SAVE: #' . $this->id . ' @ ' . time() . "\n" . ' - ' . $this->modify_date . "\n" . ' - ' . strtotime($game['modify_date']));
     // test the modified date and make sure we still have valid data
     call($this->modify_date);
     call(strtotime($game['modify_date']));
     if ($this->modify_date != strtotime($game['modify_date'])) {
         $this->_log('== FAILED ==');
         throw new MyException(__METHOD__ . ': Trying to save game (#' . $this->id . ') with out of sync data');
     }
     $update_game = false;
     call($game['state']);
     call($this->state);
     if ($game['state'] != $this->state) {
         $update_game['state'] = $this->state;
     }
     $diff = array_compare($this->_extra_info, self::$_EXTRA_INFO_DEFAULTS);
     $update_game['extra_info'] = $diff[0];
     ksort($update_game['extra_info']);
     $update_game['extra_info'] = serialize($update_game['extra_info']);
     if ('a:0:{}' == $update_game['extra_info']) {
         $update_game['extra_info'] = null;
     }
     if (0 === strcmp($game['extra_info'], $update_game['extra_info'])) {
         unset($update_game['extra_info']);
     }
     if ($update_game) {
         $update_modified = true;
         $this->_mysql->insert(self::GAME_TABLE, $update_game, " WHERE game_id = '{$this->id}' ");
     }
     // update the board
     // grab the current board from the database
     $query = "\n\t\t\tSELECT *\n\t\t\tFROM " . self::GAME_BOARD_TABLE . "\n\t\t\tWHERE game_id = '{$this->id}'\n\t\t\tORDER BY move_date DESC\n\t\t\tLIMIT 1\n\t\t";
     $board = $this->_mysql->fetch_assoc($query);
     call($board);
     if (!isset($board['board']) || $board['board'] != $this->_quarto->board) {
         call('UPDATED BOARD');
         $update_modified = true;
         $this->_mysql->insert(self::GAME_BOARD_TABLE, array('board' => $this->_quarto->board, 'next_piece' => $this->_quarto->next_piece, 'game_id' => $this->id));
     }
     // update the game modified date
     if ($update_modified) {
         $this->_mysql->insert(self::GAME_TABLE, array('modify_date' => NULL), " WHERE game_id = '{$this->id}' ");
     }
 }
Пример #20
0
function compare(&$x, &$y)
{
    $ok = 0;
    $x_type = gettype($x);
    $y_type = gettype($y);
    if ($x_type == $y_type) {
        if ($x_type == "array") {
            $ok = array_compare($x, $y);
        } else {
            if ($x_type == "object") {
                $ok = object_compare($x, $y);
            } else {
                if ($x_type == "double") {
                    $ok = number_compare($x, $y);
                    //    } else if ($x_type == 'boolean') {
                    //      $ok = boolean_compare($x, $y);
                } else {
                    $ok = $x == $y;
                    //      $ok = string_compare($expect, $result);
                }
            }
        }
    }
    return $ok;
}
Пример #21
0
function object_compare(&$o1, &$o2)
{
    if (!is_object($o1) || !is_object($o2) || gettype($o1) != gettype($o2)) {
        return false;
    }
    $o1 = (array) $o1;
    $o2 = (array) $o2;
    return array_compare($o1, $o2);
}
Пример #22
0
 public function testRequireTreeWorksForRedundantDirectories()
 {
     $sp = $this->getLilo();
     $sp->scan('trilogy.coffee');
     $this->assertTrue(array_compare($sp->getChain('trilogy.coffee'), array('middleEarth/shire/bilbo.js', 'middleEarth/shire/frodo.coffee', 'middleEarth/legolas.coffee')), 'require_tree works for redundant directories');
 }
function fflcommerce_admin_option_display($options)
{
    if (empty($options)) {
        return false;
    }
    $counter = 1;
    foreach ($options as $value) {
        switch ($value['type']) {
            case 'string':
                ?>
<tr>
				<th scope="row"><?php 
                echo $value['name'];
                ?>
</th>
				<td><?php 
                echo $value['desc'];
                ?>
</td>
			  </tr><?php 
                break;
            case 'tab':
                ?>
<div id="<?php 
                echo $value['type'] . $counter;
                ?>
" class="panel">
			  <table class="form-table"><?php 
                break;
            case 'title':
                ?>
<thead>
				<tr>
					<th scope="col" colspan="2">
						<h3 class="title"><?php 
                echo $value['name'];
                ?>
</h3>
						<?php 
                if (!empty($value['desc'])) {
                    ?>
						<p><?php 
                    echo $value['desc'];
                    ?>
</p>
						<?php 
                }
                ?>
					</th>
				</tr>
			  </thead><?php 
                break;
            case 'button':
                ?>
<tr>
				<th scope="row"<?php 
                if (empty($value['name'])) {
                    ?>
 style="padding-top:0px;"<?php 
                }
                ?>
>
					<?php 
                if (!empty($value['tip'])) {
                    ?>
					<a href="#" tip="<?php 
                    echo $value['tip'];
                    ?>
" class="tips" tabindex="99" ></a>
					<?php 
                }
                ?>
					<?php 
                if (!empty($value['name'])) {
                    ?>
					<label for="<?php 
                    echo esc_attr($value['id']);
                    ?>
"><?php 
                    echo $value['name'];
                    ?>
</label>
					<?php 
                }
                ?>
				</th>
				<td<?php 
                if (empty($value['name'])) {
                    ?>
 style="padding-top:0px;"<?php 
                }
                ?>
>
					<a  id="<?php 
                echo esc_attr($value['id']);
                ?>
"
						class="button <?php 
                if (!empty($value['class'])) {
                    echo esc_attr($value['class']);
                }
                ?>
"
						style="<?php 
                if (!empty($value['css'])) {
                    echo esc_attr($value['css']);
                }
                ?>
"
						href="<?php 
                if (!empty($value['href'])) {
                    echo esc_attr($value['href']);
                }
                ?>
"
					><?php 
                if (!empty($value['desc'])) {
                    echo $value['desc'];
                }
                ?>
</a>
				</td>
			  </tr><?php 
                break;
            case 'checkbox':
                ?>
<tr>
				<th scope="row"<?php 
                if (empty($value['name'])) {
                    ?>
 style="padding-top:0px;"<?php 
                }
                ?>
>
					<?php 
                if (!empty($value['tip'])) {
                    ?>
					<a href="#" tip="<?php 
                    echo $value['tip'];
                    ?>
" class="tips" tabindex="99" ></a>
					<?php 
                }
                ?>
					<?php 
                if (!empty($value['name'])) {
                    ?>
					<label for="<?php 
                    echo esc_attr($value['id']);
                    ?>
"><?php 
                    echo $value['name'];
                    ?>
</label>
					<?php 
                }
                ?>
				</th>
				<td<?php 
                if (empty($value['name'])) {
                    ?>
 style="padding-top:0px;"<?php 
                }
                ?>
>
					<input
					id="<?php 
                echo esc_attr($value['id']);
                ?>
"
					type="checkbox"
					class="fflcommerce-input fflcommerce-checkbox <?php 
                if (!empty($value['class'])) {
                    echo esc_attr($value['class']);
                }
                ?>
"
					style="<?php 
                if (!empty($value['css'])) {
                    echo esc_attr($value['css']);
                }
                ?>
"
					name="<?php 
                echo esc_attr($value['id']);
                ?>
"
					<?php 
                if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
                    echo checked(get_option($value['id']), 'yes', false);
                } else {
                    if (isset($value['std'])) {
                        echo checked($value['std'], 'yes', false);
                    }
                }
                ?>
 />
					<label for="<?php 
                echo esc_attr($value['id']);
                ?>
"><?php 
                if (!empty($value['desc'])) {
                    echo $value['desc'];
                }
                ?>
</label>
				</td>
			  </tr><?php 
                break;
            case 'text':
            case 'number':
                ?>
<tr>
				<th scope="row"<?php 
                if (empty($value['name'])) {
                    ?>
 style="padding-top:0px;"<?php 
                }
                ?>
>
					<?php 
                if (!empty($value['tip'])) {
                    ?>
					<a href="#" tip="<?php 
                    echo $value['tip'];
                    ?>
" class="tips" tabindex="99"></a>
					<?php 
                }
                ?>
					<?php 
                if (!empty($value['name'])) {
                    ?>
					<label for="<?php 
                    echo esc_attr($value['id']);
                    ?>
"><?php 
                    echo $value['name'];
                    ?>
</label>
					<?php 
                }
                ?>
				</th>

				<td<?php 
                if (empty($value['name'])) {
                    ?>
 style="padding-top:0px;"<?php 
                }
                ?>
>
					<input name="<?php 
                echo esc_attr($value['id']);
                ?>
"
						id="<?php 
                echo esc_attr($value['id']);
                ?>
"
						type="<?php 
                echo $value['type'];
                ?>
"
						<?php 
                if ($value['type'] == 'number' && !empty($value['restrict']) && is_array($value['restrict'])) {
                    ?>
						min="<?php 
                    echo isset($value['restrict']['min']) ? $value['restrict']['min'] : '';
                    ?>
"
						max="<?php 
                    echo isset($value['restrict']['max']) ? $value['restrict']['max'] : '';
                    ?>
"
						step="<?php 
                    echo isset($value['restrict']['step']) ? $value['restrict']['step'] : 'any';
                    ?>
"
						<?php 
                }
                ?>
						class="regular-text <?php 
                if (!empty($value['class'])) {
                    echo esc_attr($value['class']);
                }
                ?>
"
						style="<?php 
                if (!empty($value['css'])) {
                    echo esc_attr($value['css']);
                }
                ?>
"
						placeholder="<?php 
                if (!empty($value['placeholder'])) {
                    echo esc_attr($value['placeholder']);
                }
                ?>
"
						value="<?php 
                if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
                    echo esc_attr(get_option($value['id']));
                } else {
                    if (isset($value['std'])) {
                        echo esc_attr($value['std']);
                    }
                }
                ?>
" />
					<?php 
                if (!empty($value['desc']) && (!empty($value['name']) && empty($value['group']))) {
                    ?>
							<br /><small><?php 
                    echo $value['desc'];
                    ?>
</small>
					<?php 
                } elseif (!empty($value['desc'])) {
                    ?>
						<?php 
                    echo $value['desc'];
                    ?>
					<?php 
                }
                ?>
				</td>
			  </tr><?php 
                break;
            case 'select':
                ?>
<tr>
				<th scope="row"<?php 
                if (empty($value['name'])) {
                    ?>
 style="padding-top:0px;"<?php 
                }
                ?>
>
					<?php 
                if (!empty($value['tip'])) {
                    ?>
					<a href="#" tip="<?php 
                    echo $value['tip'];
                    ?>
" class="tips" tabindex="99"></a>
					<?php 
                }
                ?>
					<?php 
                if (!empty($value['name'])) {
                    ?>
					<label for="<?php 
                    echo esc_attr($value['id']);
                    ?>
"><?php 
                    echo $value['name'];
                    ?>
</label>
					<?php 
                }
                ?>
				</th>
				<td>
					<select name="<?php 
                echo esc_attr($value['id']);
                ?>
"
							id="<?php 
                echo esc_attr($value['id']);
                ?>
"
							style="<?php 
                if (isset($value['css'])) {
                    echo esc_attr($value['css']);
                }
                ?>
"
							class="<?php 
                if (!empty($value['class'])) {
                    echo esc_attr($value['class']);
                }
                ?>
"
							<?php 
                if (!empty($value['multiple'])) {
                    echo 'multiple="multiple"';
                }
                ?>
							<?php 
                if (!empty($value['class']) && $value['class'] == 'chzn-select' && !empty($value['placeholder'])) {
                    ?>
							data-placeholder="<?php 
                    _e(esc_attr($value['placeholder']));
                    ?>
"
							<?php 
                }
                ?>
					>

					<?php 
                $selected = get_option($value['id']);
                $selected = !empty($selected) ? $selected : $value['std'];
                ?>
					<?php 
                foreach ($value['options'] as $key => $val) {
                    ?>
						<option value="<?php 
                    echo esc_attr($key);
                    ?>
"
						<?php 
                    if (!is_array($selected) && $selected == $key || is_array($selected) && in_array($key, $selected)) {
                        ?>
								selected="selected"
						<?php 
                    }
                    ?>
						>
							<?php 
                    echo ucfirst($val);
                    ?>
						</option>
					<?php 
                }
                ?>
					</select>
					<?php 
                if (!empty($value['desc']) && (!empty($value['name']) && empty($value['group']))) {
                    ?>
						<br /><small><?php 
                    echo $value['desc'];
                    ?>
</small>
					<?php 
                } elseif (!empty($value['desc'])) {
                    ?>
						<?php 
                    echo $value['desc'];
                    ?>
					<?php 
                }
                ?>
				</td>
			  </tr><?php 
                break;
            case 'radio':
                ?>
<tr>
				<th scope="row"<?php 
                if (empty($value['name'])) {
                    ?>
 style="padding-top:0px;"<?php 
                }
                ?>
>
					<?php 
                if (!empty($value['tip'])) {
                    ?>
					<a href="#" tip="<?php 
                    echo $value['tip'];
                    ?>
" class="tips" tabindex="99"></a>
					<?php 
                }
                ?>
					<?php 
                echo $value['name'];
                ?>
				</th>
				<td<?php 
                if (empty($value['name'])) {
                    ?>
 style="padding-top:0px;"<?php 
                }
                ?>
>
					<?php 
                foreach ($value['options'] as $key => $val) {
                    ?>
					<label class="radio">
					<input type="radio"
						   name="<?php 
                    echo esc_attr($value['id']);
                    ?>
"
						   id="<?php 
                    echo esc_attr($key);
                    ?>
"
						   value="<?php 
                    echo esc_attr($key);
                    ?>
"
						   class="<?php 
                    if (!empty($value['class'])) {
                        echo esc_attr($value['class']);
                    }
                    ?>
"
						   <?php 
                    if (get_option($value['id']) == $key) {
                        ?>
 checked="checked" <?php 
                    }
                    ?>
>
					<?php 
                    echo esc_attr(ucfirst($val));
                    ?>
					</label><br />
					<?php 
                }
                ?>
				</td>
			  </tr><?php 
                break;
            case 'image_size':
                $sizes = array('fflcommerce_shop_tiny' => 'fflcommerce_use_wordpress_tiny_crop', 'fflcommerce_shop_thumbnail' => 'fflcommerce_use_wordpress_thumbnail_crop', 'fflcommerce_shop_small' => 'fflcommerce_use_wordpress_catalog_crop', 'fflcommerce_shop_large' => 'fflcommerce_use_wordpress_featured_crop');
                $altSize = $sizes[$value['id']];
                ?>
<tr>
				<th scope="row"><?php 
                echo $value['name'];
                ?>
</label></th>
				<td valign="top" style="line-height:25px;height:25px;">

					<input name="<?php 
                echo esc_attr($value['id']);
                ?>
_w"
						   id="<?php 
                echo esc_attr($value['id']);
                ?>
_w"
						   type="number"
						   min="0"
						   style="width:60px;"
						   placeholder=<?php 
                if (!empty($value['placeholder'])) {
                    echo $value['placeholder'];
                }
                ?>
						   value="<?php 
                if ($size = get_option($value['id'] . '_w')) {
                    echo $size;
                } else {
                    echo $value['std'];
                }
                ?>
"
					/>

					<label for="<?php 
                echo esc_attr($value['id']);
                ?>
_h">x</label>

					<input name="<?php 
                echo esc_attr($value['id']);
                ?>
_h"
						   id="<?php 
                echo esc_attr($value['id']);
                ?>
_h"
						   type="number"
						   min="0"
						   style="width:60px;"
						   placeholder=<?php 
                if (!empty($value['placeholder'])) {
                    echo $value['placeholder'];
                }
                ?>
						   value="<?php 
                if ($size = get_option($value['id'] . '_h')) {
                    echo $size;
                } else {
                    echo $value['std'];
                }
                ?>
"
					/>

					<input
					id="<?php 
                echo esc_attr($altSize);
                ?>
"
					type="checkbox"
					class="fflcommerce-input fflcommerce-checkbox"
					name="<?php 
                echo esc_attr($altSize);
                ?>
"
					<?php 
                if (get_option($altSize) !== false && get_option($altSize) !== null) {
                    echo checked(get_option($altSize), 'yes', false);
                }
                ?>
 />
					<label for="<?php 
                echo esc_attr($altSize);
                ?>
"> <?php 
                echo __('Crop', 'fflcommerce');
                ?>
</label>
					<br /><small><?php 
                echo $value['desc'];
                ?>
</small>
				</td>
			</tr><?php 
                break;
            case 'textarea':
                ?>
<tr>
					<th scope="row"><?php 
                if ($value['tip']) {
                    ?>
<a href="#" tip="<?php 
                    echo $value['tip'];
                    ?>
" class="tips" tabindex="99"></a><?php 
                }
                ?>
<label for="<?php 
                echo esc_attr($value['id']);
                ?>
"><?php 
                echo $value['name'];
                ?>
</label></th>
					<td>
						<textarea <?php 
                if (isset($value['args'])) {
                    echo $value['args'] . ' ';
                }
                ?>
								name="<?php 
                echo esc_attr($value['id']);
                ?>
"
								id="<?php 
                echo esc_attr($value['id']);
                ?>
"
								class="large-text <?php 
                if (!empty($value['class'])) {
                    echo esc_attr($value['class']);
                }
                ?>
"
								style="<?php 
                echo esc_attr($value['css']);
                ?>
"
								placeholder="<?php 
                if (!empty($value['placeholder'])) {
                    echo esc_attr($value['placeholder']);
                }
                ?>
"
						><?php 
                echo esc_textarea(get_option($value['id']) ? stripslashes(get_option($value['id'])) : $value['std']);
                ?>
</textarea>
						<br /><small><?php 
                echo $value['desc'];
                ?>
</small>
					</td>
				</tr><?php 
                break;
            case 'tabend':
                ?>
</table></div><?php 
                $counter = $counter + 1;
                break;
            case 'single_select_page':
                $args = array('name' => $value['id'], 'id' => $value['id'] . '" style="width: 200px;', 'sort_column' => 'menu_order', 'sort_order' => 'ASC', 'selected' => (int) get_option($value['id']));
                if (!empty($value['args'])) {
                    $args = wp_parse_args($value['args'], $args);
                }
                ?>
<tr class="single_select_page">
				<th scope="row"><?php 
                if ($value['tip']) {
                    ?>
<a href="#" tip="<?php 
                    echo $value['tip'];
                    ?>
" class="tips" tabindex="99"></a><?php 
                }
                ?>
<label for="<?php 
                echo esc_attr($value['id']);
                ?>
"><?php 
                echo $value['name'];
                ?>
</label></th>
				<td>
					<?php 
                wp_dropdown_pages($args);
                ?>
					<br /><small><?php 
                echo $value['desc'];
                ?>
</small>
				</td>
			</tr><?php 
                break;
            case 'single_select_country':
                $countries = fflcommerce_countries::$countries;
                $country_setting = (string) get_option($value['id']);
                if (strstr($country_setting, ':')) {
                    $country = current(explode(':', $country_setting));
                    $state = end(explode(':', $country_setting));
                } else {
                    $country = $country_setting;
                    $state = '*';
                }
                ?>
<tr class="multi_select_countries">
					<th scope="row"><?php 
                if ($value['tip']) {
                    ?>
<a href="#" tip="<?php 
                    echo $value['tip'];
                    ?>
" class="tips" tabindex="99"></a><?php 
                }
                ?>
<label for="<?php 
                echo esc_attr($value['id']);
                ?>
"><?php 
                echo $value['name'];
                ?>
</label></th>
					<td>
						<select id="<?php 
                echo esc_attr($value['id']);
                ?>
" name="<?php 
                echo esc_attr($value['id']);
                ?>
" title="Country" style="width: 150px;">
						<?php 
                $show_all = $value['id'] != 'fflcommerce_default_country';
                echo fflcommerce_countries::country_dropdown_options($country, $state, false, $show_all);
                ?>
						</select>
					</td>
				</tr><?php 
                if (!$show_all && fflcommerce_countries::country_has_states($country) && $state == '*') {
                    fflcommerce_countries::base_country_notice();
                }
                break;
            case 'multi_select_countries':
                $countries = fflcommerce_countries::$countries;
                asort($countries);
                $selections = (array) get_option($value['id']);
                ?>
<tr class="multi_select_countries">
					<th scope="row"><?php 
                if ($value['tip']) {
                    ?>
<a href="#" tip="<?php 
                    echo $value['tip'];
                    ?>
" class="tips" tabindex="99"></a><?php 
                }
                ?>
<label><?php 
                echo $value['name'];
                ?>
</label></th>
					<td>
						<div class="multi_select_countries">
							<ul><?php 
                if ($countries) {
                    foreach ($countries as $key => $val) {
                        ?>
<li><label>
								<input type="checkbox"
									   name="<?php 
                        echo esc_attr($value['id']) . '[]';
                        ?>
"
									   value="<?php 
                        echo esc_attr($key);
                        ?>
"
									   <?php 
                        if (in_array($key, $selections)) {
                            ?>
									   checked="checked"
									   <?php 
                        }
                        ?>
								/>
								<?php 
                        echo $val;
                        ?>
								</label></li><?php 
                    }
                }
                ?>
</ul>
						</div>
					</td>
				</tr><?php 
                break;
            case 'coupons':
                _deprecated_argument('fflcommerce_admin_option_display', '1.3', 'The coupons type has no alternative. Use the new custom post Coupons Menu item under FFL Commerce.');
                $coupons = new fflcommerce_coupons();
                $coupon_codes = $coupons->get_coupons();
                ?>
		<style>
table{max-width:100%;background-color:transparent;border-collapse:collapse;border-spacing:0;}
.table{width:100%;margin-bottom:18px;}
.table th,.table td{padding:8px;line-height:18px;text-align:left;vertical-align:top;border-top:1px solid #dddddd;}
.table thead th{vertical-align:bottom;}
.table caption+thead tr:first-child th,.table caption+thead tr:first-child td,.table colgroup+thead tr:first-child th,.table colgroup+thead tr:first-child td,.table thead:first-child tr:first-child th,.table thead:first-child tr:first-child td{border-top:0;}
.table tbody+tbody{border-top:2px solid #dddddd;}
.table-condensed th,.table-condensed td{padding:4px 5px;}
.coupon-table th,.coupon-table td{padding:8px;line-height:18px;text-align:left;vertical-align:top;border-top:0px;}
</style>
			<tr><td><a href="#" class="add button" id="add_coupon"><?php 
                _e('+ Add Coupon', 'fflcommerce');
                ?>
</a></td></tr>

			<table class="coupons table">
				<thead>
					<tr>
						<th>Coupon</th>
						<th>Type</th>
						<th>Amount</th>
						<th>Usage</th>
						<th>Controls</th>
					</tr>
				</thead>
				<tbody>

				<?php 
                /* Payment methods. */
                $payment_methods = array();
                $available_gateways = fflcommerce_payment_gateways::get_available_payment_gateways();
                if (!empty($available_gateways)) {
                    foreach ($available_gateways as $id => $info) {
                        $payment_methods[$id] = $info->title;
                    }
                }
                /* Coupon types. */
                $discount_types = fflcommerce_coupons::get_coupon_types();
                /* Product categories. */
                $categories = get_terms('product_cat', array('hide_empty' => false));
                $coupon_cats = array();
                foreach ($categories as $category) {
                    $coupon_cats[$category->term_id] = $category->name;
                }
                $i = -1;
                if ($coupon_codes && is_array($coupon_codes) && sizeof($coupon_codes) > 0) {
                    foreach ($coupon_codes as $coupon) {
                        $i++;
                        ?>
				<tr>
				<td style="width:500px;">
				<table class="coupon-table form-table" id="coupons_table_<?php 
                        echo $i;
                        ?>
">
				<?php 
                        echo $coupon['code'];
                        ?>

				<tbody class="couponDisplay" id="coupons_rows_<?php 
                        echo $i;
                        ?>
">
				<?php 
                        $selected_type = '';
                        foreach ($discount_types as $type => $label) {
                            if ($coupon['type'] == $type) {
                                $selected_type = $type;
                            }
                        }
                        $options3 = array(array('name' => __('Code', 'fflcommerce'), 'tip' => __('The coupon code a customer enters on the cart or checkout page.', 'fflcommerce'), 'id' => 'coupon_code[' . esc_attr($i) . ']', 'css' => 'width:150px;', 'class' => 'coupon_code', 'type' => 'text', 'std' => esc_attr($coupon['code'])), array('name' => __('Type', 'fflcommerce'), 'tip' => __('Cart - Applies to whole cart<br/>Product - Applies to individual products only. You must specify individual products.', 'fflcommerce'), 'id' => 'coupon_type[' . esc_attr($i) . ']', 'css' => 'width:200px;', 'type' => 'select', 'std' => $selected_type, 'options' => $discount_types), array('name' => __('Amount', 'fflcommerce'), 'tip' => __('Amount this coupon is worth. If it is a percentange, just include the number without the percentage sign.', 'fflcommerce'), 'id' => 'coupon_amount[' . esc_attr($i) . ']', 'css' => 'width:60px;', 'type' => 'number', 'restrict' => array('min' => 0), 'std' => esc_attr($coupon['amount'])), array('name' => __('Usage limit', 'fflcommerce'), 'desc' => __(sprintf('Times used: %s', !empty($coupon['usage']) ? $coupon['usage'] : '0'), 'fflcommerce'), 'placeholder' => __('No limit', 'fflcommerce'), 'tip' => __('Control how many times this coupon may be used.', 'fflcommerce'), 'id' => 'usage_limit[' . esc_attr($i) . ']', 'css' => 'width:60px;', 'type' => 'number', 'restrict' => array('min' => 0), 'std' => !empty($coupon['usage_limit']) ? $coupon['usage_limit'] : ''), array('name' => __('Order subtotal', 'fflcommerce'), 'placeholder' => __('No min', 'fflcommerce'), 'desc' => __('Min', 'fflcommerce'), 'tip' => __('Set the required subtotal for this coupon to be valid on an order.', 'fflcommerce'), 'id' => 'order_total_min[' . esc_attr($i) . ']', 'css' => 'width:60px;', 'type' => 'number', 'restrict' => array('min' => 0), 'std' => !empty($coupon['order_total_min']) ? $coupon['order_total_min'] : '', 'group' => true), array('desc' => __('Max', 'fflcommerce'), 'placeholder' => __('No max', 'fflcommerce'), 'id' => 'order_total_max[' . esc_attr($i) . ']', 'css' => 'width:60px;', 'type' => 'number', 'restrict' => array('min' => 0), 'std' => !empty($coupon['order_total_max']) ? $coupon['order_total_max'] : '', 'group' => true), array('name' => __('Payment methods', 'fflcommerce'), 'tip' => __('Which payment methods are allowed for this coupon to be effective?', 'fflcommerce'), 'id' => 'coupon_pay_methods[' . esc_attr($i) . '][]', 'css' => 'width:200px;', 'class' => 'chzn-select', 'type' => 'select', 'placeholder' => 'Any method', 'multiple' => true, 'std' => !empty($coupon['coupon_pay_methods']) ? $coupon['coupon_pay_methods'] : '', 'options' => $payment_methods));
                        fflcommerce_admin_option_display($options3);
                        ?>

					<tr>
						<th scope="row">
							<a href="#" tip="<?php 
                        _e('Control which products this coupon can apply to.', 'fflcommerce');
                        ?>
" class="tips" tabindex="99"></a>
							<label for="product_ids_<?php 
                        echo esc_attr($i);
                        ?>
"><?php 
                        _e('Products', 'fflcommerce');
                        ?>
</label>
						</th>

						<td>
							<select id="product_ids_<?php 
                        echo esc_attr($i);
                        ?>
" style="width:200px;" name="product_ids[<?php 
                        echo esc_attr($i);
                        ?>
][]" style="width:100px" class="ajax_chosen_select_products_and_variations" multiple="multiple" data-placeholder="<?php 
                        _e('Any product', 'fflcommerce');
                        ?>
">
								<?php 
                        $product_ids = $coupon['products'];
                        if ($product_ids) {
                            foreach ($product_ids as $product_id) {
                                $title = get_the_title($product_id);
                                $sku = get_post_meta($product_id, '_sku', true);
                                if (!$title) {
                                    continue;
                                }
                                if (isset($sku) && $sku) {
                                    $sku = ' (SKU: ' . $sku . ')';
                                }
                                echo '<option value="' . $product_id . '" selected="selected">' . $title . $sku . '</option>';
                            }
                        }
                        ?>
							</select> <?php 
                        _e('Include', 'fflcommerce');
                        ?>
						</td>
					  </tr>

					<tr>
						<th scope="row"></th>
						<td style="padding-top:0px;">
							<select id="exclude_product_ids_<?php 
                        echo esc_attr($i);
                        ?>
" style="width:200px;" name="exclude_product_ids[<?php 
                        echo esc_attr($i);
                        ?>
][]" style="width:100px" class="ajax_chosen_select_products_and_variations" multiple="multiple" data-placeholder="<?php 
                        _e('Any product', 'fflcommerce');
                        ?>
">
								<?php 
                        if (!empty($coupon['exclude_products'])) {
                            foreach ($coupon['exclude_products'] as $product_id) {
                                $title = get_the_title($product_id);
                                $sku = get_post_meta($product_id, '_sku', true);
                                if (!$title) {
                                    continue;
                                }
                                if (isset($sku) && $sku) {
                                    $sku = ' (SKU: ' . $sku . ')';
                                }
                                echo '<option value="' . $product_id . '" selected="selected">' . $title . $sku . '</option>';
                            }
                        }
                        ?>
							</select> <?php 
                        _e('Exclude', 'fflcommerce');
                        ?>
						</td>
					  </tr>

					<?php 
                        $options2 = array(array('name' => __('Categories', 'fflcommerce'), 'desc' => __('Include', 'fflcommerce'), 'tip' => __('Control which categories this coupon can apply to.', 'fflcommerce'), 'id' => 'coupon_category[' . esc_attr($i) . '][]', 'type' => 'select', 'multiple' => true, 'std' => !empty($coupon['coupon_category']) ? $coupon['coupon_category'] : '', 'options' => $coupon_cats, 'class' => 'chzn-select', 'css' => 'width:200px;', 'placeholder' => 'Any category', 'group' => true), array('desc' => __('Exclude', 'fflcommerce'), 'id' => 'exclude_categories[' . esc_attr($i) . '][]', 'type' => 'select', 'multiple' => true, 'std' => !empty($coupon['exclude_categories']) ? $coupon['exclude_categories'] : '', 'options' => $coupon_cats, 'class' => 'chzn-select', 'css' => 'width:200px;', 'placeholder' => 'Any category', 'group' => true), array('name' => __('Dates allowed', 'fflcommerce'), 'desc' => __('From', 'fflcommerce'), 'placeholder' => __('Any date', 'fflcommerce'), 'tip' => __('Choose between which dates this coupon is enabled.', 'fflcommerce'), 'id' => 'coupon_date_from[' . esc_attr($i) . ']', 'css' => 'width:150px;', 'type' => 'text', 'class' => 'date-pick', 'std' => !empty($coupon['date_from']) ? date('Y-m-d', $coupon['date_from']) : '', 'group' => true), array('desc' => __('To', 'fflcommerce'), 'placeholder' => __('Any date', 'fflcommerce'), 'id' => 'coupon_date_to[' . esc_attr($i) . ']', 'css' => 'width:150px;', 'type' => 'text', 'class' => 'date-pick', 'std' => !empty($coupon['date_to']) ? date('Y-m-d', $coupon['date_to']) : '', 'group' => true), array('name' => __('Misc. settings', 'fflcommerce'), 'desc' => 'Prevent other coupons', 'tip' => __('Prevent other coupons from being used while this one is applied to a cart.', 'fflcommerce'), 'id' => 'individual[' . esc_attr($i) . ']', 'type' => 'checkbox', 'std' => isset($coupon['individual_use']) && $coupon['individual_use'] == 'yes' ? 'yes' : 'no'), array('desc' => 'Free shipping', 'tip' => __('Show the Free Shipping method on checkout with this enabled.', 'fflcommerce'), 'id' => 'coupon_free_shipping[' . esc_attr($i) . ']', 'type' => 'checkbox', 'std' => isset($coupon['coupon_free_shipping']) && $coupon['coupon_free_shipping'] == 'yes' ? 'yes' : 'no'));
                        fflcommerce_admin_option_display($options2);
                        ?>
					</tbody>
					</table>
					<script type="text/javascript">
						/* <![CDATA[ */
						jQuery(function() {
							jQuery("select#product_ids_<?php 
                        echo esc_attr($i);
                        ?>
").ajaxChosen({
								method: 	'GET',
								url: 		'<?php 
                        echo !is_ssl() ? str_replace('https', 'http', admin_url('admin-ajax.php')) : admin_url('admin-ajax.php');
                        ?>
',
								dataType: 	'json',
								afterTypeDelay: 100,
								data:		{
									action: 		'fflcommerce_json_search_products_and_variations',
									security: 		'<?php 
                        echo wp_create_nonce("search-products");
                        ?>
'
								}
							}, function (data) {

								var terms = {};

								jQuery.each(data, function (i, val) {
									terms[i] = val;
								});

								return terms;
							});
							jQuery("select#exclude_product_ids_<?php 
                        echo esc_attr($i);
                        ?>
").ajaxChosen({
								method: 	'GET',
								url: 		'<?php 
                        echo !is_ssl() ? str_replace('https', 'http', admin_url('admin-ajax.php')) : admin_url('admin-ajax.php');
                        ?>
',
								dataType: 	'json',
								afterTypeDelay: 100,
								data:		{
									action: 		'fflcommerce_json_search_products_and_variations',
									security: 		'<?php 
                        echo wp_create_nonce("search-products");
                        ?>
'
								}
							}, function (data) {

								var terms = {};

								jQuery.each(data, function (i, val) {
									terms[i] = val;
								});

								return terms;
							});
							jQuery('.date-pick').datepicker( {dateFormat: 'yy-mm-dd', gotoCurrent: true} );
						});
						/* ]]> */
					</script>
				</td>
				<td><?php 
                        echo $discount_types[$selected_type];
                        ?>
</td>
				<td><?php 
                        echo !empty($coupon['amount']) ? $coupon['amount'] : '';
                        ?>
</td>
				<td><?php 
                        echo !empty($coupon['usage']) ? $coupon['usage'] : '0';
                        ?>
</td>
				<td>
					<a class="toggleCoupon" href="#coupons_rows_<?php 
                        echo $i;
                        ?>
"><?php 
                        _e('Show', 'fflcommerce');
                        ?>
</a> /
					<a href="#" id="remove_coupon_<?php 
                        echo esc_attr($i);
                        ?>
" class="remove_coupon" title="<?php 
                        _e('Delete this Coupon', 'fflcommerce');
                        ?>
"><?php 
                        _e('Delete', 'fflcommerce');
                        ?>
</a>
				</td>
				</tr>
					<?php 
                    }
                }
                ?>
			<script type="text/javascript">

			jQuery('.couponDisplay').hide();

			/* <![CDATA[ */
			jQuery(function() {
				function toggle_coupons() {
					jQuery('a.toggleCoupon').click(function(e) {
						e.preventDefault();
						jQuery(this).text(jQuery(this).text() == '<?php 
                _e('Show', 'fflcommerce');
                ?>
' ? '<?php 
                _e('Hide', 'fflcommerce');
                ?>
' : '<?php 
                _e('Show', 'fflcommerce');
                ?>
');

						var id = jQuery(this).attr('href').substr(1);
						jQuery('#' + id).toggle('slow');
					});
				}

				toggle_coupons();

				jQuery('#add_coupon').live('click', function(e){
					e.preventDefault();
					var size = jQuery('.couponDisplay').size();
					var new_coupon = '\
					<table class="coupon-table form-table" id="coupons_table_' + size + '">\
					<tbody class="couponDisplay" id="coupons_rows_[' + size + ']">\
						<tr>\
							<th scope="row">\
								<a href="#" tip="<?php 
                _e('The coupon code a customer enters on the cart or checkout page.', 'fflcommerce');
                ?>
"\
								class="tips" tabindex="99"></a>\
								<label for="coupon_code[' + size + ']"><?php 
                _e('Code', 'fflcommerce');
                ?>
</label>\
							</th>\
							<td>\
								<input name="coupon_code[' + size + ']" id="coupon_code[' + size + ']" type="text" class="regular-text coupon_code"\
								style="width:150px;" placeholder="" value="" />\
								<br />\
								<small></small>\
							</td>\
						</tr>\
						<tr>\
							<th scope="row">\
								<a href="#" tip="<?php 
                _e('Cart - Applies to whole cart<br/>Product - Applies to individual products only. You must specify individual products.', 'fflcommerce');
                ?>
"\
								class="tips" tabindex="99"></a>\
								<label for="coupon_type[' + size + ']"><?php 
                _e('Type', 'fflcommerce');
                ?>
</label>\
							</th>\
							<td>\
								<select name="coupon_type[' + size + ']" id="coupon_type[' + size + ']" style="width:150px;">\
									<option value="fixed_cart"><?php 
                _e('Cart Discount', 'fflcommerce');
                ?>
</option>\
									<option value="percent"><?php 
                _e('Cart % Discount', 'fflcommerce');
                ?>
</option>\
									<option value="fixed_product"><?php 
                _e('Product Discount', 'fflcommerce');
                ?>
</option>\
									<option value="percent_product"><?php 
                _e('Product % Discount', 'fflcommerce');
                ?>
</option>\
									</select>\
								<br />\
								<small></small>\
							</td>\
						</tr>\
						<tr>\
							<th scope="row">\
								<a href="#" tip="<?php 
                _e('Amount this coupon is worth. If it is a percentange, just include the number without the percentage sign.', 'fflcommerce');
                ?>
"\
								class="tips" tabindex="99"></a>\
								<label for="coupon_amount[' + size + ']"><?php 
                _e('Amount', 'fflcommerce');
                ?>
</label>\
							</th>\
							<td>\
								<input name="coupon_amount[' + size + ']" id="coupon_amount[' + size + ']" type="number" min="0"\
								max="" class="regular-text " style="width:60px;" value=""\
								/>\
								<br />\
								<small></small>\
							</td>\
						</tr>\
						<tr>\
							<th scope="row">\
								<a href="#" tip="<?php 
                _e('Control how many times this coupon may be used.', 'fflcommerce');
                ?>
" class="tips"\
								tabindex="99"></a>\
								<label for="usage_limit[' + size + ']"><?php 
                _e('Usage limit', 'fflcommerce');
                ?>
</label>\
							</th>\
							<td>\
								<input name="usage_limit[' + size + ']" id="usage_limit[' + size + ']" type="number" min="0"\
								max="" class="regular-text " style="width:60px;" placeholder="<?php 
                _e('No limit', 'fflcommerce');
                ?>
"\
								value="" />\
							</td>\
						</tr>\
						<tr>\
							<th scope="row">\
								<a href="#" tip="<?php 
                _e('Set the required subtotal for this coupon to be valid on an order.', 'fflcommerce');
                ?>
"\
								class="tips" tabindex="99"></a>\
								<label for="order_total_min[' + size + ']"><?php 
                _e('Order subtotal', 'fflcommerce');
                ?>
</label>\
							</th>\
							<td>\
								<input name="order_total_min[' + size + ']" id="order_total_min[' + size + ']" type="number"\
								min="0" max="" class="regular-text " style="width:60px;" placeholder="<?php 
                _e('No min', 'fflcommerce');
                ?>
"\
								value="" /><?php 
                _e('Min', 'fflcommerce');
                ?>
</td>\
						</tr>\
						<tr>\
							<th scope="row" style="padding-top:0px;"></th>\
							<td style="padding-top:0px;">\
								<input name="order_total_max[' + size + ']" id="order_total_max[' + size + ']" type="number"\
								min="0" max="" class="regular-text " style="width:60px;" placeholder="<?php 
                _e('No max', 'fflcommerce');
                ?>
"\
								value="" /><?php 
                _e('Max', 'fflcommerce');
                ?>
</td>\
						</tr>\
						<tr>\
							<th scope="row">\
								<a href="#" tip="<?php 
                _e('Which payment methods are allowed for this coupon to be effective?', 'fflcommerce');
                ?>
"\
								class="tips" tabindex="99"></a>\
								<label for="coupon_pay_methods[' + size + '][]"><?php 
                _e('Payment methods', 'fflcommerce');
                ?>
</label>\
							</th>\
							<td>\
								<select name="coupon_pay_methods[' + size + '][]" id="coupon_pay_methods[' + size + '][]" style="width:200px;"\
								class="chzn-select" multiple="multiple">\
									<?php 
                foreach ($payment_methods as $id => $label) {
                    echo '<option value="' . $id . '">' . $label . '</option>';
                }
                ?>
\
								</select>\
								<br />\
								<small></small>\
							</td>\
						</tr>\
						<tr>\
							<th scope="row">\
								<a href="#" tip="<?php 
                _e('Control which products this coupon can apply to.', 'fflcommerce');
                ?>
" class="tips"\
								tabindex="99"></a>\
								<label for="product_ids_' + size + '"><?php 
                _e('Products', 'fflcommerce');
                ?>
</label>\
							</th>\
							<td>\
								<select id="product_ids_' + size + '" style="width:200px;" name="product_ids[' + size + '][]"\
								style="width:100px" class="ajax_chosen_select_products_and_variations"\
								multiple="multiple" data-placeholder="<?php 
                _e('Any product', 'fflcommerce');
                ?>
"></select><?php 
                _e('Include', 'fflcommerce');
                ?>
</td>\
						</tr>\
						<tr>\
							<th scope="row"></th>\
							<td style="padding-top:0px;">\
								<select id="exclude_product_ids_' + size + '" style="width:200px;" name="exclude_product_ids[' + size + '][]"\
								style="width:100px" class="ajax_chosen_select_products_and_variations"\
								multiple="multiple" data-placeholder="<?php 
                _e('Any product', 'fflcommerce');
                ?>
"></select><?php 
                _e('Exclude', 'fflcommerce');
                ?>
</td>\
						</tr>\
						<tr>\
							<th scope="row">\
								<a href="#" tip="<?php 
                _e('Control which categories this coupon can apply to.', 'fflcommerce');
                ?>
" class="tips"\
								tabindex="99"></a>\
								<label for="coupon_category[' + size + '][]"><?php 
                _e('Categories', 'fflcommerce');
                ?>
</label>\
							</th>\
							<td>\
								<select name="coupon_category[' + size + '][]" id="coupon_category_' + size + '" style="width:200px;"\
								class="chzn-select" multiple="multiple">\
								   <?php 
                $categories = get_terms('product_cat', array('hide_empty' => false));
                foreach ($categories as $category) {
                    echo '<option value="' . $category->term_id . '">' . $category->name . '</option>';
                }
                ?>
\
								</select><?php 
                _e('Include', 'fflcommerce');
                ?>
</td>\
						</tr>\
						<tr>\
							<th scope="row">\
								<label for="exclude_categories[' + size + '][]"></label>\
							</th>\
							<td>\
								<select name="exclude_categories[' + size + '][]" id="exclude_categories_' + size + '" style="width:200px;"\
								class="chzn-select" multiple="multiple">\
									<?php 
                $categories = get_terms('product_cat', array('hide_empty' => false));
                foreach ($categories as $category) {
                    echo '<option value="' . $category->term_id . '">' . $category->name . '</option>';
                }
                ?>
\
								</select><?php 
                _e('Exclude', 'fflcommerce');
                ?>
</td>\
						</tr>\
						<tr>\
							<th scope="row">\
								<a href="#" tip="<?php 
                _e('Choose between which dates this coupon is enabled.', 'fflcommerce');
                ?>
" class="tips"\
								tabindex="99"></a>\
								<label for="coupon_date_from[' + size + ']"><?php 
                _e('Dates allowed', 'fflcommerce');
                ?>
</label>\
							</th>\
							<td>\
								<input name="coupon_date_from[' + size + ']" id="coupon_date_from[' + size + ']" type="text"\
								class="regular-text date-pick" style="width:150px;" placeholder="<?php 
                _e('Any date', 'fflcommerce');
                ?>
"\
								value="" /><?php 
                _e('From', 'fflcommerce');
                ?>
</td>\
						</tr>\
						<tr>\
							<th scope="row" style="padding-top:0px;"></th>\
							<td style="padding-top:0px;">\
								<input name="coupon_date_to[' + size + ']" id="coupon_date_to[' + size + ']" type="text" class="regular-text date-pick"\
								style="width:150px;" placeholder="<?php 
                _e('Any date', 'fflcommerce');
                ?>
" value="" /><?php 
                _e('To', 'fflcommerce');
                ?>
</td>\
						</tr>\
						<tr>\
							<th scope="row">\
								<a href="#" tip="<?php 
                _e('Prevent other coupons from being used while this one is applied to a cart.', 'fflcommerce');
                ?>
"\
								class="tips" tabindex="99"></a>\
								<label for="individual[' + size + ']"><?php 
                _e('Misc. settings', 'fflcommerce');
                ?>
</label>\
							</th>\
							<td>\
								<input id="individual[' + size + ']" type="checkbox" class="fflcommerce-input fflcommerce-checkbox "\
								style="" name="individual[' + size + ']" />\
								<label for="individual[' + size + ']"><?php 
                _e('Prevent other coupons', 'fflcommerce');
                ?>
</label>\
							</td>\
						</tr>\
						<tr>\
							<th scope="row" style="padding-top:0px;">\
								<a href="#" tip="<?php 
                _e('Show the Free Shipping method on checkout with this enabled.', 'fflcommerce');
                ?>
"\
								class="tips" tabindex="99"></a>\
							</th>\
							<td style="padding-top:0px;">\
								<input id="coupon_free_shipping[' + size + ']" type="checkbox" class="fflcommerce-input fflcommerce-checkbox "\
								style="" name="coupon_free_shipping[' + size + ']" />\
								<label for="coupon_free_shipping[' + size + ']"><?php 
                _e('Free shipping', 'fflcommerce');
                ?>
</label>\
							</td>\
						</tr>\
					</tbody>\
					</table>\
					';
					/* Add the table */
					jQuery('.coupons.table').before(new_coupon);
					jQuery('#coupons_table_' + size).hide().fadeIn('slow');

					jQuery("select#product_ids_" + size).ajaxChosen({
						method: 	'GET',
						url: 		'<?php 
                echo !is_ssl() ? str_replace('https', 'http', admin_url('admin-ajax.php')) : admin_url('admin-ajax.php');
                ?>
',
						dataType: 	'json',
						afterTypeDelay: 100,
						data:		{
							action: 		'fflcommerce_json_search_products_and_variations',
							security: 		'<?php 
                echo wp_create_nonce("search-products");
                ?>
'
						}
					}, function (data) {

						var terms = {};

						jQuery.each(data, function (i, val) {
							terms[i] = val;
						});

						return terms;
					});
					jQuery("select#exclude_product_ids_" + size).ajaxChosen({
						method: 	'GET',
						url: 		'<?php 
                echo !is_ssl() ? str_replace('https', 'http', admin_url('admin-ajax.php')) : admin_url('admin-ajax.php');
                ?>
',
						dataType: 	'json',
						afterTypeDelay: 100,
						data:		{
							action: 		'fflcommerce_json_search_products_and_variations',
							security: 		'<?php 
                echo wp_create_nonce("search-products");
                ?>
'
						}
					}, function (data) {

						var terms = {};

						jQuery.each(data, function (i, val) {
							terms[i] = val;
						});

						return terms;
					});
					jQuery('a[href="#coupons_rows_'+size+'"]').click(function(e) {
						e.preventDefault();
						jQuery('#coupons_rows_'+size).toggle('slow', function() {
							// Stuff later?
						});
					});
					jQuery(".chzn-select").chosen();
					jQuery(".tips").tooltip();
					jQuery('.date-pick').datepicker( {dateFormat: 'yy-mm-dd', gotoCurrent: true} );
					return false;
				});
				jQuery('a.remove_coupon').live('click', function(){
					var answer = confirm("<?php 
                _e('Delete this coupon?', 'fflcommerce');
                ?>
")
					if (answer) {
						jQuery('input', jQuery(this).parent().parent().children()).val('');
						jQuery(this).parent().parent().fadeOut();
					}
					return false;
				});
			});
		/* ]]> */
		</script>
						<?php 
                break;
            case 'tax_rates':
                $_tax = new fflcommerce_tax();
                $tax_classes = $_tax->get_tax_classes();
                $tax_rates = get_option('fflcommerce_tax_rates');
                $applied_all_states = array();
                ?>
<tr>
					<th><?php 
                if ($value['tip']) {
                    ?>
<a href="#" tip="<?php 
                    echo $value['tip'];
                    ?>
" class="tips" tabindex="99"></a><?php 
                }
                ?>
<label><?php 
                echo $value['name'];
                ?>
</label></th>
					<td id="tax_rates">
						<div class="taxrows">
			<?php 
                $i = -1;
                if ($tax_rates && is_array($tax_rates) && sizeof($tax_rates) > 0) {
                    function array_find($needle, $haystack)
                    {
                        foreach ($haystack as $key => $val) {
                            if ($needle == array("label" => $val['label'], "compound" => $val['compound'], 'rate' => $val['rate'], 'shipping' => $val['shipping'], 'is_all_states' => $val['is_all_states'], 'class' => $val['class'])) {
                                return $key;
                            }
                        }
                        return false;
                    }
                    function array_compare($tax_rates)
                    {
                        $after = array();
                        foreach ($tax_rates as $key => $val) {
                            $first_two = array("label" => $val['label'], "compound" => $val['compound'], 'rate' => $val['rate'], 'shipping' => $val['shipping'], 'is_all_states' => $val['is_all_states'], 'class' => $val['class']);
                            $found = array_find($first_two, $after);
                            if ($found !== false) {
                                $combined = $after[$found]["state"];
                                $combined2 = $after[$found]["country"];
                                $combined = !is_array($combined) ? array($combined) : $combined;
                                $combined2 = !is_array($combined2) ? array($combined2) : $combined2;
                                $after[$found] = array_merge($first_two, array("state" => array_merge($combined, array($val['state'])), "country" => array_merge($combined2, array($val['country']))));
                            } else {
                                $after = array_merge($after, array(array_merge($first_two, array("state" => $val['state'], "country" => $val['country']))));
                            }
                        }
                        return $after;
                    }
                    $tax_rates = array_compare($tax_rates);
                    foreach ($tax_rates as $rate) {
                        if ($rate['is_all_states'] && in_array(get_all_states_key($rate), $applied_all_states)) {
                            continue;
                        }
                        $i++;
                        // increment counter after check for all states having been applied
                        echo '<p class="taxrow">
					<select name="tax_classes[' . esc_attr($i) . ']" title="Tax Classes">
						<option value="*">' . __('Standard Rate', 'fflcommerce') . '</option>';
                        if ($tax_classes) {
                            foreach ($tax_classes as $class) {
                                echo '<option value="' . sanitize_title($class) . '"';
                                if ($rate['class'] == sanitize_title($class)) {
                                    echo 'selected="selected"';
                                }
                                echo '>' . $class . '</option>';
                            }
                        }
                        echo '</select>

					<input type="text"
						   class="text" value="' . esc_attr($rate['label']) . '"
						   name="tax_label[' . esc_attr($i) . ']"
						   title="' . __('Online Label', 'fflcommerce') . '"
						   placeholder="' . __('Online Label', 'fflcommerce') . '"
						   maxlength="15" />';
                        echo '<select name="tax_country[' . esc_attr($i) . '][]" title="Country" multiple="multiple" style="width:250px;">';
                        if ($rate['is_all_states']) {
                            if (is_array($applied_all_states) && !in_array(get_all_states_key($rate), $applied_all_states)) {
                                $applied_all_states[] = get_all_states_key($rate);
                                fflcommerce_countries::country_dropdown_options($rate['country'], '*');
                                //all-states
                            } else {
                                continue;
                            }
                        } else {
                            fflcommerce_countries::country_dropdown_options($rate['country'], $rate['state']);
                        }
                        echo '</select>

					<input type="text"
						   class="text"
						   value="' . esc_attr($rate['rate']) . '"
						   name="tax_rate[' . esc_attr($i) . ']"
						   title="' . __('Rate', 'fflcommerce') . '"
						   placeholder="' . __('Rate', 'fflcommerce') . '"
						   maxlength="8" />%

					<label><input type="checkbox" name="tax_shipping[' . esc_attr($i) . ']" ';
                        if (isset($rate['shipping']) && $rate['shipping'] == 'yes') {
                            echo 'checked="checked"';
                        }
                        echo ' /> ' . __('Apply to shipping', 'fflcommerce') . '</label>

					<label><input type="checkbox" name="tax_compound[' . esc_attr($i) . ']" ';
                        if (isset($rate['compound']) && $rate['compound'] == 'yes') {
                            echo 'checked="checked"';
                        }
                        echo ' /> ' . __('Compound', 'fflcommerce') . '</label>

					<a href="#" class="remove button">&times;</a></p>';
                    }
                }
                ?>
						</div>
						<p><a href="#" class="add button"><?php 
                _e('+ Add Tax Rule', 'fflcommerce');
                ?>
</a></p>
					</td>
				</tr>
				<script type="text/javascript">
					/* <![CDATA[ */
					jQuery(function() {
						jQuery('#tax_rates a.add').live('click', function(){
							var size = jQuery('.taxrows .taxrow').size();

							// Add the row
							jQuery('<p class="taxrow"> \
								<select name="tax_classes[' + size + ']" title="Tax Classes"> \
									<option value="*"><?php 
                _e('Standard Rate', 'fflcommerce');
                ?>
</option><?php 
                $tax_classes = $_tax->get_tax_classes();
                if ($tax_classes) {
                    foreach ($tax_classes as $class) {
                        echo '<option value="' . sanitize_title($class) . '">' . $class . '</option>';
                    }
                }
                ?>
</select><input type="text" class="text" name="tax_label[' + size + ']" title="<?php 
                _e('Online Label', 'fflcommerce');
                ?>
" placeholder="<?php 
                _e('Online Label', 'fflcommerce');
                ?>
" maxlength="15" />\
									</select><select name="tax_country[' + size + '][]" title="Country" multiple="multiple"><?php 
                fflcommerce_countries::country_dropdown_options('', '', true);
                ?>
</select><input type="text" class="text" name="tax_rate[' + size + ']" title="<?php 
                _e('Rate', 'fflcommerce');
                ?>
" placeholder="<?php 
                _e('Rate', 'fflcommerce');
                ?>
" maxlength="8" />%\
									<label><input type="checkbox" name="tax_shipping[' + size + ']" /> <?php 
                _e('Apply to shipping', 'fflcommerce');
                ?>
</label>\
									<label><input type="checkbox" name="tax_compound[' + size + ']" /> <?php 
                _e('Compound', 'fflcommerce');
                ?>
</label><a href="#" class="remove button">&times;</a>\
							</p>').appendTo('#tax_rates div.taxrows');
												return false;
											});
											jQuery('#tax_rates a.remove').live('click', function(){
												var answer = confirm("<?php 
                _e('Delete this rule?', 'fflcommerce');
                ?>
");
												if (answer) {
													jQuery('input', jQuery(this).parent()).val('');
													jQuery(this).parent().hide();
												}
												return false;
											});
										});
										/* ]]> */
				</script>
			<?php 
                break;
            case "shipping_options":
                foreach (fflcommerce_shipping::get_all_methods() as $method) {
                    $method->admin_options();
                }
                break;
            case "gateway_options":
                foreach (fflcommerce_payment_gateways::payment_gateways() as $gateway) {
                    $gateway->admin_options();
                }
                break;
        }
    }
}
Пример #24
0
function test_array_compare()
{
    $test_cases = array(array('a' => array('a', 'b', 'c'), 'b' => array('a', 'b', 'c'), 'res' => true), array('a' => array('a', 'b'), 'b' => array('a', 'b', 'c'), 'res' => false), array('a' => array('a', 'b', 'c'), 'b' => array('a', 'b'), 'res' => false), array('a' => 'a', 'b' => array('a', 'b', 'c'), 'res' => false));
    assert_options(ASSERT_ACTIVE, 1);
    assert_options(ASSERT_WARNING, 0);
    assert_options(ASSERT_QUIET_EVAL, 1);
    // Create a handler function
    function my_assert_handler($file, $line, $code)
    {
        print "Assertion Failed: file({$file}) line({$line}) code(test_array_compare)" . PHP_EOL;
    }
    assert_options(ASSERT_CALLBACK, 'my_assert_handler');
    assert($test_arr == $test_arr_result);
    foreach ($test_cases as $test_case) {
        $res = array_compare($test_case['a'], $test_case['b']);
        assert($res == $test_case['res']);
    }
}
 /**
  * UPDATE /api/exerciseEntries/{exerciseEntries}
  * @param Request $request
  * @param Entry $entry
  * @return Response
  */
 public function update(Request $request, Entry $entry)
 {
     // Create an array with the new fields merged
     $data = array_compare($entry->toArray(), $request->only(['quantity']));
     $entry->update($data);
     $entry = $this->transform($this->createItem($entry, new ExerciseEntryTransformer()))['data'];
     return response($entry, Response::HTTP_OK);
 }
Пример #26
0
 /** public function get_extra_info
  *		Returns the extra info for the game
  *
  * @param void
  * @return array extra game info
  */
 public function get_extra_info()
 {
     call(__METHOD__);
     $diff = array_compare($this->_extra_info, self::$EXTRA_INFO_DEFAULTS);
     $extra_info = $diff[0];
     ksort($extra_info);
     return $extra_info;
 }
Пример #27
0
 /**
  *
  * @param Request $request
  * @param Item $item
  * @return Response
  */
 public function update(Request $request, Item $item)
 {
     if ($request->has('updatingNextTimeForRecurringItem')) {
         $item = $this->itemsRepository->updateNextTimeForRecurringItem($item);
     } else {
         $data = array_compare($item->toArray(), $request->only(['priority', 'urgency', 'title', 'body', 'favourite', 'pinned', 'alarm', 'not_before', 'recurring_unit', 'recurring_frequency']));
         //So the recurring unit can be removed
         if ($request->get('recurring_unit') === 'none') {
             $data['recurring_unit'] = null;
         }
         //So the not before time can be removed
         if ($request->exists('not_before') && !$request->get('not_before')) {
             $data['not_before'] = null;
         }
         //So the recurring frequency can be removed
         if ($request->get('recurring_frequency') === '') {
             $data['recurring_frequency'] = null;
         }
         //So the alarm of an item can be removed
         if ($request->has('alarm') && !$request->get('alarm')) {
             $data['alarm'] = null;
         }
         //So the urgency of an item can be removed
         if ($request->has('urgency') && !$request->get('urgency')) {
             $data['urgency'] = null;
         }
         $item->update($data);
         if ($request->has('parent_id')) {
             //So the parent_id can be removed (so the item moves to the top-most level, home)
             if ($request->get('parent_id') === 'none') {
                 $item->parent()->dissociate();
             } else {
                 $item->parent()->associate(Item::findOrFail($request->get('parent_id')));
             }
             $item->save();
         }
         if ($request->has('category_id')) {
             $item->category()->associate(Category::findOrFail($request->get('category_id')));
             $item->save();
         }
         if ($request->has('moveItem')) {
             $this->itemsRepository->moveItem($request, $item);
         }
     }
     $item = $this->transform($this->createItem($item, new ItemTransformer()))['data'];
     return response($item, Response::HTTP_OK);
 }