feat(papers): update T9.26 price list, remove price/kg, add supplier filter and smart search modal
Browse filesFiles changed (10)
- data/papers_t9_26.jsonAdded+1877
- scripts/import_t9.pyAdded+98
- src/app/api/calculate/route.ts+10-4
- src/app/api/papers/route.ts+60-24
- src/app/page.tsx+75-17
- src/components/PaperManager.tsx+378-78
- src/components/PaperSelectorModal.tsxAdded+431
- src/lib/db.ts+50-1312
- src/lib/engine/costCalculator.ts+12-9
- src/types/index.ts+6-3
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877[ { "code": "I210_65x86_AF_Indo", "name": "Ivory 210gsm (65x86cm) - AF - Indo", "gsm": 210, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1068000.0, "price_below_500": 1086000.0, "price_per_ram": 1068000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu AF - Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I210_79x109_AF_Indo", "name": "Ivory 210gsm (79x109cm) - AF - Indo", "gsm": 210, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 1646000.0, "price_below_500": 1673000.0, "price_per_ram": 1646000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu AF - Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I230_65x86_AF_Indo", "name": "Ivory 230gsm (65x86cm) - AF - Indo", "gsm": 230, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1119000.0, "price_below_500": 1138000.0, "price_per_ram": 1119000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu AF - Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I230_79x109_AF_Indo", "name": "Ivory 230gsm (79x109cm) - AF - Indo", "gsm": 230, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 1723000.0, "price_below_500": 1753000.0, "price_per_ram": 1723000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu AF - Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I250_65x86_AF_Indo", "name": "Ivory 250gsm (65x86cm) - AF - Indo", "gsm": 250, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1216000.0, "price_below_500": 1237000.0, "price_per_ram": 1216000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu AF - Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I250_79x109_AF_Indo", "name": "Ivory 250gsm (79x109cm) - AF - Indo", "gsm": 250, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 1873000.0, "price_below_500": 1905000.0, "price_per_ram": 1873000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu AF - Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I270_65x86_AF_Indo", "name": "Ivory 270gsm (65x86cm) - AF - Indo", "gsm": 270, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1313000.0, "price_below_500": 1336000.0, "price_per_ram": 1313000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu AF - Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I270_79x109_AF_Indo", "name": "Ivory 270gsm (79x109cm) - AF - Indo", "gsm": 270, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 2023000.0, "price_below_500": 2058000.0, "price_per_ram": 2023000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu AF - Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I300_65x86_AF_Indo", "name": "Ivory 300gsm (65x86cm) - AF - Indo", "gsm": 300, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1459000.0, "price_below_500": 1484000.0, "price_per_ram": 1459000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu AF - Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I300_79x109_AF_Indo", "name": "Ivory 300gsm (79x109cm) - AF - Indo", "gsm": 300, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 2247000.0, "price_below_500": 2286000.0, "price_per_ram": 2247000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu AF - Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I350_65x86_AF_Indo", "name": "Ivory 350gsm (65x86cm) - AF - Indo", "gsm": 350, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1702000.0, "price_below_500": 1732000.0, "price_per_ram": 1702000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu AF - Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I350_79x109_AF_Indo", "name": "Ivory 350gsm (79x109cm) - AF - Indo", "gsm": 350, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 2622000.0, "price_below_500": 2667000.0, "price_per_ram": 2622000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu AF - Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I400_65x86_AF_Indo", "name": "Ivory 400gsm (65x86cm) - AF - Indo", "gsm": 400, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1945000.0, "price_below_500": 1979000.0, "price_per_ram": 1945000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu AF - Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I400_79x109_AF_Indo", "name": "Ivory 400gsm (79x109cm) - AF - Indo", "gsm": 400, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 2997000.0, "price_below_500": 3048000.0, "price_per_ram": 2997000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu AF - Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I210_65x86_NingboTQ", "name": "Ivory 210gsm (65x86cm) - Ningbo TQ", "gsm": 210, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1162000.0, "price_below_500": 1180000.0, "price_per_ram": 1162000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Ningbo TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I210_79x109_NingboTQ", "name": "Ivory 210gsm (79x109cm) - Ningbo TQ", "gsm": 210, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 1790000.0, "price_below_500": 1817000.0, "price_per_ram": 1790000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Ningbo TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I230_65x86_NingboTQ", "name": "Ivory 230gsm (65x86cm) - Ningbo TQ", "gsm": 230, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1157000.0, "price_below_500": 1176000.0, "price_per_ram": 1157000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Ningbo TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I230_79x109_NingboTQ", "name": "Ivory 230gsm (79x109cm) - Ningbo TQ", "gsm": 230, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 1782000.0, "price_below_500": 1812000.0, "price_per_ram": 1782000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Ningbo TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I250_65x86_NingboTQ", "name": "Ivory 250gsm (65x86cm) - Ningbo TQ", "gsm": 250, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1258000.0, "price_below_500": 1279000.0, "price_per_ram": 1258000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Ningbo TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I250_79x109_NingboTQ", "name": "Ivory 250gsm (79x109cm) - Ningbo TQ", "gsm": 250, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 1937000.0, "price_below_500": 1970000.0, "price_per_ram": 1937000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Ningbo TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I270_65x86_NingboTQ", "name": "Ivory 270gsm (65x86cm) - Ningbo TQ", "gsm": 270, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1358000.0, "price_below_500": 1381000.0, "price_per_ram": 1358000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Ningbo TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I270_79x109_NingboTQ", "name": "Ivory 270gsm (79x109cm) - Ningbo TQ", "gsm": 270, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 2092000.0, "price_below_500": 2127000.0, "price_per_ram": 2092000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Ningbo TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I300_65x86_NingboTQ", "name": "Ivory 300gsm (65x86cm) - Ningbo TQ", "gsm": 300, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1509000.0, "price_below_500": 1534000.0, "price_per_ram": 1509000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Ningbo TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I300_79x109_NingboTQ", "name": "Ivory 300gsm (79x109cm) - Ningbo TQ", "gsm": 300, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 2325000.0, "price_below_500": 2364000.0, "price_per_ram": 2325000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Ningbo TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I350_65x86_NingboTQ", "name": "Ivory 350gsm (65x86cm) - Ningbo TQ", "gsm": 350, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1761000.0, "price_below_500": 1790000.0, "price_per_ram": 1761000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Ningbo TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I350_79x109_NingboTQ", "name": "Ivory 350gsm (79x109cm) - Ningbo TQ", "gsm": 350, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 2712000.0, "price_below_500": 2758000.0, "price_per_ram": 2712000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Ningbo TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I400_65x86_NingboTQ", "name": "Ivory 400gsm (65x86cm) - Ningbo TQ", "gsm": 400, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 2012000.0, "price_below_500": 2046000.0, "price_per_ram": 2012000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Ningbo TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I400_79x109_NingboTQ", "name": "Ivory 400gsm (79x109cm) - Ningbo TQ", "gsm": 400, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 3100000.0, "price_below_500": 3152000.0, "price_per_ram": 3100000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Ningbo TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I300_65x86_IPSUN_TQ", "name": "Ivory 300gsm (65x86cm) - IP SUN - TQ", "gsm": 300, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1425000.0, "price_below_500": 1451000.0, "price_per_ram": 1425000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IP SUN - TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "I350_65x86_IPSUN_TQ", "name": "Ivory 350gsm (65x86cm) - IP SUN - TQ", "gsm": 350, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1663000.0, "price_below_500": 1692000.0, "price_per_ram": 1663000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IP SUN - TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C80_60x84_Nevia_baobì", "name": "Couche 80gsm (60x84cm) - Nevia - bao bì", "gsm": 80, "parent_width_cm": 60, "parent_height_cm": 84, "price_above_500": 494000.0, "price_below_500": 500000.0, "price_per_ram": 494000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Nevia - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C80_65x86_Nevia_baobì", "name": "Couche 80gsm (65x86cm) - Nevia - bao bì", "gsm": 80, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 548000.0, "price_below_500": 555000.0, "price_per_ram": 548000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Nevia - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C80_79x109_Nevia_baobì", "name": "Couche 80gsm (79x109cm) - Nevia - bao bì", "gsm": 80, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 844000.0, "price_below_500": 854000.0, "price_per_ram": 844000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Nevia - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C100_60x84_Hainan_baobì", "name": "Couche 100gsm (60x84cm) - Hainan - bao bì", "gsm": 100, "parent_width_cm": 60, "parent_height_cm": 84, "price_above_500": 542000.0, "price_below_500": 549000.0, "price_per_ram": 542000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C100_65x86_Hainan_baobì", "name": "Couche 100gsm (65x86cm) - Hainan - bao bì", "gsm": 100, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 601000.0, "price_below_500": 609000.0, "price_per_ram": 601000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C100_79x109_Hainan_baobì", "name": "Couche 100gsm (79x109cm) - Hainan - bao bì", "gsm": 100, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 926000.0, "price_below_500": 939000.0, "price_per_ram": 926000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C115_60x84_Hainan_baobì", "name": "Couche 115gsm (60x84cm) - Hainan - bao bì", "gsm": 115, "parent_width_cm": 60, "parent_height_cm": 84, "price_above_500": 623000.0, "price_below_500": 632000.0, "price_per_ram": 623000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C115_65x86_Hainan_baobì", "name": "Couche 115gsm (65x86cm) - Hainan - bao bì", "gsm": 115, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 691000.0, "price_below_500": 701000.0, "price_per_ram": 691000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C115_79x109_Hainan_baobì", "name": "Couche 115gsm (79x109cm) - Hainan - bao bì", "gsm": 115, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 1065000.0, "price_below_500": 1079000.0, "price_per_ram": 1065000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C120_60x84_Hainan_baobì", "name": "Couche 120gsm (60x84cm) - Hainan - bao bì", "gsm": 120, "parent_width_cm": 60, "parent_height_cm": 84, "price_above_500": 650000.0, "price_below_500": 659000.0, "price_per_ram": 650000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C120_65x86_Hainan_baobì", "name": "Couche 120gsm (65x86cm) - Hainan - bao bì", "gsm": 120, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 721000.0, "price_below_500": 731000.0, "price_per_ram": 721000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C120_79x109_Hainan_baobì", "name": "Couche 120gsm (79x109cm) - Hainan - bao bì", "gsm": 120, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 1111000.0, "price_below_500": 1126000.0, "price_per_ram": 1111000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C140_60x84_Hainan_baobì", "name": "Couche 140gsm (60x84cm) - Hainan - bao bì", "gsm": 140, "parent_width_cm": 60, "parent_height_cm": 84, "price_above_500": 759000.0, "price_below_500": 769000.0, "price_per_ram": 759000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C140_65x86_Hainan_baobì", "name": "Couche 140gsm (65x86cm) - Hainan - bao bì", "gsm": 140, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 841000.0, "price_below_500": 853000.0, "price_per_ram": 841000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C140_79x109_Hainan_baobì", "name": "Couche 140gsm (79x109cm) - Hainan - bao bì", "gsm": 140, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 1296000.0, "price_below_500": 1314000.0, "price_per_ram": 1296000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C148_60x84_Hainan_baobì", "name": "Couche 148gsm (60x84cm) - Hainan - bao bì", "gsm": 148, "parent_width_cm": 60, "parent_height_cm": 84, "price_above_500": 802000.0, "price_below_500": 813000.0, "price_per_ram": 802000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C148_65x86_Hainan_baobì", "name": "Couche 148gsm (65x86cm) - Hainan - bao bì", "gsm": 148, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 889000.0, "price_below_500": 902000.0, "price_per_ram": 889000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C148_79x109_Hainan_baobì", "name": "Couche 148gsm (79x109cm) - Hainan - bao bì", "gsm": 148, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 1370000.0, "price_below_500": 1389000.0, "price_per_ram": 1370000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C170_65x86_Hainan_baobì", "name": "Couche 170gsm (65x86cm) - Hainan - bao bì", "gsm": 170, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1022000.0, "price_below_500": 1036000.0, "price_per_ram": 1022000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C170_79x109_Hainan_baobì", "name": "Couche 170gsm (79x109cm) - Hainan - bao bì", "gsm": 170, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 1574000.0, "price_below_500": 1596000.0, "price_per_ram": 1574000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C200_65x86_Hainan_baobì", "name": "Couche 200gsm (65x86cm) - Hainan - bao bì", "gsm": 200, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1202000.0, "price_below_500": 1219000.0, "price_per_ram": 1202000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C200_79x109_Hainan_baobì", "name": "Couche 200gsm (79x109cm) - Hainan - bao bì", "gsm": 200, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 1851000.0, "price_below_500": 1877000.0, "price_per_ram": 1851000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C230_65x86_Hainan_baobì", "name": "Couche 230gsm (65x86cm) - Hainan - bao bì", "gsm": 230, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1382000.0, "price_below_500": 1401000.0, "price_per_ram": 1382000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C230_79x109_Hainan_baobì", "name": "Couche 230gsm (79x109cm) - Hainan - bao bì", "gsm": 230, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 2129000.0, "price_below_500": 2159000.0, "price_per_ram": 2129000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C250_65x86_Hainan_baobì", "name": "Couche 250gsm (65x86cm) - Hainan - bao bì", "gsm": 250, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1502000.0, "price_below_500": 1523000.0, "price_per_ram": 1502000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C250_79x109_Hainan_baobì", "name": "Couche 250gsm (79x109cm) - Hainan - bao bì", "gsm": 250, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 2314000.0, "price_below_500": 2346000.0, "price_per_ram": 2314000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C300_65x86_Hainan_baobì", "name": "Couche 300gsm (65x86cm) - Hainan - bao bì", "gsm": 300, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1803000.0, "price_below_500": 1828000.0, "price_per_ram": 1803000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C300_79x109_Hainan_baobì", "name": "Couche 300gsm (79x109cm) - Hainan - bao bì", "gsm": 300, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 2777000.0, "price_below_500": 2816000.0, "price_per_ram": 2777000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "C350_65x86_Hainan_baobì", "name": "Couche 350gsm (65x86cm) - Hainan - bao bì", "gsm": 350, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 2211000.0, "price_below_500": 2240000.0, "price_per_ram": 2211000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Hainan - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F60_60x84_IKIndo", "name": "Fort 60gsm (60x84cm) - IK Indo", "gsm": 60, "parent_width_cm": 60, "parent_height_cm": 84, "price_above_500": 366000.0, "price_below_500": 370000.0, "price_per_ram": 366000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F60_65x86_IKIndo", "name": "Fort 60gsm (65x86cm) - IK Indo", "gsm": 60, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 406000.0, "price_below_500": 411000.0, "price_per_ram": 406000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F60_79x109_IKIndo", "name": "Fort 60gsm (79x109cm) - IK Indo", "gsm": 60, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 625000.0, "price_below_500": 633000.0, "price_per_ram": 625000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F70_60x84_IKIndo", "name": "Fort 70gsm (60x84cm) - IK Indo", "gsm": 70, "parent_width_cm": 60, "parent_height_cm": 84, "price_above_500": 388000.0, "price_below_500": 393000.0, "price_per_ram": 388000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F70_65x86_IKIndo", "name": "Fort 70gsm (65x86cm) - IK Indo", "gsm": 70, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 430000.0, "price_below_500": 436000.0, "price_per_ram": 430000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F70_79x109_IKIndo", "name": "Fort 70gsm (79x109cm) - IK Indo", "gsm": 70, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 663000.0, "price_below_500": 672000.0, "price_per_ram": 663000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F80_60x84_IKIndo", "name": "Fort 80gsm (60x84cm) - IK Indo", "gsm": 80, "parent_width_cm": 60, "parent_height_cm": 84, "price_above_500": 444000.0, "price_below_500": 450000.0, "price_per_ram": 444000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F80_65x86_IKIndo", "name": "Fort 80gsm (65x86cm) - IK Indo", "gsm": 80, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 492000.0, "price_below_500": 499000.0, "price_per_ram": 492000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F80_79x109_IKIndo", "name": "Fort 80gsm (79x109cm) - IK Indo", "gsm": 80, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 758000.0, "price_below_500": 768000.0, "price_per_ram": 758000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F100_60x84_IKIndo", "name": "Fort 100gsm (60x84cm) - IK Indo", "gsm": 100, "parent_width_cm": 60, "parent_height_cm": 84, "price_above_500": 554000.0, "price_below_500": 562000.0, "price_per_ram": 554000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F100_65x86_IKIndo", "name": "Fort 100gsm (65x86cm) - IK Indo", "gsm": 100, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 615000.0, "price_below_500": 623000.0, "price_per_ram": 615000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F100_79x109_IKIndo", "name": "Fort 100gsm (79x109cm) - IK Indo", "gsm": 100, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 947000.0, "price_below_500": 960000.0, "price_per_ram": 947000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F120_60x84_IKIndo", "name": "Fort 120gsm (60x84cm) - IK Indo", "gsm": 120, "parent_width_cm": 60, "parent_height_cm": 84, "price_above_500": 665000.0, "price_below_500": 674000.0, "price_per_ram": 665000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F120_65x86_IKIndo", "name": "Fort 120gsm (65x86cm) - IK Indo", "gsm": 120, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 738000.0, "price_below_500": 748000.0, "price_per_ram": 738000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F120_79x109_IKIndo", "name": "Fort 120gsm (79x109cm) - IK Indo", "gsm": 120, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 1137000.0, "price_below_500": 1152000.0, "price_per_ram": 1137000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F140_65x86_IKIndo", "name": "Fort 140gsm (65x86cm) - IK Indo", "gsm": 140, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 880000.0, "price_below_500": 892000.0, "price_per_ram": 880000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F140_79x109_IKIndo", "name": "Fort 140gsm (79x109cm) - IK Indo", "gsm": 140, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 1356000.0, "price_below_500": 1374000.0, "price_per_ram": 1356000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F160_65x86_IKIndo", "name": "Fort 160gsm (65x86cm) - IK Indo", "gsm": 160, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1006000.0, "price_below_500": 1020000.0, "price_per_ram": 1006000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F160_79x109_IKIndo", "name": "Fort 160gsm (79x109cm) - IK Indo", "gsm": 160, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 1550000.0, "price_below_500": 1571000.0, "price_per_ram": 1550000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F150_65x86_IKIndo", "name": "Fort 150gsm (65x86cm) - IK Indo", "gsm": 150, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 943000.0, "price_below_500": 956000.0, "price_per_ram": 943000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F150_79x109_IKIndo", "name": "Fort 150gsm (79x109cm) - IK Indo", "gsm": 150, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 1453000.0, "price_below_500": 1472000.0, "price_per_ram": 1453000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F180_65x86_IKIndo", "name": "Fort 180gsm (65x86cm) - IK Indo", "gsm": 180, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1283000.0, "price_below_500": 1298000.0, "price_per_ram": 1283000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F180_79x109_IKIndo", "name": "Fort 180gsm (79x109cm) - IK Indo", "gsm": 180, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 1976000.0, "price_below_500": 1999000.0, "price_per_ram": 1976000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F200_65x86_IKIndo", "name": "Fort 200gsm (65x86cm) - IK Indo", "gsm": 200, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1576000.0, "price_below_500": 1593000.0, "price_per_ram": 1576000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F200_79x109_IKIndo", "name": "Fort 200gsm (79x109cm) - IK Indo", "gsm": 200, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 2428000.0, "price_below_500": 2454000.0, "price_per_ram": 2428000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F230_65x86_IKIndo", "name": "Fort 230gsm (65x86cm) - IK Indo", "gsm": 230, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1813000.0, "price_below_500": 1832000.0, "price_per_ram": 1813000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F230_79x109_IKIndo", "name": "Fort 230gsm (79x109cm) - IK Indo", "gsm": 230, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 2793000.0, "price_below_500": 2822000.0, "price_per_ram": 2793000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F250_65x86_IKIndo", "name": "Fort 250gsm (65x86cm) - IK Indo", "gsm": 250, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1970000.0, "price_below_500": 1991000.0, "price_per_ram": 1970000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F250_79x109_IKIndo", "name": "Fort 250gsm (79x109cm) - IK Indo", "gsm": 250, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 3035000.0, "price_below_500": 3068000.0, "price_per_ram": 3035000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IK Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F300_65x86_3ĐT", "name": "Fort 300gsm (65x86cm) - 3ĐT", "gsm": 300, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 2474000.0, "price_below_500": 2499000.0, "price_per_ram": 2474000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu 3ĐT (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F300_79x109_3ĐT", "name": "Fort 300gsm (79x109cm) - 3ĐT", "gsm": 300, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 3810000.0, "price_below_500": 3849000.0, "price_per_ram": 3810000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu 3ĐT (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "Fkem 80_60x84_YP_TQ", "name": "Fort 80gsm (60x84cm) - YP - TQ", "gsm": 80, "parent_width_cm": 60, "parent_height_cm": 84, "price_above_500": 534000.0, "price_below_500": 540000.0, "price_per_ram": 534000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu YP - TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "Fkem 80_65x86_YP_TQ", "name": "Fort 80gsm (65x86cm) - YP - TQ", "gsm": 80, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 593000.0, "price_below_500": 599000.0, "price_per_ram": 593000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu YP - TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "Fkem 80_79x109_YP_TQ", "name": "Fort 80gsm (79x109cm) - YP - TQ", "gsm": 80, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 913000.0, "price_below_500": 923000.0, "price_per_ram": 913000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu YP - TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F200_65x86_IPSUN_TQ", "name": "Fort 200gsm (65x86cm) - IP SUN - TQ", "gsm": 200, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1453000.0, "price_below_500": 1470000.0, "price_per_ram": 1453000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IP SUN - TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F200_79x109_IPSUN_TQ", "name": "Fort 200gsm (79x109cm) - IP SUN - TQ", "gsm": 200, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 2239000.0, "price_below_500": 2265000.0, "price_per_ram": 2239000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IP SUN - TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F230_65x86_IPSUN_TQ", "name": "Fort 230gsm (65x86cm) - IP SUN - TQ", "gsm": 230, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1671000.0, "price_below_500": 1691000.0, "price_per_ram": 1671000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IP SUN - TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F230_79x109_IPSUN_TQ", "name": "Fort 230gsm (79x109cm) - IP SUN - TQ", "gsm": 230, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 2575000.0, "price_below_500": 2604000.0, "price_per_ram": 2575000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IP SUN - TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F250_65x86_IPSUN_TQ", "name": "Fort 250gsm (65x86cm) - IP SUN - TQ", "gsm": 250, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1817000.0, "price_below_500": 1838000.0, "price_per_ram": 1817000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IP SUN - TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F250_79x109_IPSUN_TQ", "name": "Fort 250gsm (79x109cm) - IP SUN - TQ", "gsm": 250, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 2799000.0, "price_below_500": 2831000.0, "price_per_ram": 2799000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IP SUN - TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F300_65x86_IPSUN_TQ", "name": "Fort 300gsm (65x86cm) - IP SUN - TQ", "gsm": 300, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 2222000.0, "price_below_500": 2247000.0, "price_per_ram": 2222000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IP SUN - TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "F300_79x109_IPSUN_TQ", "name": "Fort 300gsm (79x109cm) - IP SUN - TQ", "gsm": 300, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 3423000.0, "price_below_500": 3462000.0, "price_per_ram": 3423000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu IP SUN - TQ (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "B250_65x86_3ĐT_baobì", "name": "Bristol 250gsm (65x86cm) - 3ĐT - bao bì", "gsm": 250, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1677000.0, "price_below_500": 1698000.0, "price_per_ram": 1677000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu 3ĐT - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "B250_79x109_3ĐT_baobì", "name": "Bristol 250gsm (79x109cm) - 3ĐT - bao bì", "gsm": 250, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 2583000.0, "price_below_500": 2616000.0, "price_per_ram": 2583000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu 3ĐT - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "B300_65x86_3ĐT_baobì", "name": "Bristol 300gsm (65x86cm) - 3ĐT - bao bì", "gsm": 300, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1970000.0, "price_below_500": 1996000.0, "price_per_ram": 1970000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu 3ĐT - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "B300_79x109_3ĐT_baobì", "name": "Bristol 300gsm (79x109cm) - 3ĐT - bao bì", "gsm": 300, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 3035000.0, "price_below_500": 3074000.0, "price_per_ram": 3035000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu 3ĐT - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "B350_65x86_3ĐT_baobì", "name": "Bristol 350gsm (65x86cm) - 3ĐT - bao bì", "gsm": 350, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 2348000.0, "price_below_500": 2377000.0, "price_per_ram": 2348000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu 3ĐT - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "B350_79x109_3ĐT_baobì", "name": "Bristol 350gsm (79x109cm) - 3ĐT - bao bì", "gsm": 350, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 3617000.0, "price_below_500": 3662000.0, "price_per_ram": 3617000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu 3ĐT - bao bì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "B300_65x86_AF_Indo", "name": "Bristol 300gsm (65x86cm) - AF - Indo", "gsm": 300, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1845000.0, "price_below_500": 1870000.0, "price_per_ram": 1845000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu AF - Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "B300_79x109_AF_Indo", "name": "Bristol 300gsm (79x109cm) - AF - Indo", "gsm": 300, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 2842000.0, "price_below_500": 2880000.0, "price_per_ram": 2842000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu AF - Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "B350_65x86_AF_Indo", "name": "Bristol 350gsm (65x86cm) - AF - Indo", "gsm": 350, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 2152000.0, "price_below_500": 2181000.0, "price_per_ram": 2152000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu AF - Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "B350_79x109_AF_Indo", "name": "Bristol 350gsm (79x109cm) - AF - Indo", "gsm": 350, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 3315000.0, "price_below_500": 3360000.0, "price_per_ram": 3315000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu AF - Indo (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "D230_65x86_Lion_Malay", "name": "Duplex 230gsm (65x86cm) - Lion - Malay", "gsm": 230, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1189000.0, "price_below_500": 1209000.0, "price_per_ram": 1189000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Lion - Malay (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "D230_79x109_Lion_Malay", "name": "Duplex 230gsm (79x109cm) - Lion - Malay", "gsm": 230, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 1832000.0, "price_below_500": 1862000.0, "price_per_ram": 1832000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Lion - Malay (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "D250_65x86_Lion_Malay", "name": "Duplex 250gsm (65x86cm) - Lion - Malay", "gsm": 250, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1244000.0, "price_below_500": 1265000.0, "price_per_ram": 1244000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Lion - Malay (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "D250_79x109_Lion_Malay", "name": "Duplex 250gsm (79x109cm) - Lion - Malay", "gsm": 250, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 1916000.0, "price_below_500": 1948000.0, "price_per_ram": 1916000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Lion - Malay (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "D300_65x86_Lion_Malay", "name": "Duplex 300gsm (65x86cm) - Lion - Malay", "gsm": 300, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1484000.0, "price_below_500": 1509000.0, "price_per_ram": 1484000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Lion - Malay (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "D300_79x109_Lion_Malay", "name": "Duplex 300gsm (79x109cm) - Lion - Malay", "gsm": 300, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 2286000.0, "price_below_500": 2325000.0, "price_per_ram": 2286000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Lion - Malay (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "D350_65x86_Lion_Malay", "name": "Duplex 350gsm (65x86cm) - Lion - Malay", "gsm": 350, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1653000.0, "price_below_500": 1683000.0, "price_per_ram": 1653000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Lion - Malay (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "D350_79x109_Lion_Malay", "name": "Duplex 350gsm (79x109cm) - Lion - Malay", "gsm": 350, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 2547000.0, "price_below_500": 2592000.0, "price_per_ram": 2547000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Lion - Malay (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "D400_65x86_Lion_Malay", "name": "Duplex 400gsm (65x86cm) - Lion - Malay", "gsm": 400, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1889000.0, "price_below_500": 1923000.0, "price_per_ram": 1889000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Lion - Malay (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "D400_79x109_Lion_Malay", "name": "Duplex 400gsm (79x109cm) - Lion - Malay", "gsm": 400, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 2911000.0, "price_below_500": 2962000.0, "price_per_ram": 2911000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Lion - Malay (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "D230_65x86_ViệtTrì", "name": "Duplex 230gsm (65x86cm) - Việt Trì", "gsm": 230, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1112000.0, "price_below_500": 1131000.0, "price_per_ram": 1112000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Việt Trì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "D230_79x109_ViệtTrì", "name": "Duplex 230gsm (79x109cm) - Việt Trì", "gsm": 230, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 1713000.0, "price_below_500": 1743000.0, "price_per_ram": 1713000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Việt Trì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "D300_65x86_ViệtTrì", "name": "Duplex 300gsm (65x86cm) - Việt Trì", "gsm": 300, "parent_width_cm": 65, "parent_height_cm": 86, "price_above_500": 1358000.0, "price_below_500": 1384000.0, "price_per_ram": 1358000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Việt Trì (BG Thuận Phát T9/2026)", "is_active": 1 }, { "code": "D300_79x109_ViệtTrì", "name": "Duplex 300gsm (79x109cm) - Việt Trì", "gsm": 300, "parent_width_cm": 79, "parent_height_cm": 109, "price_above_500": 2092000.0, "price_below_500": 2131000.0, "price_per_ram": 2092000.0, "price_per_kg": 0, "supplier": "Thuận Phát", "unit": "ram", "description": "Hiệu Việt Trì (BG Thuận Phát T9/2026)", "is_active": 1 }]1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798import openpyxlimport sqlite3import jsonimport osimport sys
sys.stdout.reconfigure(encoding='utf-8')
wb = openpyxl.load_workbook('C:/Users/admin/Downloads/BG Thu\u1eadn Ph\u00e1t T9.26.xlsx', data_only=True)ws = wb['Trang 2']
type_map = { 'I': 'Ivory', 'C': 'Couche', 'F': 'Fort', 'D': 'Duplex', 'B': 'Bristol',}
papers = []for r in range(6, 131): vals = [ws.cell(r, c).value for c in range(1, 11)] code_raw = str(vals[1]).strip() prefix = code_raw[0].upper() gsm = int(vals[2]) w = int(vals[3]) h = int(vals[4]) brand = str(vals[5]).strip() if vals[5] else '' p_above_500 = float(vals[7]) if vals[7] else 0.0 p_below_500 = float(vals[9]) if vals[9] else 0.0
type_name = type_map.get(prefix, 'Giấy ' + prefix) full_name = f'{type_name} {gsm}gsm ({w}x{h}cm)' if brand: full_name += f' - {brand}'
clean_brand = brand.replace(' ', '').replace('-', '_') code = f'{code_raw}_{w}x{h}_{clean_brand}' if clean_brand else f'{code_raw}_{w}x{h}' desc = f'Hiệu {brand} (BG Thuận Phát T9/2026)'
papers.append({ 'code': code, 'name': full_name, 'gsm': gsm, 'parent_width_cm': w, 'parent_height_cm': h, 'price_above_500': p_above_500, 'price_below_500': p_below_500, 'price_per_ram': p_above_500, 'price_per_kg': 0, 'supplier': 'Thuận Phát', 'unit': 'ram', 'description': desc, 'is_active': 1 })
print(f'Parsed {len(papers)} papers.')
db_path = os.path.join(os.getcwd(), 'data', 'printcal.db')conn = sqlite3.connect(db_path)c = conn.cursor()
# Check and add columnsc.execute('PRAGMA table_info(paper_types)')cols = [col[1] for col in c.fetchall()]
if 'supplier' not in cols: c.execute("ALTER TABLE paper_types ADD COLUMN supplier TEXT NOT NULL DEFAULT 'Thuận Phát'")if 'price_above_500' not in cols: c.execute("ALTER TABLE paper_types ADD COLUMN price_above_500 REAL NOT NULL DEFAULT 0")if 'price_below_500' not in cols: c.execute("ALTER TABLE paper_types ADD COLUMN price_below_500 REAL NOT NULL DEFAULT 0")
# Clear old papers and insert 125 new papersc.execute('DELETE FROM paper_types')
for p in papers: c.execute(""" INSERT INTO paper_types (code, name, gsm, parent_width_cm, parent_height_cm, price_above_500, price_below_500, price_per_ram, price_per_kg, supplier, unit, description, is_active) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) """, ( p['code'], p['name'], p['gsm'], p['parent_width_cm'], p['parent_height_cm'], p['price_above_500'], p['price_below_500'], p['price_per_ram'], p['price_per_kg'], p['supplier'], p['unit'], p['description'], p['is_active'] ))
conn.commit()print('Successfully inserted 125 papers into data/printcal.db!')
# Verificationc.execute('SELECT count(*), supplier FROM paper_types GROUP BY supplier')print('DB Verification:', c.fetchall())
# Save to a json file for easy import in db.tsjson_path = os.path.join(os.getcwd(), 'data', 'papers_t9_26.json')with open(json_path, 'w', encoding='utf-8') as f: json.dump(papers, f, ensure_ascii=False, indent=2)print('Saved data/papers_t9_26.json!')21 unmodified lines2223242526271 unmodified line2930313233343536373821 unmodified linesreturn NextResponse.json({ error: 'Không tìm thấy loại giấy yêu cầu' }, { status: 400 });}const paperType: PaperType = {id: paperRow.id as number,code: paperRow.code as string,1 unmodified linegsm: paperRow.gsm as number,parentWidthCm: paperRow.parent_width_cm as number,parentHeightCm: paperRow.parent_height_cm as number,pricePerRam: paperRow.price_per_ram as number,pricePerKg: paperRow.price_per_kg as number,unit: paperRow.unit as 'ram' | 'kg',description: paperRow.description as string,isActive: Boolean(paperRow.is_active),};21 unmodified lines2223242526272829301 unmodified line3233343536373839404142434421 unmodified linesreturn NextResponse.json({ error: 'Không tìm thấy loại giấy yêu cầu' }, { status: 400 });}const pAbove = Number(paperRow.price_above_500) || Number(paperRow.price_per_ram) || 0;const pBelow = Number(paperRow.price_below_500) || pAbove;const paperType: PaperType = {id: paperRow.id as number,code: paperRow.code as string,1 unmodified linegsm: paperRow.gsm as number,parentWidthCm: paperRow.parent_width_cm as number,parentHeightCm: paperRow.parent_height_cm as number,priceAbove500: pAbove,priceBelow500: pBelow,pricePerRam: pAbove,supplier: (paperRow.supplier as string) || 'Thuận Phát',pricePerKg: 0,unit: 'ram',description: (paperRow.description as string) || '',isActive: Boolean(paperRow.is_active),};
1 unmodified line234567891011121314151617181920212223245 unmodified lines3031323334353637382 unmodified lines4142434445464748499 unmodified lines5960616263646566672 unmodified lines7071727374757677781 unmodified lineimport { getDb } from '@/lib/db';import { PaperType } from '@/types';export async function GET() {try {const db = getDb();const rows = db.prepare('SELECT * FROM paper_types ORDER BY is_active DESC, name ASC, gsm ASC').all() as Record<string, unknown>[];const papers: PaperType[] = rows.map((r) => ({id: r.id as number,code: r.code as string,name: r.name as string,gsm: r.gsm as number,parentWidthCm: r.parent_width_cm as number,parentHeightCm: r.parent_height_cm as number,pricePerRam: r.price_per_ram as number,pricePerKg: r.price_per_kg as number,unit: r.unit as 'ram' | 'kg',description: (r.description as string) || '',isActive: Boolean(r.is_active),}));return NextResponse.json(papers);} catch (err: unknown) {return NextResponse.json({ error: (err as Error).message }, { status: 500 });5 unmodified linesconst body = await req.json();const db = getDb();const stmt = db.prepare(`INSERT INTO paper_types (code, name, gsm, parent_width_cm, parent_height_cm, price_per_ram, price_per_kg, unit, description, is_active)VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);const result = stmt.run(2 unmodified linesbody.gsm,body.parentWidthCm,body.parentHeightCm,body.pricePerRam,body.pricePerKg || 0,body.unit || 'ram',body.description || '',body.isActive !== false ? 1 : 0);9 unmodified linesconst body = await req.json();const db = getDb();const stmt = db.prepare(`UPDATE paper_typesSET name = ?, gsm = ?, parent_width_cm = ?, parent_height_cm = ?, price_per_ram = ?, price_per_kg = ?, unit = ?, description = ?, is_active = ?, updated_at = CURRENT_TIMESTAMPWHERE id = ?`);2 unmodified linesbody.gsm,body.parentWidthCm,body.parentHeightCm,body.pricePerRam,body.pricePerKg || 0,body.unit || 'ram',body.description || '',body.isActive ? 1 : 0,body.id1 unmodified line2345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505 unmodified lines5657585960616263646566672 unmodified lines7071727374757677787980819 unmodified lines9192939495969798991001011022 unmodified lines1051061071081091101111121131141 unmodified lineimport { getDb } from '@/lib/db';import { PaperType } from '@/types';export async function GET(req: NextRequest) {try {const db = getDb();const { searchParams } = new URL(req.url);const supplier = searchParams.get('supplier');const q = searchParams.get('q');let query = 'SELECT * FROM paper_types WHERE 1=1';const params: unknown[] = [];if (supplier && supplier !== 'all') {query += ' AND supplier = ?';params.push(supplier);}if (q) {query += ' AND (name LIKE ? OR code LIKE ? OR description LIKE ?)';const term = `%${q}%`;params.push(term, term, term);}query += ' ORDER BY is_active DESC, supplier ASC, name ASC, gsm ASC';const rows = db.prepare(query).all(...params) as Record<string, unknown>[];const papers: PaperType[] = rows.map((r) => {const pAbove = Number(r.price_above_500) || Number(r.price_per_ram) || 0;const pBelow = Number(r.price_below_500) || pAbove;return {id: r.id as number,code: r.code as string,name: r.name as string,gsm: r.gsm as number,parentWidthCm: r.parent_width_cm as number,parentHeightCm: r.parent_height_cm as number,priceAbove500: pAbove,priceBelow500: pBelow,pricePerRam: pAbove,pricePerKg: 0,supplier: (r.supplier as string) || 'Thuận Phát',unit: 'ram',description: (r.description as string) || '',isActive: Boolean(r.is_active),};});return NextResponse.json(papers);} catch (err: unknown) {return NextResponse.json({ error: (err as Error).message }, { status: 500 });5 unmodified linesconst body = await req.json();const db = getDb();const pAbove = Number(body.priceAbove500 ?? body.pricePerRam) || 0;const pBelow = Number(body.priceBelow500) || pAbove;const stmt = db.prepare(`INSERT INTO paper_types (code, name, gsm, parent_width_cm, parent_height_cm, price_above_500, price_below_500, price_per_ram, price_per_kg, supplier, unit, description, is_active)VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);const result = stmt.run(2 unmodified linesbody.gsm,body.parentWidthCm,body.parentHeightCm,pAbove,pBelow,pAbove,0,body.supplier || 'Thuận Phát','ram',body.description || '',body.isActive !== false ? 1 : 0);9 unmodified linesconst body = await req.json();const db = getDb();const pAbove = Number(body.priceAbove500 ?? body.pricePerRam) || 0;const pBelow = Number(body.priceBelow500) || pAbove;const stmt = db.prepare(`UPDATE paper_typesSET name = ?, gsm = ?, parent_width_cm = ?, parent_height_cm = ?, price_above_500 = ?, price_below_500 = ?, price_per_ram = ?, price_per_kg = 0, supplier = ?, unit = 'ram', description = ?, is_active = ?, updated_at = CURRENT_TIMESTAMPWHERE id = ?`);2 unmodified linesbody.gsm,body.parentWidthCm,body.parentHeightCm,pAbove,pBelow,pAbove,body.supplier || 'Thuận Phát',body.description || '',body.isActive ? 1 : 0,body.id
11 unmodified lines12131415161718 unmodified lines36373839404116 unmodified lines585960616263402 unmodified lines466467468469470471472473474475476477478479480481482483484485486487488489333 unmodified lines82382482582682782811 unmodified linesimport { FinishingManager } from '@/components/FinishingManager';import { CustomerManager } from '@/components/CustomerManager';import { SettingsManager } from '@/components/SettingsManager';import {CalculationInput,CalculationResult,18 unmodified linesLayoutGrid,TrendingUp,FileText,} from 'lucide-react';export default function HomePage() {16 unmodified linesconst [heightMm, setHeightMm] = useState(297);const [bleedMm, setBleedMm] = useState(2);const [paperTypeId, setPaperTypeId] = useState<number>(0);const [printSides, setPrintSides] = useState<'1_side' | '2_side'>('2_side');const [colorsFront, setColorsFront] = useState(4);const [colorsBack, setColorsBack] = useState(4);402 unmodified lines{/* Loại giấy */}<div><label className="block text-slate-600 font-medium mb-1">Chất liệu giấy in</label><selectvalue={paperTypeId}onChange={(e) => setPaperTypeId(Number(e.target.value))}className="w-full border border-slate-300 rounded-lg p-2.5 bg-white font-medium text-slate-800 text-xs">{Object.entries(groupedPapers).map(([groupName, groupItems]) =>groupItems.length > 0 ? (<optgroup key={groupName} label={groupName}>{groupItems.map((p) => (<option key={p.id} value={p.id}>{p.name} — {p.pricePerRam > 0 ? `${p.pricePerRam.toLocaleString('vi-VN')}đ/ram` : `${p.pricePerKg.toLocaleString('vi-VN')}đ/kg`}</option>))}</optgroup>) : null)}</select></div>{/* Số mặt in & Công nghệ in */}333 unmodified lines}}/>)}</div>);}11 unmodified lines1213141516171818 unmodified lines3738394041424316 unmodified lines60616263646566402 unmodified lines469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535333 unmodified lines86987087187287387487587687787887988088188288388488588611 unmodified linesimport { FinishingManager } from '@/components/FinishingManager';import { CustomerManager } from '@/components/CustomerManager';import { SettingsManager } from '@/components/SettingsManager';import { PaperSelectorModal } from '@/components/PaperSelectorModal';import {CalculationInput,CalculationResult,18 unmodified linesLayoutGrid,TrendingUp,FileText,Search,} from 'lucide-react';export default function HomePage() {16 unmodified linesconst [heightMm, setHeightMm] = useState(297);const [bleedMm, setBleedMm] = useState(2);const [paperTypeId, setPaperTypeId] = useState<number>(0);const [isPaperModalOpen, setIsPaperModalOpen] = useState(false);const [printSides, setPrintSides] = useState<'1_side' | '2_side'>('2_side');const [colorsFront, setColorsFront] = useState(4);const [colorsBack, setColorsBack] = useState(4);402 unmodified lines{/* Loại giấy */}<div><div className="flex items-center justify-between mb-1.5"><label className="block text-slate-700 font-bold">Chất liệu giấy in</label><buttontype="button"onClick={() => setIsPaperModalOpen(true)}className="inline-flex items-center gap-1 text-[11px] font-semibold text-blue-600 hover:text-blue-700 bg-blue-50 hover:bg-blue-100 px-2.5 py-1 rounded-lg transition-colors"><Search className="w-3.5 h-3.5" />Tra cứu & Đổi loại giấy (125+ loại)</button></div>{/* Selected Paper Preview Card */}<divonClick={() => setIsPaperModalOpen(true)}className="group relative cursor-pointer border border-slate-300 hover:border-blue-500 bg-white hover:bg-blue-50/20 p-3 rounded-xl transition-all shadow-2xs"><div className="flex items-start justify-between gap-2"><div><div className="flex items-center gap-2 mb-1"><span className="inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold bg-amber-50 text-amber-800 border border-amber-200">NCC: {selectedPaper?.supplier || 'Thuận Phát'}</span><span className="font-mono text-xs text-slate-500 font-semibold">{selectedPaper?.code}</span></div><h4 className="font-bold text-slate-900 text-sm group-hover:text-blue-600 transition-colors">{selectedPaper?.name || 'Chưa chọn giấy'}</h4><p className="text-[11px] text-slate-500 mt-0.5">Định lượng: <strong className="text-blue-700">{selectedPaper?.gsm} gsm</strong> • Khổ mẹ: <strong>{selectedPaper?.parentWidthCm} × {selectedPaper?.parentHeightCm} cm</strong></p></div><div className="text-right shrink-0"><div className="text-[11px] font-medium text-slate-500">Đơn giá áp dụng:</div><div className="font-black text-emerald-700 text-sm">{((result?.quantities?.parentSheetsNeeded || 0) >= 500? (selectedPaper?.priceAbove500 || selectedPaper?.pricePerRam || 0): (selectedPaper?.priceBelow500 || selectedPaper?.priceAbove500 || selectedPaper?.pricePerRam || 0)).toLocaleString('vi-VN')} đ/ram</div><div className="text-[10px] text-slate-400">{(result?.quantities?.parentSheetsNeeded || 0) >= 500? 'Mức ≥ 500 tờ (nguyên ram)': 'Mức < 500 tờ (bán lẻ)'}</div></div></div><div className="mt-2 pt-2 border-t border-slate-100 flex items-center justify-between text-[11px]"><span className="text-slate-400">Bấm vào đây để tìm theo NCC, loại giấy, định lượng gsm...</span><span className="text-blue-600 font-semibold group-hover:underline">Đổi giấy →</span></div></div></div>{/* Số mặt in & Công nghệ in */}333 unmodified lines}}/>)}{/* Modal Tra Cứu & Chọn Loại Giấy */}<PaperSelectorModalisOpen={isPaperModalOpen}onClose={() => setIsPaperModalOpen(false)}papers={papers}selectedPaperId={paperTypeId}onSelectPaper={(paper) => {setPaperTypeId(paper.id);setIsPaperModalOpen(false);}}/></div>);}
123456781 unmodified line10111213141511 unmodified lines2728293031323334353637383940412 unmodified lines444546474849504 unmodified lines555657585960616263646566676869707172737 unmodified lines818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651666 unmodified lines1731741751761771781791 unmodified line1811821831841851862 unmodified lines18919019119219319419544 unmodified lines240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288'use client';import React, { useState, useEffect } from 'react';import { PaperType } from '@/types';import { Plus, Edit2, Trash2, Check, X, FileSpreadsheet, RefreshCw } from 'lucide-react';export const PaperManager: React.FC = () => {const [papers, setPapers] = useState<PaperType[]>([]);1 unmodified lineconst [editingPaper, setEditingPaper] = useState<Partial<PaperType> | null>(null);const [isModalOpen, setIsModalOpen] = useState(false);const fetchPapers = async () => {try {setLoading(true);11 unmodified linesfetchPapers();}, []);const handleOpenAdd = () => {setEditingPaper({code: `C_${Date.now().toString().slice(-4)}`,name: 'Couche ',gsm: 150,parentWidthCm: 65,parentHeightCm: 86,pricePerRam: 500000,pricePerKg: 28500,unit: 'ram',description: '',isActive: true,2 unmodified lines};const handleOpenEdit = (p: PaperType) => {setEditingPaper({ ...p });setIsModalOpen(true);};4 unmodified linesconst isUpdate = Boolean(editingPaper.id);const method = isUpdate ? 'PUT' : 'POST';try {const res = await fetch('/api/papers', {method,headers: { 'Content-Type': 'application/json' },body: JSON.stringify(editingPaper),});if (res.ok) {setIsModalOpen(false);setEditingPaper(null);fetchPapers();}} catch (err) {console.error(err);}};7 unmodified lines}};return (<div className="space-y-4"><div className="flex items-center justify-between bg-white p-4 rounded-xl border border-slate-200 shadow-xs"><div><h2 className="text-base font-bold text-slate-800">Kho Bảng Giá Giấy In</h2><p className="text-xs text-slate-500">Quản lý các loại giấy (Couche, Ivory, Ford, Bristol, Kraft) và đơn giá thị trường</p></div><buttononClick={handleOpenAdd}className="flex items-center gap-1.5 px-3.5 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-xs font-semibold shadow transition-colors"><Plus className="w-4 h-4" />Thêm Loại Giấy</button></div><div className="bg-white rounded-xl border border-slate-200 shadow-xs overflow-hidden"><div className="overflow-x-auto"><table className="w-full text-xs text-left"><thead className="bg-slate-50 border-b border-slate-200 text-slate-600 font-semibold uppercase"><tr><th className="py-3 px-4">Mã Giấy</th><th className="py-3 px-4">Tên Loại Giấy</th><th className="py-3 px-4 text-center">Định Lượng</th><th className="py-3 px-4 text-center">Khổ Giấy Mẹ</th><th className="py-3 px-4 text-right">Giá / Ram (500 tờ)</th><th className="py-3 px-4 text-right">Giá / Kg</th><th className="py-3 px-4 text-center">Trạng Thái</th><th className="py-3 px-4 text-right">Thao Tác</th></tr></thead><tbody className="divide-y divide-slate-100 text-slate-700">{loading ? (<tr><td colSpan={8} className="py-8 text-center text-slate-400"><RefreshCw className="w-5 h-5 animate-spin mx-auto text-blue-500 mb-1" />Đang tải dữ liệu giấy...</td></tr>) : (papers.map((p) => (<tr key={p.id} className="hover:bg-slate-50 transition-colors"><td className="py-2.5 px-4 font-mono font-bold text-slate-700">{p.code}</td><td className="py-2.5 px-4"><strong className="block text-slate-900">{p.name}</strong>{p.description && <span className="text-[11px] text-slate-400">{p.description}</span>}</td><td className="py-2.5 px-4 text-center font-semibold text-blue-700">{p.gsm} gsm</td><td className="py-2.5 px-4 text-center font-medium text-slate-700">{p.parentWidthCm} × {p.parentHeightCm} cm</td><td className="py-2.5 px-4 text-right font-bold text-slate-900 text-sm">{p.pricePerRam > 0 ? `${p.pricePerRam.toLocaleString('vi-VN')}đ` : '-'}</td><td className="py-2.5 px-4 text-right font-medium text-slate-600">{p.pricePerKg > 0 ? `${p.pricePerKg.toLocaleString('vi-VN')}đ` : '-'}</td><td className="py-2.5 px-4 text-center"><span className={`px-2 py-0.5 rounded-full text-[10px] font-bold ${p.isActive ? 'bg-emerald-100 text-emerald-800' : 'bg-slate-100 text-slate-500'}`}>{p.isActive ? 'Đang dùng' : 'Tạm khóa'}</span></td><td className="py-2.5 px-4 text-right whitespace-nowrap"><div className="flex items-center justify-end gap-1"><buttononClick={() => handleOpenEdit(p)}className="p-1.5 text-slate-500 hover:text-blue-600 rounded hover:bg-slate-100"title="Sửa giá giấy"><Edit2 className="w-3.5 h-3.5" /></button><buttononClick={() => handleDelete(p.id)}className="p-1.5 text-slate-400 hover:text-rose-600 rounded hover:bg-rose-50"title="Xóa loại giấy"><Trash2 className="w-3.5 h-3.5" /></button></div></td></tr>)))}</tbody></table>6 unmodified lines<div className="bg-white rounded-xl shadow-xl max-w-lg w-full overflow-hidden"><div className="p-4 bg-slate-900 text-white flex items-center justify-between"><h3 className="font-bold text-sm">{editingPaper.id ? 'Cập Nhật Loại Giấy' : 'Thêm Mới Loại Giấy'}</h3><button onClick={() => setIsModalOpen(false)} className="text-slate-400 hover:text-white"><X className="w-5 h-5" />1 unmodified line</div><form onSubmit={handleSave} className="p-5 space-y-3 text-xs"><div className="grid grid-cols-2 gap-3"><div><label className="block text-slate-600 font-medium mb-1">Mã Giấy *</label>2 unmodified linesrequiredvalue={editingPaper.code || ''}onChange={(e) => setEditingPaper({ ...editingPaper, code: e.target.value })}className="w-full border border-slate-300 rounded-lg p-2 focus:ring-1 focus:ring-blue-500"/></div><div>44 unmodified lines</div></div><div className="grid grid-cols-2 gap-3"><div><label className="block text-slate-600 font-medium mb-1">Giá / Ram (500 tờ) VNĐ</label><inputtype="number"value={editingPaper.pricePerRam || 0}onChange={(e) => setEditingPaper({ ...editingPaper, pricePerRam: Number(e.target.value) })}className="w-full border border-slate-300 rounded-lg p-2 focus:ring-1 focus:ring-blue-500"/></div><div><label className="block text-slate-600 font-medium mb-1">Giá / Kg (VNĐ)</label><inputtype="number"value={editingPaper.pricePerKg || 0}onChange={(e) => setEditingPaper({ ...editingPaper, pricePerKg: Number(e.target.value) })}className="w-full border border-slate-300 rounded-lg p-2 focus:ring-1 focus:ring-blue-500"/></div></div><div><label className="block text-slate-600 font-medium mb-1">Ghi Chú / Ứng Dụng</label><inputtype="text"value={editingPaper.description || ''}onChange={(e) => setEditingPaper({ ...editingPaper, description: e.target.value })}placeholder="Ví dụ: Dùng in tờ rơi, ruột catalogue..."className="w-full border border-slate-300 rounded-lg p-2 focus:ring-1 focus:ring-blue-500"/></div><div className="flex justify-end gap-2 pt-3 border-t border-slate-100"><buttontype="button"onClick={() => setIsModalOpen(false)}className="px-4 py-2 border border-slate-300 rounded-lg text-slate-600 hover:bg-slate-50">Hủy</button><buttontype="submit"className="px-4 py-2 bg-blue-600 text-white font-semibold rounded-lg hover:bg-blue-700">Lưu Thông Tin</button>123456781 unmodified line101112131415161718192011 unmodified lines32333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798992 unmodified lines1021031041051061071081091101111121134 unmodified lines1181191201211221231241251261271281291301311321331341351361371381391401411421431441451467 unmodified lines1541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204216 unmodified lines4284294304314324334341 unmodified line4364374384394404414424434444454464474484494504514524534542 unmodified lines45745845946046146246344 unmodified lines508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588'use client';import React, { useState, useEffect, useMemo } from 'react';import { PaperType } from '@/types';import { Plus, Edit2, Trash2, Check, X, RefreshCw, Search, Building2, Filter, RotateCcw } from 'lucide-react';export const PaperManager: React.FC = () => {const [papers, setPapers] = useState<PaperType[]>([]);1 unmodified lineconst [editingPaper, setEditingPaper] = useState<Partial<PaperType> | null>(null);const [isModalOpen, setIsModalOpen] = useState(false);// Search & Filter Stateconst [searchTerm, setSearchTerm] = useState('');const [selectedSupplier, setSelectedSupplier] = useState<string>('all');const [selectedCategory, setSelectedCategory] = useState<string>('all');const fetchPapers = async () => {try {setLoading(true);11 unmodified linesfetchPapers();}, []);// Unique suppliersconst suppliers = useMemo(() => {const list = Array.from(new Set(papers.map((p) => p.supplier || 'Thuận Phát'))).filter(Boolean);return list.sort();}, [papers]);// Categories helperconst getCategory = (p: PaperType): string => {const name = p.name.toLowerCase();const code = p.code.toLowerCase();if (name.includes('ivory') || code.startsWith('i')) return 'Ivory';if (name.includes('couche') || code.startsWith('c')) return 'Couche';if (name.includes('fort') || name.includes('ford') || code.startsWith('f')) return 'Fort';if (name.includes('duplex') || code.startsWith('d')) return 'Duplex';if (name.includes('bristol') || code.startsWith('b')) return 'Bristol';if (name.includes('decal')) return 'Decal';if (name.includes('kraft')) return 'Kraft';return 'Khác';};const categories = ['Ivory', 'Couche', 'Fort', 'Duplex', 'Bristol', 'Decal', 'Kraft', 'Khác'];// Filtered papersconst filteredPapers = useMemo(() => {return papers.filter((p) => {// Supplier filterif (selectedSupplier !== 'all') {const supp = p.supplier || 'Thuận Phát';if (supp !== selectedSupplier) return false;}// Category filterif (selectedCategory !== 'all') {if (getCategory(p) !== selectedCategory) return false;}// Text searchif (searchTerm.trim()) {const query = searchTerm.toLowerCase();const matchName = p.name.toLowerCase().includes(query);const matchCode = p.code.toLowerCase().includes(query);const matchDesc = (p.description || '').toLowerCase().includes(query);const matchSupp = (p.supplier || '').toLowerCase().includes(query);const matchGsm = p.gsm.toString().includes(query);if (!matchName && !matchCode && !matchDesc && !matchSupp && !matchGsm) return false;}return true;});}, [papers, selectedSupplier, selectedCategory, searchTerm]);const handleOpenAdd = () => {setEditingPaper({supplier: 'Thuận Phát',code: `C_${Date.now().toString().slice(-4)}`,name: 'Couche ',gsm: 150,parentWidthCm: 65,parentHeightCm: 86,priceAbove500: 500000,priceBelow500: 530000,pricePerRam: 500000,unit: 'ram',description: '',isActive: true,2 unmodified lines};const handleOpenEdit = (p: PaperType) => {setEditingPaper({...p,supplier: p.supplier || 'Thuận Phát',priceAbove500: p.priceAbove500 || p.pricePerRam || 0,priceBelow500: p.priceBelow500 || p.pricePerRam || 0,});setIsModalOpen(true);};4 unmodified linesconst isUpdate = Boolean(editingPaper.id);const method = isUpdate ? 'PUT' : 'POST';// Normalize prices: keep pricePerRam synced with priceAbove500const payload = {...editingPaper,pricePerRam: editingPaper.priceAbove500 || 0,};try {const res = await fetch('/api/papers', {method,headers: { 'Content-Type': 'application/json' },body: JSON.stringify(payload),});if (res.ok) {setIsModalOpen(false);setEditingPaper(null);fetchPapers();} else {const data = await res.json();alert(data.error || 'Có lỗi xảy ra khi lưu giấy!');}} catch (err) {console.error(err);alert('Không thể kết nối đến máy chủ.');}};7 unmodified lines}};const resetFilters = () => {setSearchTerm('');setSelectedSupplier('all');setSelectedCategory('all');};return (<div className="space-y-4">{/* Header & Quick stats */}<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-3 bg-white p-4 rounded-xl border border-slate-200 shadow-xs"><div><h2 className="text-base font-bold text-slate-800 flex items-center gap-2"><Building2 className="w-5 h-5 text-blue-600" />Kho Bảng Giá Giấy In & Nhà Cung Cấp</h2><p className="text-xs text-slate-500 mt-0.5">Quản lý báo giá theo mức ≥ 500 tờ (trên ram) và < 500 tờ (dưới ram). Đã phân chia rõ từng Nhà Cung Cấp (NCC).</p></div><div className="flex items-center gap-2"><buttononClick={fetchPapers}className="p-2 border border-slate-200 text-slate-600 hover:text-blue-600 rounded-lg text-xs font-semibold hover:bg-slate-50 transition-colors"title="Tải lại dữ liệu"><RefreshCw className={`w-4 h-4 ${loading ? 'animate-spin text-blue-600' : ''}`} /></button><buttononClick={handleOpenAdd}className="flex items-center gap-1.5 px-3.5 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-xs font-semibold shadow transition-colors whitespace-nowrap"><Plus className="w-4 h-4" />Thêm Loại Giấy Mới</button></div></div>{/* Filter Bar */}<div className="bg-white p-3.5 rounded-xl border border-slate-200 shadow-xs space-y-3"><div className="grid grid-cols-1 md:grid-cols-12 gap-3 items-center">{/* Search box */}<div className="md:col-span-6 relative"><Search className="w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-slate-400" /><inputtype="text"value={searchTerm}onChange={(e) => setSearchTerm(e.target.value)}placeholder="Tìm theo tên giấy, mã giấy, hiệu (Ningbo, Nevia, Indo...), NCC..."className="w-full pl-9 pr-8 py-2 text-xs border border-slate-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 font-medium"/>{searchTerm && (<buttononClick={() => setSearchTerm('')}className="absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600"><X className="w-3.5 h-3.5" /></button>)}</div>{/* Supplier Filter */}<div className="md:col-span-3 flex items-center gap-1.5"><span className="text-[11px] font-semibold text-slate-500 shrink-0">NCC:</span><selectvalue={selectedSupplier}onChange={(e) => setSelectedSupplier(e.target.value)}className="w-full text-xs border border-slate-300 rounded-lg p-2 bg-white font-medium text-slate-700 focus:ring-1 focus:ring-blue-500"><option value="all">Tất cả NCC ({suppliers.length})</option>{suppliers.map((s) => (<option key={s} value={s}>{s}</option>))}</select></div>{/* Category Filter */}<div className="md:col-span-3 flex items-center gap-1.5"><span className="text-[11px] font-semibold text-slate-500 shrink-0">Loại:</span><selectvalue={selectedCategory}onChange={(e) => setSelectedCategory(e.target.value)}className="w-full text-xs border border-slate-300 rounded-lg p-2 bg-white font-medium text-slate-700 focus:ring-1 focus:ring-blue-500"><option value="all">Tất cả loại giấy</option>{categories.map((c) => (<option key={c} value={c}>{c}</option>))}</select></div></div>{/* Filter Badges & Count */}<div className="flex flex-wrap items-center justify-between gap-2 pt-2 border-t border-slate-100 text-xs"><div className="flex items-center gap-2"><span className="text-slate-500">Hiển thị <strong className="text-blue-600">{filteredPapers.length}</strong> / {papers.length} loại giấy</span>{(searchTerm || selectedSupplier !== 'all' || selectedCategory !== 'all') && (<buttononClick={resetFilters}className="inline-flex items-center gap-1 text-[11px] text-rose-600 hover:text-rose-700 font-medium px-2 py-0.5 rounded bg-rose-50 hover:bg-rose-100 transition-colors"><RotateCcw className="w-3 h-3" />Xóa bộ lọc</button>)}</div>{/* Quick Category Pills */}<div className="flex items-center gap-1 overflow-x-auto pb-0.5 max-w-full">{['all', 'Couche', 'Ivory', 'Fort', 'Duplex', 'Bristol'].map((cat) => (<buttonkey={cat}onClick={() => setSelectedCategory(cat)}className={`px-2 py-0.5 text-[11px] rounded-full font-medium transition-colors ${selectedCategory === cat? 'bg-blue-600 text-white shadow-2xs': 'bg-slate-100 text-slate-600 hover:bg-slate-200'}`}>{cat === 'all' ? 'Tất cả' : cat}</button>))}</div></div></div>{/* Main Table */}<div className="bg-white rounded-xl border border-slate-200 shadow-xs overflow-hidden"><div className="overflow-x-auto"><table className="w-full text-xs text-left"><thead className="bg-slate-50 border-b border-slate-200 text-slate-600 font-semibold uppercase"><tr><th className="py-3 px-3 w-28">Nhà Cung Cấp</th><th className="py-3 px-3">Mã Giấy</th><th className="py-3 px-3">Tên Loại Giấy & Hiệu</th><th className="py-3 px-3 text-center">Định Lượng</th><th className="py-3 px-3 text-center">Khổ Mẹ</th><th className="py-3 px-3 text-right"><div>Giá ≥ 500 tờ</div><div className="text-[10px] text-slate-400 font-normal">Nguyên ram</div></th><th className="py-3 px-3 text-right"><div>Giá < 500 tờ</div><div className="text-[10px] text-slate-400 font-normal">Bán lẻ</div></th><th className="py-3 px-3 text-center">Trạng Thái</th><th className="py-3 px-3 text-right">Thao Tác</th></tr></thead><tbody className="divide-y divide-slate-100 text-slate-700">{loading ? (<tr><td colSpan={9} className="py-8 text-center text-slate-400"><RefreshCw className="w-5 h-5 animate-spin mx-auto text-blue-500 mb-1" />Đang tải dữ liệu giấy...</td></tr>) : filteredPapers.length === 0 ? (<tr><td colSpan={9} className="py-8 text-center text-slate-400">Không tìm thấy loại giấy nào phù hợp với bộ lọc.</td></tr>) : (filteredPapers.map((p) => {const priceAbove = p.priceAbove500 || p.pricePerRam || 0;const priceBelow = p.priceBelow500 || priceAbove;const unitPriceAbove = Math.round(priceAbove / 500);const unitPriceBelow = Math.round(priceBelow / 500);return (<tr key={p.id} className="hover:bg-blue-50/30 transition-colors">{/* NCC */}<td className="py-2.5 px-3"><span className="inline-flex items-center px-2 py-0.5 rounded-md text-[10px] font-bold bg-amber-50 text-amber-800 border border-amber-200">{p.supplier || 'Thuận Phát'}</span></td>{/* Mã giấy */}<td className="py-2.5 px-3 font-mono font-bold text-slate-700 whitespace-nowrap">{p.code}</td>{/* Tên loại giấy */}<td className="py-2.5 px-3"><strong className="block text-slate-900">{p.name}</strong>{p.description && <span className="text-[11px] text-slate-400">{p.description}</span>}</td>{/* GSM */}<td className="py-2.5 px-3 text-center font-bold text-blue-700 whitespace-nowrap">{p.gsm} gsm</td>{/* Khổ mẹ */}<td className="py-2.5 px-3 text-center font-medium text-slate-700 whitespace-nowrap">{p.parentWidthCm} × {p.parentHeightCm} cm</td>{/* Giá >= 500 tờ (trên ram) */}<td className="py-2.5 px-3 text-right whitespace-nowrap"><div className="font-bold text-emerald-700 text-sm">{priceAbove > 0 ? `${priceAbove.toLocaleString('vi-VN')} đ` : '-'}</div>{priceAbove > 0 && (<div className="text-[10px] text-slate-400">~{unitPriceAbove.toLocaleString('vi-VN')} đ/tờ</div>)}</td>{/* Giá < 500 tờ (dưới ram) */}<td className="py-2.5 px-3 text-right whitespace-nowrap"><div className="font-bold text-blue-700 text-sm">{priceBelow > 0 ? `${priceBelow.toLocaleString('vi-VN')} đ` : '-'}</div>{priceBelow > 0 && (<div className="text-[10px] text-slate-400">~{unitPriceBelow.toLocaleString('vi-VN')} đ/tờ</div>)}</td>{/* Trạng thái */}<td className="py-2.5 px-3 text-center whitespace-nowrap"><spanclassName={`px-2 py-0.5 rounded-full text-[10px] font-bold ${p.isActive ? 'bg-emerald-100 text-emerald-800' : 'bg-slate-100 text-slate-500'}`}>{p.isActive ? 'Đang d��ng' : 'Tạm khóa'}</span></td>{/* Thao tác */}<td className="py-2.5 px-3 text-right whitespace-nowrap"><div className="flex items-center justify-end gap-1"><buttononClick={() => handleOpenEdit(p)}className="p-1.5 text-slate-500 hover:text-blue-600 rounded hover:bg-slate-100"title="Sửa giá giấy"><Edit2 className="w-3.5 h-3.5" /></button><buttononClick={() => handleDelete(p.id)}className="p-1.5 text-slate-400 hover:text-rose-600 rounded hover:bg-rose-50"title="Xóa loại giấy"><Trash2 className="w-3.5 h-3.5" /></button></div></td></tr>);}))}</tbody></table>6 unmodified lines<div className="bg-white rounded-xl shadow-xl max-w-lg w-full overflow-hidden"><div className="p-4 bg-slate-900 text-white flex items-center justify-between"><h3 className="font-bold text-sm">{editingPaper.id ? 'Cập Nhật Bảng Giá Giấy' : 'Thêm Mới Loại Giấy'}</h3><button onClick={() => setIsModalOpen(false)} className="text-slate-400 hover:text-white"><X className="w-5 h-5" />1 unmodified line</div><form onSubmit={handleSave} className="p-5 space-y-3 text-xs">{/* Nhà Cung Cấp */}<div><label className="block text-slate-600 font-medium mb-1">Nhà Cung Cấp (NCC) *</label><inputtype="text"requiredvalue={editingPaper.supplier || ''}onChange={(e) => setEditingPaper({ ...editingPaper, supplier: e.target.value })}placeholder="Ví dụ: Thuận Phát, Mai Lam, Tân Phát Đạt..."className="w-full border border-slate-300 rounded-lg p-2 focus:ring-1 focus:ring-blue-500 font-medium"/></div><div className="grid grid-cols-2 gap-3"><div><label className="block text-slate-600 font-medium mb-1">Mã Giấy *</label>2 unmodified linesrequiredvalue={editingPaper.code || ''}onChange={(e) => setEditingPaper({ ...editingPaper, code: e.target.value })}className="w-full border border-slate-300 rounded-lg p-2 focus:ring-1 focus:ring-blue-500 font-mono"/></div><div>44 unmodified lines</div></div>{/* 2 Mức giá: >= 500 tờ và < 500 tờ */}<div className="grid grid-cols-2 gap-3 bg-slate-50 p-3 rounded-lg border border-slate-200"><div><label className="block text-emerald-800 font-bold mb-1">Giá ≥ 500 tờ (VNĐ/ram) *</label><inputtype="number"requiredvalue={editingPaper.priceAbove500 || 0}onChange={(e) =>setEditingPaper({...editingPaper,priceAbove500: Number(e.target.value),pricePerRam: Number(e.target.value),})}className="w-full border border-emerald-300 rounded-lg p-2 focus:ring-1 focus:ring-emerald-500 font-bold text-emerald-900 bg-white"/><span className="text-[10px] text-slate-400">Áp dụng khi dùng ≥ 500 tờ mẹ (~{Math.round((editingPaper.priceAbove500 || 0) / 500).toLocaleString('vi-VN')} đ/tờ)</span></div><div><label className="block text-blue-800 font-bold mb-1">Giá < 500 tờ (VNĐ/ram) *</label><inputtype="number"requiredvalue={editingPaper.priceBelow500 || 0}onChange={(e) => setEditingPaper({ ...editingPaper, priceBelow500: Number(e.target.value) })}className="w-full border border-blue-300 rounded-lg p-2 focus:ring-1 focus:ring-blue-500 font-bold text-blue-900 bg-white"/><span className="text-[10px] text-slate-400">Bán lẻ khi dùng < 500 tờ mẹ (~{Math.round((editingPaper.priceBelow500 || 0) / 500).toLocaleString('vi-VN')} đ/tờ)</span></div></div><div><label className="block text-slate-600 font-medium mb-1">Hiệu / Ghi Chú / Ứng Dụng</label><inputtype="text"value={editingPaper.description || ''}onChange={(e) => setEditingPaper({ ...editingPaper, description: e.target.value })}placeholder="Ví dụ: AF - Indo, Nevia, Oji..."className="w-full border border-slate-300 rounded-lg p-2 focus:ring-1 focus:ring-blue-500"/></div><div className="flex items-center gap-2 pt-1"><inputtype="checkbox"id="isActivePaper"checked={editingPaper.isActive ?? true}onChange={(e) => setEditingPaper({ ...editingPaper, isActive: e.target.checked })}className="rounded text-blue-600 focus:ring-blue-500 w-4 h-4"/><label htmlFor="isActivePaper" className="text-slate-700 font-medium cursor-pointer">Kích hoạt sử dụng loại giấy này</label></div><div className="flex justify-end gap-2 pt-3 border-t border-slate-100"><buttontype="button"onClick={() => setIsModalOpen(false)}className="px-4 py-2 border border-slate-300 rounded-lg text-slate-600 hover:bg-slate-50 font-medium">Hủy</button><buttontype="submit"className="px-4 py-2 bg-blue-600 text-white font-semibold rounded-lg hover:bg-blue-700 transition-colors">Lưu Thông Tin</button>
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431'use client';
import React, { useState, useMemo } from 'react';import { PaperType } from '@/types';import { Search, X, Building2, Check, Filter, RotateCcw, Sparkles, Layers, ChevronDown,} from 'lucide-react';
interface PaperSelectorModalProps { isOpen: boolean; onClose: () => void; papers: PaperType[]; selectedPaperId: number; onSelectPaper: (paper: PaperType) => void;}
export const PaperSelectorModal: React.FC<PaperSelectorModalProps> = ({ isOpen, onClose, papers, selectedPaperId, onSelectPaper,}) => { const [searchTerm, setSearchTerm] = useState(''); const [selectedSupplier, setSelectedSupplier] = useState<string>('all'); const [selectedCategory, setSelectedCategory] = useState<string>('all'); const [selectedSize, setSelectedSize] = useState<string>('all'); const [selectedGsm, setSelectedGsm] = useState<string>('all');
// Danh sách nhà cung cấp duy nhất const suppliers = useMemo(() => { const list = Array.from(new Set(papers.map((p) => p.supplier || 'Thuận Phát'))).filter(Boolean); return list.sort(); }, [papers]);
// Phân loại danh mục giấy const getCategory = (p: PaperType): string => { const name = p.name.toLowerCase(); const code = p.code.toLowerCase(); if (name.includes('ivory') || code.startsWith('i')) return 'Ivory'; if (name.includes('couche') || code.startsWith('c')) return 'Couche'; if (name.includes('fort') || name.includes('ford') || code.startsWith('f')) return 'Fort'; if (name.includes('duplex') || code.startsWith('d')) return 'Duplex'; if (name.includes('bristol') || code.startsWith('b')) return 'Bristol'; if (name.includes('decal')) return 'Decal'; if (name.includes('kraft')) return 'Kraft'; return 'Khác'; };
const categories = ['Ivory', 'Couche', 'Fort', 'Duplex', 'Bristol', 'Decal', 'Kraft'];
// Danh sách các khổ giấy duy nhất const sizes = useMemo(() => { const s = Array.from(new Set(papers.map((p) => `${p.parentWidthCm}x${p.parentHeightCm}`))); return s.sort(); }, [papers]);
// Danh sách các mức định lượng gsm duy nhất const gsmList = useMemo(() => { const g = Array.from(new Set(papers.map((p) => p.gsm))).filter(Boolean); return g.sort((a, b) => a - b); }, [papers]);
// Lọc danh sách giấy theo các tiêu chí const filteredPapers = useMemo(() => { return papers.filter((p) => { // 1. Lọc theo NCC if (selectedSupplier !== 'all') { const supp = p.supplier || 'Thuận Phát'; if (supp !== selectedSupplier) return false; }
// 2. Lọc theo danh mục loại giấy if (selectedCategory !== 'all') { const cat = getCategory(p); if (cat !== selectedCategory) return false; }
// 3. Lọc theo khổ giấy mẹ if (selectedSize !== 'all') { const sizeStr = `${p.parentWidthCm}x${p.parentHeightCm}`; if (sizeStr !== selectedSize) return false; }
// 4. Lọc theo định lượng gsm if (selectedGsm !== 'all') { if (p.gsm !== Number(selectedGsm)) return false; }
// 5. Tìm kiếm từ khóa tự do (mã, tên, hiệu, ncc) if (searchTerm.trim()) { const term = searchTerm.toLowerCase().trim(); const matchName = p.name.toLowerCase().includes(term); const matchCode = p.code.toLowerCase().includes(term); const matchDesc = (p.description || '').toLowerCase().includes(term); const matchSupp = (p.supplier || '').toLowerCase().includes(term); if (!matchName && !matchCode && !matchDesc && !matchSupp) return false; }
return true; }); }, [papers, searchTerm, selectedSupplier, selectedCategory, selectedSize, selectedGsm]);
const handleResetFilters = () => { setSearchTerm(''); setSelectedSupplier('all'); setSelectedCategory('all'); setSelectedSize('all'); setSelectedGsm('all'); };
const getCategoryColor = (cat: string) => { switch (cat) { case 'Ivory': return 'bg-purple-100 text-purple-700 border-purple-200'; case 'Couche': return 'bg-blue-100 text-blue-700 border-blue-200'; case 'Fort': return 'bg-emerald-100 text-emerald-700 border-emerald-200'; case 'Duplex': return 'bg-amber-100 text-amber-700 border-amber-200'; case 'Bristol': return 'bg-indigo-100 text-indigo-700 border-indigo-200'; case 'Decal': return 'bg-rose-100 text-rose-700 border-rose-200'; case 'Kraft': return 'bg-orange-100 text-orange-700 border-orange-200'; default: return 'bg-slate-100 text-slate-700 border-slate-200'; } };
if (!isOpen) return null;
return ( <div className="fixed inset-0 z-50 overflow-y-auto bg-slate-900/60 backdrop-blur-xs flex items-center justify-center p-3 sm:p-4"> <div className="bg-white w-full max-w-5xl rounded-2xl shadow-2xl overflow-hidden flex flex-col max-h-[92vh] border border-slate-200 animate-in fade-in zoom-in-95 duration-150"> {/* Header Modal */} <div className="bg-slate-900 text-white p-4 sm:px-6 flex items-center justify-between shrink-0"> <div className="flex items-center gap-2.5"> <div className="w-8 h-8 rounded-lg bg-blue-600 flex items-center justify-center text-white shadow-xs"> <Layers className="w-4 h-4" /> </div> <div> <h2 className="text-base font-bold text-white flex items-center gap-2"> Chọn & Lọc Bảng Giá Giấy In <span className="text-xs px-2 py-0.5 rounded-full bg-blue-500/30 text-blue-200 border border-blue-400/30 font-normal"> {papers.length} loại </span> </h2> <p className="text-[11px] text-slate-400"> Tìm kiếm thông minh theo Nhà Cung Cấp, Loại Giấy, Khổ & Định Lượng </p> </div> </div>
<button type="button" onClick={onClose} className="p-1.5 rounded-lg text-slate-400 hover:text-white hover:bg-slate-800 transition-colors" > <X className="w-5 h-5" /> </button> </div>
{/* Thanh công cụ tìm kiếm & Bộ lọc (Search & Filters Panel) */} <div className="bg-slate-50 border-b border-slate-200 p-4 space-y-3 shrink-0"> {/* Hàng 1: Ô tìm kiếm từ khóa */} <div className="relative"> <Search className="w-4 h-4 absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400" /> <input type="text" value={searchTerm} onChange={(e) => setSearchTerm(e.target.value)} placeholder="Nhập mã giấy, tên giấy, thương hiệu (Indo, Nevia, Oji...), nhà cung cấp..." className="w-full bg-white border border-slate-300 rounded-xl pl-10 pr-10 py-2.5 text-xs text-slate-900 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 shadow-2xs font-medium" /> {searchTerm && ( <button type="button" onClick={() => setSearchTerm('')} className="absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 p-1" > <X className="w-3.5 h-3.5" /> </button> )} </div>
{/* Hàng 2: Các bộ lọc dạng Dropdown / Chips */} <div className="grid grid-cols-2 sm:grid-cols-4 gap-2"> {/* Lọc theo NCC */} <div> <label className="block text-[11px] font-semibold text-slate-600 mb-1 flex items-center gap-1"> <Building2 className="w-3 h-3 text-slate-400" /> Nhà Cung Cấp (NCC) </label> <select value={selectedSupplier} onChange={(e) => setSelectedSupplier(e.target.value)} className="w-full bg-white border border-slate-300 rounded-lg py-1.5 px-2.5 text-xs font-medium text-slate-800 focus:outline-none focus:ring-2 focus:ring-blue-500" > <option value="all">🏢 Tất Cả Nhà Cung Cấp ({suppliers.length})</option> {suppliers.map((supp) => ( <option key={supp} value={supp}> {supp} </option> ))} </select> </div>
{/* Lọc theo Loại Giấy */} <div> <label className="block text-[11px] font-semibold text-slate-600 mb-1 flex items-center gap-1"> <Layers className="w-3 h-3 text-slate-400" /> Loại Giấy </label> <select value={selectedCategory} onChange={(e) => setSelectedCategory(e.target.value)} className="w-full bg-white border border-slate-300 rounded-lg py-1.5 px-2.5 text-xs font-medium text-slate-800 focus:outline-none focus:ring-2 focus:ring-blue-500" > <option value="all">Tất Cả Loại Giấy</option> {categories.map((cat) => ( <option key={cat} value={cat}> Giấy {cat} </option> ))} </select> </div>
{/* Lọc theo Khổ Giấy */} <div> <label className="block text-[11px] font-semibold text-slate-600 mb-1 flex items-center gap-1"> <Filter className="w-3 h-3 text-slate-400" /> Khổ Giấy Mẹ </label> <select value={selectedSize} onChange={(e) => setSelectedSize(e.target.value)} className="w-full bg-white border border-slate-300 rounded-lg py-1.5 px-2.5 text-xs font-medium text-slate-800 focus:outline-none focus:ring-2 focus:ring-blue-500" > <option value="all">Tất Cả Khổ Giấy</option> {sizes.map((s) => ( <option key={s} value={s}> Khổ {s.replace('x', ' × ')} cm </option> ))} </select> </div>
{/* Lọc theo Định Lượng GSM */} <div> <label className="block text-[11px] font-semibold text-slate-600 mb-1 flex items-center gap-1"> <Sparkles className="w-3 h-3 text-slate-400" /> Định Lượng (gsm) </label> <select value={selectedGsm} onChange={(e) => setSelectedGsm(e.target.value)} className="w-full bg-white border border-slate-300 rounded-lg py-1.5 px-2.5 text-xs font-medium text-slate-800 focus:outline-none focus:ring-2 focus:ring-blue-500" > <option value="all">Tất Cả Định Lượng</option> {gsmList.map((g) => ( <option key={g} value={g}> {g} gsm </option> ))} </select> </div> </div>
{/* Dải thông tin trạng thái lọc */} <div className="flex items-center justify-between text-xs pt-1 border-t border-slate-200/80"> <span className="text-slate-500 font-medium"> Tìm thấy <strong className="text-blue-700 font-bold">{filteredPapers.length}</strong> / {papers.length} loại giấy {selectedSupplier !== 'all' && <span> • NCC: <strong className="text-slate-800">{selectedSupplier}</strong></span>} {selectedCategory !== 'all' && <span> • Loại: <strong className="text-slate-800">{selectedCategory}</strong></span>} </span>
{(searchTerm || selectedSupplier !== 'all' || selectedCategory !== 'all' || selectedSize !== 'all' || selectedGsm !== 'all') && ( <button type="button" onClick={handleResetFilters} className="text-blue-600 hover:text-blue-800 font-semibold flex items-center gap-1 hover:underline" > <RotateCcw className="w-3 h-3" /> Xóa bộ lọc </button> )} </div> </div>
{/* Danh sách thẻ giấy (Scrollable Cards Grid) */} <div className="flex-1 overflow-y-auto p-4 sm:p-5 space-y-3 divide-y divide-slate-100"> {filteredPapers.length === 0 ? ( <div className="py-16 text-center text-slate-400 space-y-3"> <Layers className="w-10 h-10 mx-auto text-slate-300" /> <p className="text-sm font-medium text-slate-600"> Không tìm thấy loại giấy nào phù hợp với bộ lọc. </p> <button type="button" onClick={handleResetFilters} className="px-4 py-2 bg-blue-50 hover:bg-blue-100 text-blue-700 font-semibold text-xs rounded-lg transition-colors inline-flex items-center gap-1.5" > <RotateCcw className="w-3.5 h-3.5" /> Khôi phục tất cả bộ lọc </button> </div> ) : ( <div className="grid grid-cols-1 md:grid-cols-2 gap-3"> {filteredPapers.map((paper) => { const isSelected = paper.id === selectedPaperId; const cat = getCategory(paper); const priceAbove = paper.priceAbove500 || paper.pricePerRam || 0; const priceBelow = paper.priceBelow500 || priceAbove; const unitAbove = Math.round(priceAbove / 500); const unitBelow = Math.round(priceBelow / 500);
return ( <div key={paper.id} onClick={() => { onSelectPaper(paper); onClose(); }} className={`relative p-3.5 rounded-xl border transition-all cursor-pointer flex flex-col justify-between ${ isSelected ? 'border-blue-600 bg-blue-50/40 shadow-sm ring-2 ring-blue-500/20' : 'border-slate-200 hover:border-blue-300 hover:bg-slate-50/80' }`} > {/* Hàng trên: Badges */} <div> <div className="flex items-center justify-between gap-1 mb-1.5"> <div className="flex items-center gap-1.5 flex-wrap"> {/* Badge Loại giấy */} <span className={`px-2 py-0.5 rounded-md text-[10px] font-bold border ${getCategoryColor(cat)}`} > {cat} </span>
{/* Badge NCC */} <span className="px-2 py-0.5 rounded-md text-[10px] font-bold bg-slate-100 text-slate-700 border border-slate-200 flex items-center gap-1"> <Building2 className="w-2.5 h-2.5 text-slate-400" /> {paper.supplier || 'Thuận Phát'} </span>
{/* Badge Khổ giấy */} <span className="px-2 py-0.5 rounded-md text-[10px] font-medium bg-white text-slate-600 border border-slate-200"> {paper.parentWidthCm} × {paper.parentHeightCm} cm </span> </div>
{isSelected && ( <span className="inline-flex items-center gap-1 px-2 py-0.5 bg-blue-600 text-white rounded-full text-[10px] font-bold shrink-0"> <Check className="w-3 h-3" /> Đang chọn </span> )} </div>
{/* Tên giấy & Mã */} <h4 className="text-xs font-bold text-slate-900 leading-snug"> {paper.name} </h4> {paper.description && ( <p className="text-[11px] text-slate-400 mt-0.5 line-clamp-1"> {paper.description} </p> )} </div>
{/* Bảng giá: Giá trên 500 tờ (trên ram) và Giá dưới 500 tờ (dưới ram) */} <div className="mt-3 pt-2.5 border-t border-slate-200/80 grid grid-cols-2 gap-2 text-center"> <div className="bg-white/80 border border-slate-200/80 rounded-lg p-1.5"> <span className="text-[10px] text-slate-500 block font-medium"> Giá ≥ 500 tờ (Trên ram) </span> <strong className="text-xs font-black text-blue-700 block"> {priceAbove.toLocaleString('vi-VN')}đ </strong> <span className="text-[9px] text-slate-400 block"> ~{unitAbove.toLocaleString('vi-VN')}đ / tờ </span> </div>
<div className="bg-amber-50/50 border border-amber-200/60 rounded-lg p-1.5"> <span className="text-[10px] text-amber-800 block font-medium"> Giá < 500 tờ (Dưới ram) </span> <strong className="text-xs font-black text-amber-900 block"> {priceBelow.toLocaleString('vi-VN')}đ </strong> <span className="text-[9px] text-amber-700/80 block"> ~{unitBelow.toLocaleString('vi-VN')}đ / tờ </span> </div> </div> </div> ); })} </div> )} </div>
{/* Footer */} <div className="bg-slate-50 border-t border-slate-200 px-5 py-3 flex items-center justify-between shrink-0 text-xs"> <span className="text-slate-500 font-medium"> Mẹo: Click vào bất kỳ loại giấy nào để chọn ngay vào bài tính giá </span> <button type="button" onClick={onClose} className="px-4 py-1.5 bg-slate-200 hover:bg-slate-300 text-slate-800 rounded-lg font-semibold transition-colors" > Đóng </button> </div> </div> </div> );};28 unmodified lines2930313233343536111 unmodified lines1481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147228 unmodified linesgsm INTEGER NOT NULL,parent_width_cm REAL NOT NULL,parent_height_cm REAL NOT NULL,price_per_ram REAL NOT NULL,price_per_kg REAL NOT NULL,unit TEXT NOT NULL DEFAULT 'ram',description TEXT,is_active INTEGER NOT NULL DEFAULT 1,111 unmodified linesdb.exec('ALTER TABLE offset_machines ADD COLUMN includes_plate INTEGER NOT NULL DEFAULT 1;');} catch {}// Seed default data if emptyseedDefaultData(db);}function seedDefaultData(db: DatabaseSync) {const paperCount = db.prepare('SELECT COUNT(*) as cnt FROM paper_types').get() as { cnt: number };if (paperCount.cnt < 100) {if (paperCount.cnt > 0) {db.exec('DELETE FROM paper_types;');}const insertPaper = db.prepare(`INSERT INTO paper_types (code, name, gsm, parent_width_cm, parent_height_cm, price_per_ram, price_per_kg, unit, description)VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`);// Standard Vietnamese paper inventoryconst papers = [["I210_65x86_AFIndo","Ivory 210gsm (65x86cm) - AF - Indo",210,65,86,1057000,18000,"ram","Hiệu AF - Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,074,000đ/ram)"],["I210_79x109_AFIndo","Ivory 210gsm (79x109cm) - AF - Indo",210,79,109,1627000,18000,"ram","Hiệu AF - Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,655,000đ/ram)"],["I230_65x86_AFIndo","Ivory 230gsm (65x86cm) - AF - Indo",230,65,86,1119000,17400,"ram","Hiệu AF - Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,138,000đ/ram)"],["I230_79x109_AFIndo","Ivory 230gsm (79x109cm) - AF - Indo",230,79,109,1723000,17400,"ram","Hiệu AF - Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,753,000đ/ram)"],["I250_65x86_AFIndo","Ivory 250gsm (65x86cm) - AF - Indo",250,65,86,1216000,17400,"ram","Hiệu AF - Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,237,000đ/ram)"],["I250_79x109_AFIndo","Ivory 250gsm (79x109cm) - AF - Indo",250,79,109,1873000,17400,"ram","Hiệu AF - Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,905,000đ/ram)"],["I270_65x86_AFIndo","Ivory 270gsm (65x86cm) - AF - Indo",270,65,86,1313000,17400,"ram","Hiệu AF - Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,336,000đ/ram)"],["I270_79x109_AFIndo","Ivory 270gsm (79x109cm) - AF - Indo",270,79,109,2023000,17400,"ram","Hiệu AF - Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,058,000đ/ram)"],["I300_65x86_AFIndo","Ivory 300gsm (65x86cm) - AF - Indo",300,65,86,1459000,17400,"ram","Hiệu AF - Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,484,000đ/ram)"],["I300_79x109_AFIndo","Ivory 300gsm (79x109cm) - AF - Indo",300,79,109,2247000,17400,"ram","Hiệu AF - Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,286,000đ/ram)"],["I350_65x86_AFIndo","Ivory 350gsm (65x86cm) - AF - Indo",350,65,86,1702000,17400,"ram","Hiệu AF - Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,732,000đ/ram)"],["I350_79x109_AFIndo","Ivory 350gsm (79x109cm) - AF - Indo",350,79,109,2622000,17400,"ram","Hiệu AF - Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,667,000đ/ram)"],["I400_65x86_AFIndo","Ivory 400gsm (65x86cm) - AF - Indo",400,65,86,1945000,17400,"ram","Hiệu AF - Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,979,000đ/ram)"],["I400_79x109_AFIndo","Ivory 400gsm (79x109cm) - AF - Indo",400,79,109,2997000,17400,"ram","Hiệu AF - Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 3,048,000đ/ram)"],["I210_65x86_NingboTQ","Ivory 210gsm (65x86cm) - Ningbo TQ",210,65,86,1162000,19800,"ram","Hiệu Ningbo TQ (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,180,000đ/ram)"],["I210_79x109_NingboTQ","Ivory 210gsm (79x109cm) - Ningbo TQ",210,79,109,1790000,19800,"ram","Hiệu Ningbo TQ (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,817,000đ/ram)"],["I230_65x86_NingboTQ","Ivory 230gsm (65x86cm) - Ningbo TQ",230,65,86,1157000,18000,"ram","Hiệu Ningbo TQ (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,176,000đ/ram)"],["I230_79x109_NingboTQ","Ivory 230gsm (79x109cm) - Ningbo TQ",230,79,109,1782000,18000,"ram","Hiệu Ningbo TQ (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,812,000đ/ram)"],["I250_65x86_NingboTQ","Ivory 250gsm (65x86cm) - Ningbo TQ",250,65,86,1258000,18000,"ram","Hiệu Ningbo TQ (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,279,000đ/ram)"],["I250_79x109_NingboTQ","Ivory 250gsm (79x109cm) - Ningbo TQ",250,79,109,1937000,18000,"ram","Hiệu Ningbo TQ (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,970,000đ/ram)"],["I270_65x86_NingboTQ","Ivory 270gsm (65x86cm) - Ningbo TQ",270,65,86,1358000,18000,"ram","Hiệu Ningbo TQ (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,381,000đ/ram)"],["I270_79x109_NingboTQ","Ivory 270gsm (79x109cm) - Ningbo TQ",270,79,109,2092000,18000,"ram","Hiệu Ningbo TQ (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,127,000đ/ram)"],["I300_65x86_NingboTQ","Ivory 300gsm (65x86cm) - Ningbo TQ",300,65,86,1509000,18000,"ram","Hiệu Ningbo TQ (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,534,000đ/ram)"],["I300_79x109_NingboTQ","Ivory 300gsm (79x109cm) - Ningbo TQ",300,79,109,2325000,18000,"ram","Hiệu Ningbo TQ (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,364,000đ/ram)"],["I350_65x86_NingboTQ","Ivory 350gsm (65x86cm) - Ningbo TQ",350,65,86,1761000,18000,"ram","Hiệu Ningbo TQ (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,790,000đ/ram)"],["I350_79x109_NingboTQ","Ivory 350gsm (79x109cm) - Ningbo TQ",350,79,109,2712000,18000,"ram","Hiệu Ningbo TQ (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,758,000đ/ram)"],["I400_65x86_NingboTQ","Ivory 400gsm (65x86cm) - Ningbo TQ",400,65,86,2012000,18000,"ram","Hiệu Ningbo TQ (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,046,000đ/ram)"],["I400_79x109_NingboTQ","Ivory 400gsm (79x109cm) - Ningbo TQ",400,79,109,3100000,18000,"ram","Hiệu Ningbo TQ (BG Thuận Phát T4/2026. Lẻ dưới ram: 3,152,000đ/ram)"],["C80_60x84_Neviabaob","Couche 80gsm (60x84cm) - Nevia - bao bì",80,60,84,494000,24500,"ram","Hiệu Nevia - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 500,000đ/ram)"],["C80_65x86_Neviabaob","Couche 80gsm (65x86cm) - Nevia - bao bì",80,65,86,548000,24500,"ram","Hiệu Nevia - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 555,000đ/ram)"],["C80_79x109_Neviabaob","Couche 80gsm (79x109cm) - Nevia - bao bì",80,79,109,844000,24500,"ram","Hiệu Nevia - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 854,000đ/ram)"],["C100_60x84_Hainanbaob","Couche 100gsm (60x84cm) - Hainan - bao bì",100,60,84,542000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 549,000đ/ram)"],["C100_65x86_Hainanbaob","Couche 100gsm (65x86cm) - Hainan - bao bì",100,65,86,601000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 609,000đ/ram)"],["C100_79x109_Hainanbaob","Couche 100gsm (79x109cm) - Hainan - bao bì",100,79,109,926000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 939,000đ/ram)"],["C115_60x84_Hainanbaob","Couche 115gsm (60x84cm) - Hainan - bao bì",115,60,84,623000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 632,000đ/ram)"],["C115_65x86_Hainanbaob","Couche 115gsm (65x86cm) - Hainan - bao bì",115,65,86,691000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 701,000đ/ram)"],["C115_79x109_Hainanbaob","Couche 115gsm (79x109cm) - Hainan - bao bì",115,79,109,1065000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,079,000đ/ram)"],["C120_60x84_Hainanbaob","Couche 120gsm (60x84cm) - Hainan - bao bì",120,60,84,650000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 659,000đ/ram)"],["C120_65x86_Hainanbaob","Couche 120gsm (65x86cm) - Hainan - bao bì",120,65,86,721000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 731,000đ/ram)"],["C120_79x109_Hainanbaob","Couche 120gsm (79x109cm) - Hainan - bao bì",120,79,109,1111000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,126,000đ/ram)"],["C140_60x84_Hainanbaob","Couche 140gsm (60x84cm) - Hainan - bao bì",140,60,84,759000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 769,000đ/ram)"],["C140_65x86_Hainanbaob","Couche 140gsm (65x86cm) - Hainan - bao bì",140,65,86,841000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 853,000đ/ram)"],["C140_79x109_Hainanbaob","Couche 140gsm (79x109cm) - Hainan - bao bì",140,79,109,1296000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,314,000đ/ram)"],["C148_60x84_Hainanbaob","Couche 148gsm (60x84cm) - Hainan - bao bì",148,60,84,802000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 813,000đ/ram)"],["C148_65x86_Hainanbaob","Couche 148gsm (65x86cm) - Hainan - bao bì",148,65,86,889000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 902,000đ/ram)"],["C148_79x109_Hainanbaob","Couche 148gsm (79x109cm) - Hainan - bao bì",148,79,109,1370000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,389,000đ/ram)"],["C170_65x86_Hainanbaob","Couche 170gsm (65x86cm) - Hainan - bao bì",170,65,86,1022000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,036,000đ/ram)"],["C170_79x109_Hainanbaob","Couche 170gsm (79x109cm) - Hainan - bao bì",170,79,109,1574000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,596,000đ/ram)"],["C200_65x86_Hainanbaob","Couche 200gsm (65x86cm) - Hainan - bao bì",200,65,86,1202000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,219,000đ/ram)"],["C200_79x109_Hainanbaob","Couche 200gsm (79x109cm) - Hainan - bao bì",200,79,109,1851000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,877,000đ/ram)"],["C230_65x86_Hainanbaob","Couche 230gsm (65x86cm) - Hainan - bao bì",230,65,86,1382000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,401,000đ/ram)"],["C230_79x109_Hainanbaob","Couche 230gsm (79x109cm) - Hainan - bao bì",230,79,109,2129000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,159,000đ/ram)"],["C250_65x86_Hainanbaob","Couche 250gsm (65x86cm) - Hainan - bao bì",250,65,86,1502000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,523,000đ/ram)"],["C250_79x109_Hainanbaob","Couche 250gsm (79x109cm) - Hainan - bao bì",250,79,109,2314000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,346,000đ/ram)"],["C300_65x86_Hainanbaob","Couche 300gsm (65x86cm) - Hainan - bao bì",300,65,86,1803000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,828,000đ/ram)"],["C300_79x109_Hainanbaob","Couche 300gsm (79x109cm) - Hainan - bao bì",300,79,109,2777000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,816,000đ/ram)"],["C350_65x86_Hainanbaob","Couche 350gsm (65x86cm) - Hainan - bao bì",350,65,86,2103000,21500,"ram","Hiệu Hainan - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,133,000đ/ram)"],["F60_60x84_IKIndo","Fort 60gsm (60x84cm) - IK Indo",60,60,84,366000,24200,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 370,000đ/ram)"],["F60_65x86_IKIndo","Fort 60gsm (65x86cm) - IK Indo",60,65,86,406000,24200,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 411,000đ/ram)"],["F60_79x109_IKIndo","Fort 60gsm (79x109cm) - IK Indo",60,79,109,625000,24200,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 633,000đ/ram)"],["F70_60x84_IKIndo","Fort 70gsm (60x84cm) - IK Indo",70,60,84,397000,22500,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 402,000đ/ram)"],["F70_65x86_IKIndo","Fort 70gsm (65x86cm) - IK Indo",70,65,86,440000,22500,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 446,000đ/ram)"],["F70_79x109_IKIndo","Fort 70gsm (79x109cm) - IK Indo",70,79,109,678000,22500,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 687,000đ/ram)"],["F80_60x84_IKIndo","Fort 80gsm (60x84cm) - IK Indo",80,60,84,454000,22500,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 460,000đ/ram)"],["F80_65x86_IKIndo","Fort 80gsm (65x86cm) - IK Indo",80,65,86,503000,22500,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 510,000đ/ram)"],["F80_79x109_IKIndo","Fort 80gsm (79x109cm) - IK Indo",80,79,109,775000,22500,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 785,000đ/ram)"],["F100_60x84_IKIndo","Fort 100gsm (60x84cm) - IK Indo",100,60,84,567000,22500,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 575,000đ/ram)"],["F100_65x86_IKIndo","Fort 100gsm (65x86cm) - IK Indo",100,65,86,629000,22500,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 637,000đ/ram)"],["F100_79x109_IKIndo","Fort 100gsm (79x109cm) - IK Indo",100,79,109,969000,22500,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 982,000đ/ram)"],["F120_60x84_IKIndo","Fort 120gsm (60x84cm) - IK Indo",120,60,84,680000,22500,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 689,000đ/ram)"],["F120_65x86_IKIndo","Fort 120gsm (65x86cm) - IK Indo",120,65,86,755000,22500,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 765,000đ/ram)"],["F120_79x109_IKIndo","Fort 120gsm (79x109cm) - IK Indo",120,79,109,1162000,22500,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,178,000đ/ram)"],["F140_65x86_IKIndo","Fort 140gsm (65x86cm) - IK Indo",140,65,86,880000,22500,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 892,000đ/ram)"],["F140_79x109_IKIndo","Fort 140gsm (79x109cm) - IK Indo",140,79,109,1356000,22500,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,374,000đ/ram)"],["F160_65x86_IKIndo","Fort 160gsm (65x86cm) - IK Indo",160,65,86,1006000,22500,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,020,000đ/ram)"],["F160_79x109_IKIndo","Fort 160gsm (79x109cm) - IK Indo",160,79,109,1550000,22500,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,571,000đ/ram)"],["F150_65x86_IKIndo","Fort 150gsm (65x86cm) - IK Indo",150,65,86,943000,22500,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 956,000đ/ram)"],["F150_79x109_IKIndo","Fort 150gsm (79x109cm) - IK Indo",150,79,109,1453000,22500,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,472,000đ/ram)"],["F180_65x86_IKIndo","Fort 180gsm (65x86cm) - IK Indo",180,65,86,1283000,25500,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,298,000đ/ram)"],["F180_79x109_IKIndo","Fort 180gsm (79x109cm) - IK Indo",180,79,109,1976000,25500,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,999,000đ/ram)"],["F200_65x86_IKIndo","Fort 200gsm (65x86cm) - IK Indo",200,65,86,1576000,28200,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,593,000đ/ram)"],["F200_79x109_IKIndo","Fort 200gsm (79x109cm) - IK Indo",200,79,109,2428000,28200,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,454,000đ/ram)"],["F230_65x86_IKIndo","Fort 230gsm (65x86cm) - IK Indo",230,65,86,1813000,28200,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,832,000đ/ram)"],["F230_79x109_IKIndo","Fort 230gsm (79x109cm) - IK Indo",230,79,109,2793000,28200,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,822,000đ/ram)"],["F250_65x86_IKIndo","Fort 250gsm (65x86cm) - IK Indo",250,65,86,1970000,28200,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,991,000đ/ram)"],["F250_79x109_IKIndo","Fort 250gsm (79x109cm) - IK Indo",250,79,109,3035000,28200,"ram","Hiệu IK Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 3,068,000đ/ram)"],["F300_65x86_3T","Fort 300gsm (65x86cm) - 3ĐT",300,65,86,2474000,29500,"ram","Hiệu 3ĐT (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,499,000đ/ram)"],["F300_79x109_3T","Fort 300gsm (79x109cm) - 3ĐT",300,79,109,3810000,29500,"ram","Hiệu 3ĐT (BG Thuận Phát T4/2026. Lẻ dưới ram: 3,849,000đ/ram)"],["F200_65x86_IPSUNTQ","Fort 200gsm (65x86cm) - IP SUN - TQ",200,65,86,1453000,26000,"ram","Hiệu IP SUN - TQ (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,470,000đ/ram)"],["F200_79x109_IPSUNTQ","Fort 200gsm (79x109cm) - IP SUN - TQ",200,79,109,2239000,26000,"ram","Hiệu IP SUN - TQ (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,265,000đ/ram)"],["F230_65x86_IPSUNTQ","Fort 230gsm (65x86cm) - IP SUN - TQ",230,65,86,1671000,26000,"ram","Hiệu IP SUN - TQ (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,691,000đ/ram)"],["F230_79x109_IPSUNTQ","Fort 230gsm (79x109cm) - IP SUN - TQ",230,79,109,2575000,26000,"ram","Hiệu IP SUN - TQ (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,604,000đ/ram)"],["F250_65x86_IPSUNTQ","Fort 250gsm (65x86cm) - IP SUN - TQ",250,65,86,1817000,26000,"ram","Hiệu IP SUN - TQ (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,838,000đ/ram)"],["F250_79x109_IPSUNTQ","Fort 250gsm (79x109cm) - IP SUN - TQ",250,79,109,2799000,26000,"ram","Hiệu IP SUN - TQ (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,831,000đ/ram)"],["F300_65x86_IPSUNTQ","Fort 300gsm (65x86cm) - IP SUN - TQ",300,65,86,2222000,26500,"ram","Hiệu IP SUN - TQ (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,247,000đ/ram)"],["F300_79x109_IPSUNTQ","Fort 300gsm (79x109cm) - IP SUN - TQ",300,79,109,3423000,26500,"ram","Hiệu IP SUN - TQ (BG Thuận Phát T4/2026. Lẻ dưới ram: 3,462,000đ/ram)"],["B250_65x86_3Tbaob","Bristol 250gsm (65x86cm) - 3ĐT - bao bì",250,65,86,1677000,24000,"ram","Hiệu 3ĐT - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,698,000đ/ram)"],["B250_79x109_3Tbaob","Bristol 250gsm (79x109cm) - 3ĐT - bao bì",250,79,109,2583000,24000,"ram","Hiệu 3ĐT - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,616,000đ/ram)"],["B300_65x86_3Tbaob","Bristol 300gsm (65x86cm) - 3ĐT - bao bì",300,65,86,2012000,24000,"ram","Hiệu 3ĐT - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,038,000đ/ram)"],["B300_79x109_3Tbaob","Bristol 300gsm (79x109cm) - 3ĐT - bao bì",300,79,109,3100000,24000,"ram","Hiệu 3ĐT - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 3,139,000đ/ram)"],["B350_65x86_3Tbaob","Bristol 350gsm (65x86cm) - 3ĐT - bao bì",350,65,86,2348000,24000,"ram","Hiệu 3ĐT - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,377,000đ/ram)"],["B350_79x109_3Tbaob","Bristol 350gsm (79x109cm) - 3ĐT - bao bì",350,79,109,3617000,24000,"ram","Hiệu 3ĐT - bao bì (BG Thuận Phát T4/2026. Lẻ dưới ram: 3,662,000đ/ram)"],["B300_65x86_AFIndo","Bristol 300gsm (65x86cm) - AF - Indo",300,65,86,1845000,22000,"ram","Hiệu AF - Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,870,000đ/ram)"],["B300_79x109_AFIndo","Bristol 300gsm (79x109cm) - AF - Indo",300,79,109,2842000,22000,"ram","Hiệu AF - Indo (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,880,000đ/ram)"],["D230_65x86_LionMalay","Duplex 230gsm (65x86cm) - Lion - Malay",230,65,86,1189000,18500,"ram","Hiệu Lion - Malay (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,209,000đ/ram)"],["D230_79x109_LionMalay","Duplex 230gsm (79x109cm) - Lion - Malay",230,79,109,1832000,18500,"ram","Hiệu Lion - Malay (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,862,000đ/ram)"],["D250_65x86_LionMalay","Duplex 250gsm (65x86cm) - Lion - Malay",250,65,86,1223000,17500,"ram","Hiệu Lion - Malay (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,244,000đ/ram)"],["D250_79x109_LionMalay","Duplex 250gsm (79x109cm) - Lion - Malay",250,79,109,1884000,17500,"ram","Hiệu Lion - Malay (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,916,000đ/ram)"],["D300_65x86_LionMalay","Duplex 300gsm (65x86cm) - Lion - Malay",300,65,86,1425000,17000,"ram","Hiệu Lion - Malay (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,451,000đ/ram)"],["D300_79x109_LionMalay","Duplex 300gsm (79x109cm) - Lion - Malay",300,79,109,2196000,17000,"ram","Hiệu Lion - Malay (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,235,000đ/ram)"],["D350_65x86_LionMalay","Duplex 350gsm (65x86cm) - Lion - Malay",350,65,86,1604000,16400,"ram","Hiệu Lion - Malay (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,634,000đ/ram)"],["D350_79x109_LionMalay","Duplex 350gsm (79x109cm) - Lion - Malay",350,79,109,2471000,16400,"ram","Hiệu Lion - Malay (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,517,000đ/ram)"],["D400_65x86_LionMalay","Duplex 400gsm (65x86cm) - Lion - Malay",400,65,86,1834000,16400,"ram","Hiệu Lion - Malay (BG Thuận Phát T4/2026. Lẻ dưới ram: 1,867,000đ/ram)"],["D400_79x109_LionMalay","Duplex 400gsm (79x109cm) - Lion - Malay",400,79,109,2824000,16400,"ram","Hiệu Lion - Malay (BG Thuận Phát T4/2026. Lẻ dưới ram: 2,876,000đ/ram)"],["DECAL_GIAY_CAM","Decal Giấy Kham Vàng/Đế Trắng (33x48cm)",135,33,48,550000,0,"ram","In tem nhãn barcode, nhãn dán chai lọ"],["DECAL_NHUA_SUA","Decal Nhựa Sữa PVC Chống Nước (33x48cm)",150,33,48,1200000,0,"ram","Chống nước, xé không rách, dán đông lạnh, ly trà sữa"],["KRAFT_170_79x109","Kraft Nâu Tái Chế 170gsm (79x109cm)",170,79,109,820000,28000,"ram","Túi giấy kraft cà phê, shop eco"],["KRAFT_250_79x109","Kraft Nâu Tái Chế 250gsm (79x109cm)",250,79,109,1200000,28000,"ram","Hộp kraft takeaway, tag quần áo vintage"]];for (const p of papers) {insertPaper.run(...p);}}28 unmodified lines2930313233343536373839111 unmodified lines15115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921028 unmodified linesgsm INTEGER NOT NULL,parent_width_cm REAL NOT NULL,parent_height_cm REAL NOT NULL,price_above_500 REAL NOT NULL DEFAULT 0,price_below_500 REAL NOT NULL DEFAULT 0,price_per_ram REAL NOT NULL DEFAULT 0,price_per_kg REAL NOT NULL DEFAULT 0,supplier TEXT NOT NULL DEFAULT 'Thuận Phát',unit TEXT NOT NULL DEFAULT 'ram',description TEXT,is_active INTEGER NOT NULL DEFAULT 1,111 unmodified linesdb.exec('ALTER TABLE offset_machines ADD COLUMN includes_plate INTEGER NOT NULL DEFAULT 1;');} catch {}// Migrations for paper_typestry {const cols = db.prepare('PRAGMA table_info(paper_types)').all() as { name: string }[];const colNames = cols.map((c) => c.name);if (!colNames.includes('supplier')) {db.exec("ALTER TABLE paper_types ADD COLUMN supplier TEXT NOT NULL DEFAULT 'Thuận Phát';");}if (!colNames.includes('price_above_500')) {db.exec('ALTER TABLE paper_types ADD COLUMN price_above_500 REAL NOT NULL DEFAULT 0;');}if (!colNames.includes('price_below_500')) {db.exec('ALTER TABLE paper_types ADD COLUMN price_below_500 REAL NOT NULL DEFAULT 0;');}} catch {}// Seed default data if emptyseedDefaultData(db);}function seedDefaultData(db: DatabaseSync) {const paperCount = db.prepare('SELECT COUNT(*) as cnt FROM paper_types').get() as { cnt: number };if (paperCount.cnt < 120) {if (paperCount.cnt > 0) {db.exec('DELETE FROM paper_types;');}const jsonPath = path.join(process.cwd(), 'data', 'papers_t9_26.json');if (fs.existsSync(jsonPath)) {try {const rawJson = fs.readFileSync(jsonPath, 'utf-8');const papersData = JSON.parse(rawJson);const insertPaper = db.prepare(`INSERT INTO paper_types (code, name, gsm, parent_width_cm, parent_height_cm, price_above_500, price_below_500, price_per_ram, price_per_kg, supplier, unit, description, is_active)VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);for (const p of papersData) {insertPaper.run(p.code,p.name,p.gsm,p.parent_width_cm,p.parent_height_cm,p.price_above_500,p.price_below_500,p.price_per_ram || p.price_above_500,p.price_per_kg || 0,p.supplier || 'Thuận Phát',p.unit || 'ram',p.description || '',p.is_active ?? 1);}} catch (err) {console.error('Error seeding papers from json:', err);}}}
201 unmodified lines202203204205206207208209210211212213214215247 unmodified lines463464465466467468469201 unmodified linesconst parentAreaM2 = (paperType.parentWidthCm / 100) * (paperType.parentHeightCm / 100);const kgNeeded = Math.round(((parentSheetsNeeded * parentAreaM2 * paperType.gsm) / 1000) * 10) / 10;// 5. Tiền giấylet paperCost = 0;if (paperType.unit === 'kg' && paperType.pricePerKg > 0) {paperCost = Math.round(kgNeeded * paperType.pricePerKg);} else {// Tính theo ram quy đổi tờpaperCost = Math.round(parentSheetsNeeded * (paperType.pricePerRam / 500));}// 6. Tiền in ấnlet plateCost = 0;247 unmodified linesconst cuts = Math.max(1, imposition.cutsPerParentSheet);const parentSheets = Math.ceil(totalSheets / cuts);const paperCost = Math.round(parentSheets * (paperType.pricePerRam / 500));let printCost = 0;if (isDigital) {201 unmodified lines202203204205206207208209210211212213214215247 unmodified lines463464465466467468469470471472201 unmodified linesconst parentAreaM2 = (paperType.parentWidthCm / 100) * (paperType.parentHeightCm / 100);const kgNeeded = Math.round(((parentSheetsNeeded * parentAreaM2 * paperType.gsm) / 1000) * 10) / 10;// 5. Tiền giấy: Bỏ giá /kg, chỉ áp dụng giá trên 500 tờ (trên ram) và giá dưới 500 tờ (dưới ram)const priceAbove500 = paperType.priceAbove500 || paperType.pricePerRam;const priceBelow500 = paperType.priceBelow500 || priceAbove500;// Nếu số tờ mẹ >= 500 (trên 1 ram) áp dụng giá sỉ nguyên ram, nếu < 500 tờ áp dụng giá lẻ dưới ramconst isWholesale = parentSheetsNeeded >= 500;const effectiveRamPrice = isWholesale ? priceAbove500 : priceBelow500;const paperCost = Math.round(parentSheetsNeeded * (effectiveRamPrice / 500));// 6. Tiền in ấnlet plateCost = 0;247 unmodified linesconst cuts = Math.max(1, imposition.cutsPerParentSheet);const parentSheets = Math.ceil(totalSheets / cuts);const pAbove = paperType.priceAbove500 || paperType.pricePerRam;const pBelow = paperType.priceBelow500 || pAbove;const effectiveRamPrice = parentSheets >= 500 ? pAbove : pBelow;const paperCost = Math.round(parentSheets * (effectiveRamPrice / 500));let printCost = 0;if (isDigital) {
9 unmodified lines1011121314151617189 unmodified linesgsm: number;parentWidthCm: number;parentHeightCm: number;pricePerRam: number;pricePerKg: number;unit: 'ram' | 'kg';description?: string;isActive: boolean;}9 unmodified lines1011121314151617181920219 unmodified linesgsm: number;parentWidthCm: number;parentHeightCm: number;priceAbove500: number; // Giá trên 500 tờ (trên ram)priceBelow500: number; // Giá dưới 500 tờ (dưới ram)pricePerRam: number; // Giá trên ram (tương đương priceAbove500)supplier: string; // Nhà cung cấp (NCC)pricePerKg?: number; // Không bắt buộc (đã bỏ giá/kg theo yêu cầu)unit?: 'ram' | 'kg';description?: string;isActive: boolean;}
data/papers_t9_26.jsonAdded+1877
scripts/import_t9.pyAdded+98
src/app/api/calculate/route.ts+10-4
src/app/api/papers/route.ts+60-24
src/app/page.tsx+75-17
src/components/PaperManager.tsx+378-78
src/components/PaperSelectorModal.tsxAdded+431
src/lib/db.ts+50-1312
src/lib/engine/costCalculator.ts+12-9
src/types/index.ts+6-3