<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>resources/script/jquery.min.js</filename>
    </added>
    <added>
      <filename>scripts/crafting/list.php</filename>
    </added>
    <added>
      <filename>scripts/crafting/recipe.php</filename>
    </added>
    <added>
      <filename>template/templates/crafting/details.tpl</filename>
    </added>
    <added>
      <filename>template/templates/crafting/list.tpl</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -2,7 +2,7 @@
 # SetEnv RELEASE_MODE DEV
 
 RewriteEngine On
-RewriteBase /kittokittokitto
+RewriteBase /kitto
 
 # These are the real folders.
 RewriteRule ^resources/(.*)$ resources/$1 [L]
@@ -18,6 +18,7 @@ RewriteRule ^notice/([0-9]+) index.php?page_slug=notice&amp;state=jump&amp;notification_
 # Pagination for /items/ - /items is still handled by the catch-all, etc.
 RewriteRule ^items/([0-9]+) index.php?page_slug=items&amp;page=$1 [NC,L]
 RewriteRule ^news/([0-9]+) index.php?page_slug=news&amp;page=$1 [NC,L]
+RewriteRule ^crafting/([0-9]+) index.php?page_slug=crafting&amp;page=$1 [NC,L]
 
 # Messages - first pagination. Then we have two URLs mapped to our write-new
 # slug - /write-new-message/ and /write-message-reply/. -new accepts a user ID,
@@ -37,5 +38,8 @@ RewriteRule ^edit-thread/([0-9]+)(/([0-9]+))? index.php?page_slug=edit-thread&amp;th
 # Search page rules.
 RewriteRule ^search/([a-z0-9]+)(((/([^/]+))(/(exact|contains)?)(/([0-9])+)?))? index.php?page_slug=search&amp;state=search&amp;search=$1&amp;term=$5&amp;page=$9&amp;precision=$7 [NC,L]
 
+# Craft things.
+RewriteRule ^craft/([0-9]+) index.php?page_slug=craft&amp;id=$1 [NC,L]
+
 # Gotta catch 'em all! Don't put any rules below this one.
 RewriteRule ^([A-Z0-9-]+)(/(.*))?$ index.php?page_slug=$1 [QSA,NC,L]</diff>
      <filename>.htaccess</filename>
    </modified>
    <modified>
      <diff>@@ -52,6 +52,16 @@ class ItemType extends ActiveTable
         ),
     );
 
+    public function hasMaterials()
+    {
+        if($this-&gt;getItemClassId() == 4)
+        {
+            return true;
+        }
+
+        return false;
+    } // end hasMaterials
+
     /**
      * Return the full URL to the item's image.
      * </diff>
      <filename>includes/classes/item/item_type.class.php</filename>
    </modified>
    <modified>
      <diff>@@ -74,6 +74,67 @@ class Recipe_Item extends Item
         ),
     );
 
+    /**
+    * An efficient bill of materials vs inventory check.
+    *
+    * This will return how many batches the user can produce.
+    * 
+    * @return integer 
+    **/
+    public function canCraft()
+    {
+       switch($this-&gt;db-&gt;phptype)
+       {
+           case 'mysqli':
+           case 'mysql':
+           {
+               $sql = '
+                   SELECT
+                       FLOOR(IFNULL(user_item.quantity,0) / item_recipe_material.material_quantity) AS batch_size
+                   FROM item_type
+                   INNER JOIN item_recipe_material ON (item_type.item_type_id = item_recipe_material.recipe_item_type_id)
+                   LEFT JOIN user_item ON (
+                       item_recipe_material.material_item_type_id = user_item.item_type_id 
+                       AND ? = user_item.user_id
+                   )
+                   WHERE item_type.item_type_id = ? 
+                   ORDER BY batch_size
+                   LIMIT 1
+               ';
+
+               break;
+           } // end mysql
+
+           default:
+           {
+               throw new ArgumentError('RDBMS unsupported.');
+
+               break;
+           } // end default
+       } // end db engine switch
+
+       $batch_size = $this-&gt;db-&gt;getOne($sql,array($this-&gt;getUserId(),$this-&gt;getItemTypeId()));
+       if(PEAR::isError($batch_size))
+       {
+           throw new SQLError($batch_size-&gt;getDebugInfo(),$batch_size-&gt;userinfo,10);
+       }
+
+       return $batch_size;
+    } // end canCraft 
+
+    public function grabProduct()
+    {
+       $item = new ItemType($this-&gt;db);
+       $item = $item-&gt;findOneByItemTypeId($this-&gt;getRecipeCreatedItemTypeId());
+
+       if($item == null)
+       {
+           throw new ArgumentError('Could not find product item - recipe buildout invalid!');
+       }
+
+       return $item;
+    } // end grabProduct
+
     public function listAttributes()
     {
         $TYPES = array(0 =&gt; 'Select one...');</diff>
      <filename>includes/classes/item/recipe_item.class.php</filename>
    </modified>
    <modified>
      <diff>@@ -366,12 +366,20 @@ class User extends ActiveTable
             ($start !== null &amp;&amp; $end !== null) == false
         )
         {
-            throw ArgumentError('Must specify either no arguments or both arguments.');
+            throw new ArgumentError('Must specify either no arguments or both arguments.');
         } // end problem w/ args.
         
-        $PROPER_INVENTORY = array();
-        $inventory = $this-&gt;grab('inventory','ORDER BY user_item_id',false,$start,$end);
+        $inventory = new Item($this-&gt;db);
+        $inventory = $inventory-&gt;findBy(array(
+            'user_id' =&gt; $this-&gt;getUserId(),
+            array(
+                'table' =&gt; 'item_class',
+                'column' =&gt; 'normal_inventory_display',
+                'value' =&gt; 'Y',
+            ),
+        ),'ORDER BY item_type.item_name',false,$start,$end); 
         
+        $PROPER_INVENTORY = array();
         foreach($inventory as $item)
         {
             $PROPER_INVENTORY[] = Item::factory($item-&gt;getUserItemId(),$this-&gt;db);
@@ -383,10 +391,54 @@ class User extends ActiveTable
     public function grabInventorySize()
     {
         $result = new Item($this-&gt;db);
-        $result = $result-&gt;findByUserId($this-&gt;getUserId(),null,true);
+        $result = $result-&gt;findBy(array(
+            'user_id' =&gt; $this-&gt;getUserId(),
+            array(
+                'table' =&gt; 'item_class',
+                'column' =&gt; 'normal_inventory_display',
+                'value' =&gt; 'Y',
+            ),
+        ),null,true);
         
         return $result;
     } // end grabInventorySize
+    
+    public function grabRecipes($start=null,$end=null)
+    {
+        if(($start === null &amp;&amp; $end === null) == false &amp;&amp; 
+            ($start !== null &amp;&amp; $end !== null) == false
+        )
+        {
+            throw new ArgumentError('Must specify either no arguments or both arguments.');
+        } // end problem w/ args.
+        
+        $inventory = new Recipe_Item($this-&gt;db);
+        $inventory = $inventory-&gt;findBy(array(
+            'user_id' =&gt; $this-&gt;getUserId(),
+            array(
+                'table' =&gt; 'item_class',
+                'column' =&gt; 'item_class_id',
+                'value' =&gt; 4,
+            ),
+        ),'ORDER BY item_type.item_name',false,$start,$end); 
+        
+        return $inventory;
+    } // end grabRecipies
+
+    public function grabRecipeSize()
+    {
+        $result = new Recipe_Item($this-&gt;db);
+        $result = $result-&gt;findBy(array(
+            'user_id' =&gt; $this-&gt;getUserId(),
+            array(
+                'table' =&gt; 'item_class',
+                'column' =&gt; 'item_class_id',
+                'value' =&gt; 4,
+            ),
+        ),null,true);
+        
+        return $result;
+    } // end grabRecipieSize
 
     /**
      * Add some money to the user. </diff>
      <filename>includes/classes/user/user.class.php</filename>
    </modified>
    <modified>
      <diff>@@ -374,3 +374,17 @@ h3 {
     display: inline;
     padding-left: 1em;
 }
+
+.page-subnav {
+    text-align: center;
+    font-size: 1.2em;
+}
+
+.recipe-desc {
+    vertical-align: top;
+}
+.recipe-name {
+    font-weight: bold;
+    margin: 0;
+    padding: 0;
+}</diff>
      <filename>resources/styles/style.css</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@
 &lt;script type='text/javascript'&gt;
 &lt;!--
     $(document).ready(function(){
-        var data = '/item-search-ajax';
+        var data = '{/literal}{$display_settings.public_dir}{literal}/item-search-ajax';
         $(&quot;#{/literal}{$id}{literal}&quot;).autocomplete(data,{
             max: 10,
             mustMatch: true,</diff>
      <filename>template/templates/_widgets/item_search.tpl</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,5 @@
+&lt;p class='page-subnav'&gt;Inventory | {kkkurl link_text='Crafting' slug='crafting'}&lt;/p&gt;
+
 {if $notice != ''}&lt;div id='item-notice' class='{$fat} notice-box'&gt;{$notice}&lt;/div&gt;{/if}
 {section name=item_index loop=$inventory}
 {assign var='item' value=$inventory[item_index]}</diff>
      <filename>template/templates/items/list.tpl</filename>
    </modified>
    <modified>
      <diff>@@ -15,6 +15,9 @@
         
         &lt;script type='text/javascript' src='{$display_settings.public_dir}/resources/script/fat.js'&gt;&lt;/script&gt;
         &lt;script type='text/javascript' src='{$display_settings.public_dir}/resources/script/yasashii.js'&gt;&lt;/script&gt;
+        &lt;script type='text/javascript' src='{$display_settings.public_dir}/resources/script/jquery.min.js'&gt;&lt;/script&gt;
+        &lt;script type='text/javascript' src='{$display_settings.public_dir}/resources/script/autocomplete/jquery.autocomplete.min.js'&gt;&lt;/script&gt;
+        &lt;link href=&quot;{$display_settings.public_dir}/resources/script/autocomplete/jquery.autocomplete.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
         
         {foreach from=$spry.js item=js_file}
         &lt;script type=&quot;text/javascript&quot; src=&quot;{$display_settings.public_dir}/resources/script/spry/widgets/{$js_file}&quot;&gt;&lt;/script&gt;</diff>
      <filename>template/templates/layout/deep/header.tpl</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>91c93b411fb7917b36d5b13249850804c0a8bdcb</id>
    </parent>
  </parents>
  <author>
    <name>Nicholas 'OwlManAtt' Evans</name>
    <email>owlmanatt@gmail.com</email>
  </author>
  <url>http://github.com/OwlManAtt/kittokittokitto/commit/6249d0a62ffa40b42489c45cb3ac72dfd776c442</url>
  <id>6249d0a62ffa40b42489c45cb3ac72dfd776c442</id>
  <committed-date>2009-07-13T14:51:01-07:00</committed-date>
  <authored-date>2009-07-13T14:43:23-07:00</authored-date>
  <message>Finished integrating crafting system.</message>
  <tree>432cc46c77e5b391268bddb60049ada6e1fbbd9c</tree>
  <committer>
    <name>Nicholas 'OwlManAtt' Evans</name>
    <email>owlmanatt@gmail.com</email>
  </committer>
</commit>
